diff options
author | tarek <none@none> | 2009-09-20 14:48:47 +0200 |
---|---|---|
committer | tarek <none@none> | 2009-09-20 14:48:47 +0200 |
commit | ba84419dfc63e5f535faead38ee9fb60306a079c (patch) | |
tree | c489fe218f0e43d14f3a9e8f8c14517439d4fde0 /setuptools/command/easy_install.py | |
parent | 1219c326683905695fbdf60c22367129075d2f8d (diff) | |
parent | 95159c09e5bb2d1dc1f0ccf89ccbe90ecc6871a0 (diff) | |
download | external_python_setuptools-ba84419dfc63e5f535faead38ee9fb60306a079c.tar.gz external_python_setuptools-ba84419dfc63e5f535faead38ee9fb60306a079c.tar.bz2 external_python_setuptools-ba84419dfc63e5f535faead38ee9fb60306a079c.zip |
merge dance
--HG--
branch : distribute
extra : rebase_source : e0fc1e252a506a6a751f9557d4a01580e1cbbdfa
Diffstat (limited to 'setuptools/command/easy_install.py')
-rwxr-xr-x | setuptools/command/easy_install.py | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 67cf949f..195139c7 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -39,6 +39,25 @@ def samefile(p1,p2): os.path.normpath(os.path.normcase(p2)) ) +if sys.version_info <= (3,): + def _to_ascii(s): + return s + def isascii(s): + try: + unicode(s, 'ascii') + return True + except UnicodeError: + return False +else: + def _to_ascii(s): + return s.encode('ascii') + def isascii(s): + try: + s.encode('ascii') + return True + except UnicodeError: + return False + class easy_install(Command): """Manage a download/build/install process""" description = "Find/get/install Python packages" @@ -599,7 +618,7 @@ Please make the appropriate changes for your system and try again. "import pkg_resources\n" "pkg_resources.run_script(%(spec)r, %(script_name)r)\n" ) % locals() - self.write_script(script_name, script_text, 'b') + self.write_script(script_name, _to_ascii(script_text), 'b') def write_script(self, script_name, contents, mode="t", blockers=()): """Write an executable file to the scripts directory""" @@ -1381,7 +1400,7 @@ class PthDistributions(Environment): if os.path.islink(self.filename): os.unlink(self.filename) - f = open(self.filename,'wb') + f = open(self.filename,'wt') f.write(data); f.close() elif os.path.exists(self.filename): @@ -1432,7 +1451,7 @@ def get_script_header(script_text, executable=sys_executable, wininst=False): else: executable = nt_quote_arg(executable) hdr = "#!%(executable)s%(options)s\n" % locals() - if unicode(hdr,'ascii','ignore').encode('ascii') != hdr: + if not isascii(hdr): # Non-ascii path to sys.executable, use -x to prevent warnings if options: if options.strip().startswith('-'): |