diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2012-03-29 23:15:27 -0400 |
|---|---|---|
| committer | Jason R. Coombs <jaraco@jaraco.com> | 2012-03-29 23:15:27 -0400 |
| commit | d6d8bcaf4e80dae0f8ba9f81ba1db4b05b857909 (patch) | |
| tree | 2292042ee7e74f0f09171f058e751f0cbe792841 /setuptools/command | |
| parent | 0d6b0fdd59f5fb29c06ed335fc7597951c5f277f (diff) | |
| parent | df1e3725c0ef744f89e1769767e04b78ebc9a525 (diff) | |
| download | python-setuptools-git-d6d8bcaf4e80dae0f8ba9f81ba1db4b05b857909.tar.gz | |
Merge with default
--HG--
branch : distribute
extra : rebase_source : a19a5411e30665acdd86f2554921e385759b1ef3
Diffstat (limited to 'setuptools/command')
| -rw-r--r-- | setuptools/command/__init__.py | 1 | ||||
| -rw-r--r-- | setuptools/command/build_py.py | 28 | ||||
| -rwxr-xr-x | setuptools/command/easy_install.py | 45 | ||||
| -rwxr-xr-x | setuptools/command/install_egg_info.py | 2 | ||||
| -rwxr-xr-x | setuptools/command/sdist.py | 18 | ||||
| -rwxr-xr-x | setuptools/command/upload.py | 1 |
6 files changed, 66 insertions, 29 deletions
diff --git a/setuptools/command/__init__.py b/setuptools/command/__init__.py index 152406b3..b063fa19 100644 --- a/setuptools/command/__init__.py +++ b/setuptools/command/__init__.py @@ -14,7 +14,6 @@ if sys.version>='2.5': from distutils.command.bdist import bdist - if 'egg' not in bdist.format_commands: bdist.format_command['egg'] = ('bdist_egg', "Python .egg file") bdist.format_commands.append('egg') diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py index a01e2843..d53960fe 100644 --- a/setuptools/command/build_py.py +++ b/setuptools/command/build_py.py @@ -28,13 +28,8 @@ try: if not files: return log.info("Fixing "+" ".join(files)) - if not self.fixer_names: - self.fixer_names = [] - for p in setuptools.lib2to3_fixer_packages: - self.fixer_names.extend(get_fixers_from_package(p)) - if self.distribution.use_2to3_fixers is not None: - for p in self.distribution.use_2to3_fixers: - self.fixer_names.extend(get_fixers_from_package(p)) + self.__build_fixer_names() + self.__exclude_fixers() if doctests: if setuptools.run_2to3_on_doctests: r = DistutilsRefactoringTool(self.fixer_names) @@ -42,6 +37,25 @@ try: else: _Mixin2to3.run_2to3(self, files) + def __build_fixer_names(self): + if self.fixer_names: return + self.fixer_names = [] + for p in setuptools.lib2to3_fixer_packages: + self.fixer_names.extend(get_fixers_from_package(p)) + if self.distribution.use_2to3_fixers is not None: + for p in self.distribution.use_2to3_fixers: + self.fixer_names.extend(get_fixers_from_package(p)) + + def __exclude_fixers(self): + excluded_fixers = getattr(self, 'exclude_fixers', []) + if self.distribution.use_2to3_exclude_fixers is not None: + excluded_fixers.extend(self.distribution.use_2to3_exclude_fixers) + for fixer_name in excluded_fixers: + if fixer_name not in self.fixer_names: + log.warn("Excluded fixer %s not found", fixer_name) + continue + self.fixer_names.remove(fixer_name) + except ImportError: class Mixin2to3: def run_2to3(self, files, doctests=True): diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 3f1b4228..d200dac1 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -42,6 +42,10 @@ __all__ = [ import site HAS_USER_SITE = not sys.version < "2.6" and site.ENABLE_USER_SITE +import struct +def is_64bit(): + return struct.calcsize("P") == 8 + def samefile(p1,p2): if hasattr(os.path,'samefile') and ( os.path.exists(p1) and os.path.exists(p2) @@ -733,22 +737,26 @@ Please make the appropriate changes for your system and try again. spec = str(dist.as_requirement()) is_script = is_python_script(script_text, script_name) - if is_script and dev_path: - script_text = get_script_header(script_text) + ( - "# EASY-INSTALL-DEV-SCRIPT: %(spec)r,%(script_name)r\n" - "__requires__ = %(spec)r\n" - "from pkg_resources import require; require(%(spec)r)\n" - "del require\n" - "__file__ = %(dev_path)r\n" - "execfile(__file__)\n" - ) % locals() - elif is_script: - script_text = get_script_header(script_text) + ( - "# EASY-INSTALL-SCRIPT: %(spec)r,%(script_name)r\n" - "__requires__ = %(spec)r\n" - "import pkg_resources\n" - "pkg_resources.run_script(%(spec)r, %(script_name)r)\n" - ) % locals() + def get_template(filename): + """ + There are a couple of template scripts in the package. This + function loads one of them and prepares it for use. + + These templates use triple-quotes to escape variable + substitutions so the scripts get the 2to3 treatment when build + on Python 3. The templates cannot use triple-quotes naturally. + """ + raw_bytes = resource_string('setuptools', template_name) + template_str = raw_bytes.decode('utf-8') + clean_template = template_str.replace('"""', '') + return clean_template + + if is_script: + template_name = 'script template.py' + if dev_path: + template_name = template_name.replace('.py', ' (dev).py') + script_text = (get_script_header(script_text) + + get_template(template_name) % locals()) self.write_script(script_name, _to_ascii(script_text), 'b') def write_script(self, script_name, contents, mode="t", blockers=()): @@ -1801,7 +1809,10 @@ def get_script_args(dist, executable=sys_executable, wininst=False): ext, launcher = '-script.py', 'cli.exe' old = ['.py','.pyc','.pyo'] new_header = re.sub('(?i)pythonw.exe','python.exe',header) - + if is_64bit(): + launcher = launcher.replace(".", "-64.") + else: + launcher = launcher.replace(".", "-32.") if os.path.exists(new_header[2:-1]) or sys.platform!='win32': hdr = new_header else: diff --git a/setuptools/command/install_egg_info.py b/setuptools/command/install_egg_info.py index dd95552e..f44b34b5 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -89,6 +89,8 @@ class install_egg_info(Command): if not self.dry_run: f = open(filename,'wt') for pkg in nsp: + # ensure pkg is not a unicode string under Python 2.7 + pkg = str(pkg) pth = tuple(pkg.split('.')) trailer = '\n' if '.' in pkg: diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 3442fe4b..c49839cd 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -199,15 +199,25 @@ class sdist(_sdist): build_scripts = self.get_finalized_command('build_scripts') self.filelist.extend(build_scripts.get_source_files()) - def read_template(self): + def __read_template_hack(self): + # This grody hack closes the template file (MANIFEST.in) if an + # exception occurs during read_template. + # Doing so prevents an error when easy_install attempts to delete the + # file. try: _sdist.read_template(self) except: - # grody hack to close the template file (MANIFEST.in) - # this prevents easy_install's attempt at deleting the file from - # dying and thus masking the real error sys.exc_info()[2].tb_next.tb_frame.f_locals['template'].close() raise + # Beginning with Python 2.7.2, 3.1.4, and 3.2.1, this leaky file handle + # has been fixed, so only override the method if we're using an earlier + # Python. + if ( + sys.version_info < (2,7,2) + or (3,0) <= sys.version_info < (3,1,4) + or (3,2) <= sys.version_info < (3,2,1) + ): + read_template = __read_template_hack def check_readme(self): alts = ("README", "README.txt") diff --git a/setuptools/command/upload.py b/setuptools/command/upload.py index 1f49745e..4bd6021d 100755 --- a/setuptools/command/upload.py +++ b/setuptools/command/upload.py @@ -181,3 +181,4 @@ class upload(Command): log.ERROR) if self.show_response: print '-'*75, r.read(), '-'*75 + |
