From b4aecb449c912f0b405c687c763b9976c4cd884d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 25 Jul 2011 17:51:23 -0400 Subject: Fix issue where easy_install fails on Python 3 on windows installer. Fixes #212 --HG-- branch : distribute extra : rebase_source : 1920a8d261fa7918d9d3813a104cf2ed11878c7c --- setuptools/command/easy_install.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 58e7ab39..c1bae1c0 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1425,7 +1425,16 @@ def extract_wininst_cfg(dist_filename): f.seek(prepended-(12+cfglen)) cfg = ConfigParser.RawConfigParser({'version':'','target_version':''}) try: - cfg.readfp(StringIO.StringIO(f.read(cfglen).split(chr(0),1)[0])) + part = f.read(cfglen) + # part is in bytes, but we need to read up to the first null + # byte. + null_byte = bytes([0]) if sys.version_info >= (2,6) else chr(0) + config, = part.split(null_byte, 1) + # Now the config is in bytes, but on Python 3, it must be + # unicode for the RawConfigParser, so decode it. Is this the + # right encoding? + config = config.decode('ascii') + cfg.readfp(StringIO.StringIO(config)) except ConfigParser.Error: return None if not cfg.has_section('metadata') or not cfg.has_section('Setup'): -- cgit v1.2.1 From 9b09f6d159a7d5f4ffeaf9de4710ee869258fed7 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 1 Aug 2011 04:38:03 -0400 Subject: Corrected ValueError introduced in the last commit due to incorrect use of arg unpacking --HG-- branch : distribute extra : rebase_source : 0ebd905145e32bf072c00bc663dde8716ad4b88a --- setuptools/command/easy_install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index c1bae1c0..f44e8d4a 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1429,7 +1429,7 @@ def extract_wininst_cfg(dist_filename): # part is in bytes, but we need to read up to the first null # byte. null_byte = bytes([0]) if sys.version_info >= (2,6) else chr(0) - config, = part.split(null_byte, 1) + config = part.split(null_byte, 1)[0] # Now the config is in bytes, but on Python 3, it must be # unicode for the RawConfigParser, so decode it. Is this the # right encoding? -- cgit v1.2.1 From 2e6300e37739b614e8b4286a9c6f534305c1c005 Mon Sep 17 00:00:00 2001 From: Tarek Ziade Date: Sat, 20 Aug 2011 11:52:00 +0200 Subject: don't use ternary operator - fixes #225 --HG-- branch : distribute extra : rebase_source : ecff177a6be463bfc55c40deec0a3f1e2804e895 --- setuptools/command/easy_install.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index f44e8d4a..263b429c 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1428,7 +1428,10 @@ def extract_wininst_cfg(dist_filename): part = f.read(cfglen) # part is in bytes, but we need to read up to the first null # byte. - null_byte = bytes([0]) if sys.version_info >= (2,6) else chr(0) + if sys.version_info >= (2,6): + null_byte = bytes([0]) + else: + chr(0) config = part.split(null_byte, 1)[0] # Now the config is in bytes, but on Python 3, it must be # unicode for the RawConfigParser, so decode it. Is this the -- cgit v1.2.1 From 05564db286ce0b50ea5296adea3e462793dfcbe1 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 20 Aug 2011 07:51:48 -0600 Subject: Fix NameError on Python 2.4, 2.5; reference #225 --HG-- branch : distribute extra : rebase_source : b2c739a08485c49b0735f5f7544f354b46ad1d12 --- setuptools/command/easy_install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 263b429c..853753c1 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1431,7 +1431,7 @@ def extract_wininst_cfg(dist_filename): if sys.version_info >= (2,6): null_byte = bytes([0]) else: - chr(0) + null_byte = chr(0) config = part.split(null_byte, 1)[0] # Now the config is in bytes, but on Python 3, it must be # unicode for the RawConfigParser, so decode it. Is this the -- cgit v1.2.1 From b568b2ffb5d4e5c767452fce2353adec70d93a00 Mon Sep 17 00:00:00 2001 From: Erik Bray Date: Tue, 30 Aug 2011 12:34:37 -0400 Subject: First stab at a fix. The hack that allows it to work is that it allows the easy_install command to take a '-' argument which simply means 'don't run', so that arguments can be passed to the easy_install command from the comannd line without running it. --HG-- branch : distribute extra : rebase_source : 6eff3586cbcf36e846b3419218979d03079d1bcf --- setuptools/command/easy_install.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 853753c1..3f1b4228 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -267,7 +267,8 @@ class easy_install(Command): ) else: self.all_site_dirs.append(normalize_path(d)) - if not self.editable: self.check_site_dir() + if not self.editable and self.args != ['-']: + self.check_site_dir() self.index_url = self.index_url or "http://pypi.python.org/simple" self.shadow_path = self.all_site_dirs[:] for path_item in self.install_dir, normalize_path(self.script_dir): @@ -338,6 +339,11 @@ class easy_install(Command): 'install_scripts', 'install_data',]) def run(self): + if self.args == ['-']: + # A single dash as an argument means 'do nothing' and is just a way + # to pass arguments to the easy_install command without running it + return + if self.verbose != self.distribution.verbose: log.set_verbosity(self.verbose) try: @@ -1079,6 +1085,20 @@ See the setuptools documentation for the "develop" command for more info. ) try: args.append(dist_dir) + ei_opts = self.distribution.get_option_dict('easy_install').copy() + keep = ( + 'find_links', 'site_dirs', 'index_url', 'optimize', + 'site_dirs', 'allow_hosts' + ) + for key in ei_opts.keys(): + if key not in keep: + del ei_opts[key] + if ei_opts: + args.append('easy_install') + for key, val in ei_opts.iteritems(): + args.append('--%s=%s' % (key.replace('_', '-'), val[1])) + args.append('-') + self.run_setup(setup_script, setup_base, args) all_eggs = Environment([dist_dir]) eggs = [] -- cgit v1.2.1 From dff9e6b6bc0bd04180d00df52eb74340fa3df580 Mon Sep 17 00:00:00 2001 From: guyroz Date: Sat, 17 Sep 2011 16:27:04 +0300 Subject: Issue #238: using 65bit wrappers on Python64bit on windows --HG-- branch : distribute extra : rebase_source : c0f80f1633017229ec77f4cc1d7c56e86aba3a84 --- setuptools/command/easy_install.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 853753c1..4700fe0e 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) @@ -1781,7 +1785,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: -- cgit v1.2.1 From 4f5c1303ca73fdb1860bf00ee9a37a2c1b6fe294 Mon Sep 17 00:00:00 2001 From: guyroz Date: Tue, 20 Sep 2011 16:40:58 +0300 Subject: Issue #244 raises ValueError in upload and register commands if using a section without a repository value --HG-- branch : distribute extra : rebase_source : e57437a8ac03832ed8170c902996423a27235856 --- setuptools/command/__init__.py | 5 --- setuptools/command/register.py | 60 ++++++++++++++++++++++++++++++++ setuptools/command/upload.py | 78 ++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 136 insertions(+), 7 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/__init__.py b/setuptools/command/__init__.py index 152406b3..a601e2d3 100644 --- a/setuptools/command/__init__.py +++ b/setuptools/command/__init__.py @@ -8,13 +8,8 @@ __all__ = [ from setuptools.command import install_scripts import sys -if sys.version>='2.5': - # In Python 2.5 and above, distutils includes its own upload command - __all__.remove('upload') - 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/register.py b/setuptools/command/register.py index 3b2e0859..874401a5 100755 --- a/setuptools/command/register.py +++ b/setuptools/command/register.py @@ -1,4 +1,6 @@ from distutils.command.register import register as _register +from ConfigParser import ConfigParser +import os class register(_register): __doc__ = _register.__doc__ @@ -6,5 +8,63 @@ class register(_register): def run(self): # Make sure that we are using valid current name/version info self.run_command('egg_info') + self._section_name = self.repository _register.run(self) + def _read_pypirc(self): + """Reads the .pypirc file.""" + rc = self._get_rc_file() + if os.path.exists(rc): + repository = self.repository + config = ConfigParser() + config.read(rc) + sections = config.sections() + if 'distutils' in sections: + # let's get the list of servers + index_servers = config.get('distutils', 'index-servers') + _servers = [server.strip() for server in + index_servers.split('\n') + if server.strip() != ''] + if _servers == []: + # nothing set, let's try to get the default pypi + if 'pypi' in sections: + _servers = ['pypi'] + else: + # the file is not properly defined, returning + # an empty dict + return {} + for server in _servers: + current = {'server': server} + current['username'] = config.get(server, 'username') + + # optional params + for key, default in (('repository', + None), + ('realm', self.DEFAULT_REALM), + ('password', None)): + if config.has_option(server, key): + current[key] = config.get(server, key) + else: + current[key] = default + if (current['server'] == repository or + current['repository'] == repository): + return current + elif 'server-login' in sections: + # old format + server = 'server-login' + if config.has_option(server, 'repository'): + repository = config.get(server, 'repository') + else: + repository = None + return {'username': config.get(server, 'username'), + 'password': config.get(server, 'password'), + 'repository': repository, + 'server': server, + 'realm': self.DEFAULT_REALM} + + return {} + + def _set_config(self): + _register._set_config(self) + if self.repository is None: + raise ValueError('%s is missing a repository value in .pypirc' % self._section_name) diff --git a/setuptools/command/upload.py b/setuptools/command/upload.py index 1f49745e..042fcbb5 100755 --- a/setuptools/command/upload.py +++ b/setuptools/command/upload.py @@ -2,6 +2,7 @@ Implements the Distutils 'upload' subcommand (upload package to PyPI).""" + from distutils.errors import * from distutils.core import Command from distutils.spawn import spawn @@ -11,6 +12,7 @@ try: except ImportError: from md5 import md5 import os +import sys import socket import platform import ConfigParser @@ -19,7 +21,7 @@ import base64 import urlparse import cStringIO as StringIO -class upload(Command): +class _upload(Command): description = "upload binary package to PyPI" @@ -65,7 +67,7 @@ class upload(Command): if not self.password: self.password = config.get('server-login', 'password') if not self.repository: - self.repository = self.DEFAULT_REPOSITORY + raise ValueError('%s is missing a repository value in .pypirc' % self._section_name) def run(self): if not self.distribution.dist_files: @@ -181,3 +183,75 @@ class upload(Command): log.ERROR) if self.show_response: print '-'*75, r.read(), '-'*75 + +if sys.version >= "2.5": + from distutils.command.upload import upload as distutils_upload + class upload(distutils_upload): + + def run(self): + self._section_name = self.repository + distutils_upload.run(self) + + def _read_pypirc(self): + """Reads the .pypirc file.""" + self._section_name = self.repository + rc = self._get_rc_file() + if os.path.exists(rc): + repository = self.repository + config = ConfigParser.ConfigParser() + config.read(rc) + sections = config.sections() + if 'distutils' in sections: + # let's get the list of servers + index_servers = config.get('distutils', 'index-servers') + _servers = [server.strip() for server in + index_servers.split('\n') + if server.strip() != ''] + if _servers == []: + # nothing set, let's try to get the default pypi + if 'pypi' in sections: + _servers = ['pypi'] + else: + # the file is not properly defined, returning + # an empty dict + return {} + for server in _servers: + current = {'server': server} + current['username'] = config.get(server, 'username') + + # optional params + for key, default in (('repository', + None), + ('realm', self.DEFAULT_REALM), + ('password', None)): + if config.has_option(server, key): + current[key] = config.get(server, key) + else: + current[key] = default + if (current['server'] == repository or + current['repository'] == repository): + return current + elif 'server-login' in sections: + # old format + server = 'server-login' + if config.has_option(server, 'repository'): + repository = config.get(server, 'repository') + else: + repository = None + return {'username': config.get(server, 'username'), + 'password': config.get(server, 'password'), + 'repository': repository, + 'server': server, + 'realm': self.DEFAULT_REALM} + + return {} + + def finalize_options(self): + distutils_upload.finalize_options(self) + if not self.repository: + raise ValueError('%s is missing a repository value in .pypirc' % self._section_name) + + +else: + upload = _upload + -- cgit v1.2.1 From d36c067b3247bf7dc3102051b088fe744ac74ae0 Mon Sep 17 00:00:00 2001 From: guyroz Date: Thu, 22 Sep 2011 20:50:45 +0300 Subject: Issue #246 --HG-- branch : distribute extra : rebase_source : e14172505ff8938f00f51de4f29a8fb2834ac933 --- setuptools/command/upload.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'setuptools/command') diff --git a/setuptools/command/upload.py b/setuptools/command/upload.py index 042fcbb5..1b708943 100755 --- a/setuptools/command/upload.py +++ b/setuptools/command/upload.py @@ -228,8 +228,10 @@ if sys.version >= "2.5": current[key] = config.get(server, key) else: current[key] = default + # Issue #246, handling url ambiguity if (current['server'] == repository or - current['repository'] == repository): + current['repository'] == repository or + (current['repository'] == "http://www.python.org/pypi" and repository == self.DEFAULT_REPOSITORY)): return current elif 'server-login' in sections: # old format -- cgit v1.2.1 From 694a9231f495a82cf62340f9b98eb4fd7272ecf3 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 4 Oct 2011 11:01:49 -0400 Subject: Added options to exclude 2to3 fixers. Fixes #249 --HG-- branch : distribute extra : rebase_source : 2033bcdd4c2e78e0e03796f1f9cf6d6e9a59fc21 --- setuptools/command/build_py.py | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'setuptools/command') 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): -- cgit v1.2.1 From 257f23372a797ede9e14ae3e62c8319896943857 Mon Sep 17 00:00:00 2001 From: "Guy Rozendorn (guyr@infinidat.com)" Date: Fri, 7 Oct 2011 18:55:31 +0200 Subject: Revert 8d1cb51a01b6 because of issue #250 --HG-- branch : distribute extra : rebase_source : 842a0d796e6e3cd5ecf312dd5c3ff2bb35d601a5 --- setuptools/command/upload.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/upload.py b/setuptools/command/upload.py index 1b708943..f2e0b2e1 100755 --- a/setuptools/command/upload.py +++ b/setuptools/command/upload.py @@ -228,10 +228,7 @@ if sys.version >= "2.5": current[key] = config.get(server, key) else: current[key] = default - # Issue #246, handling url ambiguity - if (current['server'] == repository or - current['repository'] == repository or - (current['repository'] == "http://www.python.org/pypi" and repository == self.DEFAULT_REPOSITORY)): + if (current['server'] == repository: return current elif 'server-login' in sections: # old format -- cgit v1.2.1 From d5df4531433b2031186ed2a8b335892b3600912b Mon Sep 17 00:00:00 2001 From: "Guy Rozendorn (guyr@infinidat.com)" Date: Fri, 7 Oct 2011 19:08:55 +0200 Subject: Reverting 1a1ab844f03e due to issue 250 --HG-- branch : distribute extra : rebase_source : 0dca5e604c96429f07c4d7786d3a0991c42c129d --- setuptools/command/__init__.py | 4 +++ setuptools/command/register.py | 60 --------------------------------- setuptools/command/upload.py | 76 ++---------------------------------------- 3 files changed, 6 insertions(+), 134 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/__init__.py b/setuptools/command/__init__.py index a601e2d3..b063fa19 100644 --- a/setuptools/command/__init__.py +++ b/setuptools/command/__init__.py @@ -8,6 +8,10 @@ __all__ = [ from setuptools.command import install_scripts import sys +if sys.version>='2.5': + # In Python 2.5 and above, distutils includes its own upload command + __all__.remove('upload') + from distutils.command.bdist import bdist if 'egg' not in bdist.format_commands: diff --git a/setuptools/command/register.py b/setuptools/command/register.py index 874401a5..3b2e0859 100755 --- a/setuptools/command/register.py +++ b/setuptools/command/register.py @@ -1,6 +1,4 @@ from distutils.command.register import register as _register -from ConfigParser import ConfigParser -import os class register(_register): __doc__ = _register.__doc__ @@ -8,63 +6,5 @@ class register(_register): def run(self): # Make sure that we are using valid current name/version info self.run_command('egg_info') - self._section_name = self.repository _register.run(self) - def _read_pypirc(self): - """Reads the .pypirc file.""" - rc = self._get_rc_file() - if os.path.exists(rc): - repository = self.repository - config = ConfigParser() - config.read(rc) - sections = config.sections() - if 'distutils' in sections: - # let's get the list of servers - index_servers = config.get('distutils', 'index-servers') - _servers = [server.strip() for server in - index_servers.split('\n') - if server.strip() != ''] - if _servers == []: - # nothing set, let's try to get the default pypi - if 'pypi' in sections: - _servers = ['pypi'] - else: - # the file is not properly defined, returning - # an empty dict - return {} - for server in _servers: - current = {'server': server} - current['username'] = config.get(server, 'username') - - # optional params - for key, default in (('repository', - None), - ('realm', self.DEFAULT_REALM), - ('password', None)): - if config.has_option(server, key): - current[key] = config.get(server, key) - else: - current[key] = default - if (current['server'] == repository or - current['repository'] == repository): - return current - elif 'server-login' in sections: - # old format - server = 'server-login' - if config.has_option(server, 'repository'): - repository = config.get(server, 'repository') - else: - repository = None - return {'username': config.get(server, 'username'), - 'password': config.get(server, 'password'), - 'repository': repository, - 'server': server, - 'realm': self.DEFAULT_REALM} - - return {} - - def _set_config(self): - _register._set_config(self) - if self.repository is None: - raise ValueError('%s is missing a repository value in .pypirc' % self._section_name) diff --git a/setuptools/command/upload.py b/setuptools/command/upload.py index f2e0b2e1..4bd6021d 100755 --- a/setuptools/command/upload.py +++ b/setuptools/command/upload.py @@ -2,7 +2,6 @@ Implements the Distutils 'upload' subcommand (upload package to PyPI).""" - from distutils.errors import * from distutils.core import Command from distutils.spawn import spawn @@ -12,7 +11,6 @@ try: except ImportError: from md5 import md5 import os -import sys import socket import platform import ConfigParser @@ -21,7 +19,7 @@ import base64 import urlparse import cStringIO as StringIO -class _upload(Command): +class upload(Command): description = "upload binary package to PyPI" @@ -67,7 +65,7 @@ class _upload(Command): if not self.password: self.password = config.get('server-login', 'password') if not self.repository: - raise ValueError('%s is missing a repository value in .pypirc' % self._section_name) + self.repository = self.DEFAULT_REPOSITORY def run(self): if not self.distribution.dist_files: @@ -184,73 +182,3 @@ class _upload(Command): if self.show_response: print '-'*75, r.read(), '-'*75 -if sys.version >= "2.5": - from distutils.command.upload import upload as distutils_upload - class upload(distutils_upload): - - def run(self): - self._section_name = self.repository - distutils_upload.run(self) - - def _read_pypirc(self): - """Reads the .pypirc file.""" - self._section_name = self.repository - rc = self._get_rc_file() - if os.path.exists(rc): - repository = self.repository - config = ConfigParser.ConfigParser() - config.read(rc) - sections = config.sections() - if 'distutils' in sections: - # let's get the list of servers - index_servers = config.get('distutils', 'index-servers') - _servers = [server.strip() for server in - index_servers.split('\n') - if server.strip() != ''] - if _servers == []: - # nothing set, let's try to get the default pypi - if 'pypi' in sections: - _servers = ['pypi'] - else: - # the file is not properly defined, returning - # an empty dict - return {} - for server in _servers: - current = {'server': server} - current['username'] = config.get(server, 'username') - - # optional params - for key, default in (('repository', - None), - ('realm', self.DEFAULT_REALM), - ('password', None)): - if config.has_option(server, key): - current[key] = config.get(server, key) - else: - current[key] = default - if (current['server'] == repository: - return current - elif 'server-login' in sections: - # old format - server = 'server-login' - if config.has_option(server, 'repository'): - repository = config.get(server, 'repository') - else: - repository = None - return {'username': config.get(server, 'username'), - 'password': config.get(server, 'password'), - 'repository': repository, - 'server': server, - 'realm': self.DEFAULT_REALM} - - return {} - - def finalize_options(self): - distutils_upload.finalize_options(self) - if not self.repository: - raise ValueError('%s is missing a repository value in .pypirc' % self._section_name) - - -else: - upload = _upload - -- cgit v1.2.1 From 5e53787185059a78874e2f730c431ec611b0b8e7 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 20 Jan 2012 14:11:03 -0500 Subject: Remove grody hack for later versions of Python where it is no longer necessary. Fixes #269. --HG-- branch : distribute extra : rebase_source : c4f18c8760303a2228baf5b88ec1f59a865999a5 --- setuptools/command/sdist.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'setuptools/command') 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") -- cgit v1.2.1 From d7907a5c969ad05970e458cc7b69b522dda46164 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 6 Feb 2012 22:34:53 -0500 Subject: Fix #272 - TypeError when namespace_package is unicode --HG-- branch : distribute extra : rebase_source : 5bb6bc394dbe2834977b853af85241ae0a472de6 --- setuptools/command/install_egg_info.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'setuptools/command') 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: -- cgit v1.2.1 From f4a592c1240bbc3f0b1d0d08e261874857954225 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 8 Feb 2012 13:33:09 -0500 Subject: Now load legacy scripts wrappers from templates in the package, which get converted to Python 3 syntax when built on Python 3. Fixes #273. --HG-- branch : distribute extra : rebase_source : 900842f8a9e70d347296f7b076c6113ead6f7318 --- setuptools/command/easy_install.py | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 4700fe0e..a51d88f5 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -731,22 +731,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=()): -- cgit v1.2.1 From f6cb3d29d919ff6b9313b8a3281c66cfb368c29b Mon Sep 17 00:00:00 2001 From: Erik Bray Date: Mon, 13 Feb 2012 16:22:33 -0500 Subject: This allows the sdist command to ensure that any files listed in package_data are included in the dist, regardless of whether it's under version control, as is the case with distutil's sdist. Setting include_package_data=True disables this functionality. --HG-- branch : distribute extra : rebase_source : 2cae1675c638dc12fd556368074c6b5c691c6f58 --- setuptools/command/sdist.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'setuptools/command') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index c49839cd..484f8276 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -186,6 +186,14 @@ class sdist(_sdist): if self.distribution.has_pure_modules(): build_py = self.get_finalized_command('build_py') self.filelist.extend(build_py.get_source_files()) + # This functionality is incompatible with include_package_data, and + # will in fact create an infinite recursion if include_package_data + # is True. Use of include_package_data will imply that + # distutils-style automatic handling of package_data is disabled + if not self.distribution.include_package_data: + for _, src_dir, _, filenames in build_py.data_files: + self.filelist.extend([os.path.join(src_dir, filename) + for filename in filenames]) if self.distribution.has_ext_modules(): build_ext = self.get_finalized_command('build_ext') -- cgit v1.2.1 From be66b979ea6371d92a555c5fea28faa3e2b719bc Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 29 Mar 2012 23:36:28 -0400 Subject: Another attempt at a fix that uses setopt instead of hacking easy_install --HG-- branch : distribute extra : rebase_source : 907488d2ba609dbca39cd14c021c5cfb4f353a38 --- setuptools/command/easy_install.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index d200dac1..ef82808b 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -271,8 +271,7 @@ class easy_install(Command): ) else: self.all_site_dirs.append(normalize_path(d)) - if not self.editable and self.args != ['-']: - self.check_site_dir() + if not self.editable: self.check_site_dir() self.index_url = self.index_url or "http://pypi.python.org/simple" self.shadow_path = self.all_site_dirs[:] for path_item in self.install_dir, normalize_path(self.script_dir): @@ -343,11 +342,6 @@ class easy_install(Command): 'install_scripts', 'install_data',]) def run(self): - if self.args == ['-']: - # A single dash as an argument means 'do nothing' and is just a way - # to pass arguments to the easy_install command without running it - return - if self.verbose != self.distribution.verbose: log.set_verbosity(self.verbose) try: @@ -1102,10 +1096,14 @@ See the setuptools documentation for the "develop" command for more info. if key not in keep: del ei_opts[key] if ei_opts: - args.append('easy_install') for key, val in ei_opts.iteritems(): - args.append('--%s=%s' % (key.replace('_', '-'), val[1])) - args.append('-') + args.append('setopt') + args.append('--command') + args.append('easy_install') + args.append('--option') + args.append(key.replace('_', '-')) + args.append('--set-value') + args.append(val[1]) self.run_setup(setup_script, setup_base, args) all_eggs = Environment([dist_dir]) -- cgit v1.2.1 From 23622dbdb01a2427ba8c40ffb9820793a6d21817 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 29 Mar 2012 23:57:57 -0400 Subject: Put the setopt directives before bdist_egg --HG-- branch : distribute extra : rebase_source : 23f656d6eb2ade3aa51f285a8bc288eab432819a --- setuptools/command/easy_install.py | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index ef82808b..4ff57648 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1081,29 +1081,27 @@ See the setuptools documentation for the "develop" command for more info. raise DistutilsError("Setup script exited with %s" % (v.args[0],)) def build_and_install(self, setup_script, setup_base): - args = ['bdist_egg', '--dist-dir'] + args = [] + + # first pass along any install directives using setopt + ei_opts = self.distribution.get_option_dict('easy_install').copy() + install_directives = ( + 'find_links', 'site_dirs', 'index_url', 'optimize', + 'site_dirs', 'allow_hosts' + ) + for key, val in ei_opts.iteritems(): + if key not in install_directives: continue + args.extend(['setopt', '--command', 'easy_install', + '--option', key.replace('_', '-'), + '--set-value', val[1]]) + + args.extend(['bdist_egg', '--dist-dir']) + dist_dir = tempfile.mkdtemp( prefix='egg-dist-tmp-', dir=os.path.dirname(setup_script) ) try: args.append(dist_dir) - ei_opts = self.distribution.get_option_dict('easy_install').copy() - keep = ( - 'find_links', 'site_dirs', 'index_url', 'optimize', - 'site_dirs', 'allow_hosts' - ) - for key in ei_opts.keys(): - if key not in keep: - del ei_opts[key] - if ei_opts: - for key, val in ei_opts.iteritems(): - args.append('setopt') - args.append('--command') - args.append('easy_install') - args.append('--option') - args.append(key.replace('_', '-')) - args.append('--set-value') - args.append(val[1]) self.run_setup(setup_script, setup_base, args) all_eggs = Environment([dist_dir]) -- cgit v1.2.1 From d388348dbca2972ed9cf6b2a9eff3b264f0e58b7 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 30 Mar 2012 09:08:23 -0400 Subject: Yet another approach - invoking setopt directly prior to invoking a new setup process. This approach works (compared to the previous setopt approach which did not). --HG-- branch : distribute extra : rebase_source : 4d28ae98e67d8bc1f2f98aee93d7a69000f10239 --- setuptools/command/easy_install.py | 42 ++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 15 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 4ff57648..dfd9f7ff 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -21,6 +21,7 @@ from distutils.sysconfig import get_python_lib, get_config_vars from distutils.errors import DistutilsArgError, DistutilsOptionError, \ DistutilsError, DistutilsPlatformError from distutils.command.install import INSTALL_SCHEMES, SCHEME_KEYS +from setuptools.command import setopt from setuptools.archive_util import unpack_archive from setuptools.package_index import PackageIndex from setuptools.package_index import URL_SCHEME @@ -1081,26 +1082,13 @@ See the setuptools documentation for the "develop" command for more info. raise DistutilsError("Setup script exited with %s" % (v.args[0],)) def build_and_install(self, setup_script, setup_base): - args = [] - - # first pass along any install directives using setopt - ei_opts = self.distribution.get_option_dict('easy_install').copy() - install_directives = ( - 'find_links', 'site_dirs', 'index_url', 'optimize', - 'site_dirs', 'allow_hosts' - ) - for key, val in ei_opts.iteritems(): - if key not in install_directives: continue - args.extend(['setopt', '--command', 'easy_install', - '--option', key.replace('_', '-'), - '--set-value', val[1]]) - - args.extend(['bdist_egg', '--dist-dir']) + args = ['bdist_egg', '--dist-dir'] dist_dir = tempfile.mkdtemp( prefix='egg-dist-tmp-', dir=os.path.dirname(setup_script) ) try: + self._set_fetcher_options(os.path.dirname(setup_script)) args.append(dist_dir) self.run_setup(setup_script, setup_base, args) @@ -1117,6 +1105,30 @@ See the setuptools documentation for the "develop" command for more info. rmtree(dist_dir) log.set_verbosity(self.verbose) # restore our log verbosity + def _set_fetcher_options(self, base): + """ + When easy_install is about to run bdist_egg on a source dist, that + source dist might have 'setup_requires' directives, requiring + additional fetching. Ensure the fetcher options given to easy_install + are available to that command as well. + """ + # find the fetch options from easy_install and write them out + # to the setup.cfg file. + ei_opts = self.distribution.get_option_dict('easy_install').copy() + fetch_directives = ( + 'find_links', 'site_dirs', 'index_url', 'optimize', + 'site_dirs', 'allow_hosts', + ) + fetch_options = {} + for key, val in ei_opts.iteritems(): + if key not in fetch_directives: continue + fetch_options[key.replace('_', '-')] = val[1] + # create a settings dictionary suitable for `edit_config` + settings = dict(easy_install=fetch_options) + cfg_filename = os.path.join(base, 'setup.cfg') + setopt.edit_config(cfg_filename, settings) + + def update_pth(self,dist): if self.pth_file is None: return -- cgit v1.2.1 From 8b6d10f3443e8f9b8d662097d496392a4e7ed599 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 16 Apr 2012 15:30:31 -0400 Subject: Fix typo in protocol_version. Thanks aclark! --HG-- branch : distribute extra : rebase_source : ab90cfb5cae3189b8d0c71c43992bc0273a7587a --- setuptools/command/upload.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command') diff --git a/setuptools/command/upload.py b/setuptools/command/upload.py index 4bd6021d..9f9366b5 100755 --- a/setuptools/command/upload.py +++ b/setuptools/command/upload.py @@ -92,7 +92,7 @@ class upload(Command): comment = "built on %s" % platform.platform(terse=1) data = { ':action':'file_upload', - 'protcol_version':'1', + 'protocol_version':'1', 'name':self.distribution.get_name(), 'version':self.distribution.get_version(), 'content':(basename,content), -- cgit v1.2.1 From 76f2440a4dad4038f4d3aadcd64e33e9ef22ad6e Mon Sep 17 00:00:00 2001 From: Alex Clark Date: Sun, 22 Apr 2012 21:41:29 -0400 Subject: README.rst is now a standard --HG-- branch : distribute extra : rebase_source : 261a30d0a7ec63b1ff4918d7906476a19945b288 --- setuptools/command/sdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index c49839cd..1f88e93b 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -155,7 +155,7 @@ class sdist(_sdist): dist_files.append(data) def add_defaults(self): - standards = [('README', 'README.txt'), + standards = [('README', 'README.rst', 'README.txt'), self.distribution.script_name] for fn in standards: if isinstance(fn, tuple): -- cgit v1.2.1 From 8dde28ee529c74d578e8142dfbb0a537a8bf0414 Mon Sep 17 00:00:00 2001 From: Justin Azoff Date: Sat, 12 May 2012 19:01:44 -0400 Subject: When writing out scripts, respect the users umask --HG-- branch : distribute extra : rebase_source : d4fc14bcdcd3e1a45da8bdcdef490537863ece35 --- setuptools/command/easy_install.py | 10 ++++++++-- setuptools/command/install_scripts.py | 5 +++-- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index dfd9f7ff..49a2c41e 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -10,7 +10,7 @@ file, or visit the `EasyInstall home page`__. __ http://packages.python.org/distribute/easy_install.html """ -import sys, os.path, zipimport, shutil, tempfile, zipfile, re, stat, random +import sys, os, os.path, zipimport, shutil, tempfile, zipfile, re, stat, random from glob import glob from setuptools import Command, _dont_write_bytecode from setuptools.sandbox import run_setup @@ -762,12 +762,13 @@ Please make the appropriate changes for your system and try again. target = os.path.join(self.script_dir, script_name) self.add_output(target) + mask = current_umask() if not self.dry_run: ensure_directory(target) f = open(target,"w"+mode) f.write(contents) f.close() - chmod(target,0755) + chmod(target, 0777-mask) @@ -1870,6 +1871,11 @@ def rmtree(path, ignore_errors=False, onerror=auto_chmod): except os.error: onerror(os.rmdir, path, sys.exc_info()) +def current_umask(): + tmp = os.umask(022) + os.umask(tmp) + return tmp + def bootstrap(): # This function is called when setuptools*.egg is run using /bin/sh import setuptools; argv0 = os.path.dirname(setuptools.__path__[0]) diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index 6ce1b993..82456035 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -39,15 +39,16 @@ class install_scripts(_install_scripts): def write_script(self, script_name, contents, mode="t", *ignored): """Write an executable file to the scripts directory""" - from setuptools.command.easy_install import chmod + from setuptools.command.easy_install import chmod, current_umask log.info("Installing %s script to %s", script_name, self.install_dir) target = os.path.join(self.install_dir, script_name) self.outfiles.append(target) + mask = current_umask() if not self.dry_run: ensure_directory(target) f = open(target,"w"+mode) f.write(contents) f.close() - chmod(target,0755) + chmod(target, 0777-mask) -- cgit v1.2.1 From 311fb781f87f8885d9a94343b4b7e9731bc0c9e7 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Tue, 26 Jun 2012 15:15:27 -0700 Subject: Add tests and fix for marshal.load of pyc files on Python 3.3 Fixes https://bitbucket.org/tarek/distribute/issue/283/bdist_egg-issues-with-python-330ax --HG-- branch : distribute extra : rebase_source : ec6f2611d3f8a54b7e11cfadf9d03fdcdef39639 --- setuptools/command/bdist_egg.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'setuptools/command') diff --git a/setuptools/command/bdist_egg.py b/setuptools/command/bdist_egg.py index 68ca15c7..0ee9c55b 100644 --- a/setuptools/command/bdist_egg.py +++ b/setuptools/command/bdist_egg.py @@ -426,7 +426,11 @@ def scan_module(egg_dir, base, name, stubs): pkg = base[len(egg_dir)+1:].replace(os.sep,'.') module = pkg+(pkg and '.' or '')+os.path.splitext(name)[0] f = open(filename,'rb'); f.read(8) # skip magic & date - code = marshal.load(f); f.close() + try: + code = marshal.load(f); f.close() + except ValueError: + f.seek(0); f.read(12) # skip magic & date & file size; file size added in Python 3.3 + code = marshal.load(f); f.close() safe = True symbols = dict.fromkeys(iter_symbols(code)) for bad in ['__file__', '__path__']: -- cgit v1.2.1 From 12c0d7f3e916957294a095a8425554fe8413e42e Mon Sep 17 00:00:00 2001 From: Jim Fulton Date: Sat, 14 Jul 2012 14:25:06 -0400 Subject: Issue #283 bdist_egg issues with python 3.3.0aX --HG-- branch : distribute extra : rebase_source : 3173cb1ab5550635b8565767059701ab2649ac19 --- setuptools/command/bdist_egg.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'setuptools/command') diff --git a/setuptools/command/bdist_egg.py b/setuptools/command/bdist_egg.py index 68ca15c7..a9d98d3b 100644 --- a/setuptools/command/bdist_egg.py +++ b/setuptools/command/bdist_egg.py @@ -459,6 +459,8 @@ def iter_symbols(code): yield name def can_scan(): + if sys.version_info > (3, 3): + return False # Can't scan recent formats if not sys.platform.startswith('java') and sys.platform != 'cli': # CPython, PyPy, etc. return True -- cgit v1.2.1 From cbb03edb6cf43016eed584f42506458893e4be05 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 21 Jul 2012 17:04:33 -0400 Subject: Reorganized imports --HG-- branch : distribute extra : rebase_source : 6836f95f7e0668d6bd3e34f915d16de21d4f3731 --- setuptools/command/easy_install.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 49a2c41e..f2260236 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -10,7 +10,15 @@ file, or visit the `EasyInstall home page`__. __ http://packages.python.org/distribute/easy_install.html """ -import sys, os, os.path, zipimport, shutil, tempfile, zipfile, re, stat, random +import sys +import os +import zipimport +import shutil +import tempfile +import zipfile +import re +import stat +import random from glob import glob from setuptools import Command, _dont_write_bytecode from setuptools.sandbox import run_setup -- cgit v1.2.1 From 4084ebc22ff58d406b73fe25c069b5235f04c4d8 Mon Sep 17 00:00:00 2001 From: Arfrever Frehtes Taifersar Arahesis Date: Wed, 25 Jul 2012 05:11:56 +0200 Subject: Issue #283: Reenable scanning of *.pyc / *.pyo files on Python 3.3. Scanning of these files was fixed in commit 2479772eeea7. --HG-- branch : distribute extra : rebase_source : fcbb14f0e6efc2c42b691fa2a8920816903ede42 --- setuptools/command/bdist_egg.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/bdist_egg.py b/setuptools/command/bdist_egg.py index cf2d75e4..0ee9c55b 100644 --- a/setuptools/command/bdist_egg.py +++ b/setuptools/command/bdist_egg.py @@ -463,8 +463,6 @@ def iter_symbols(code): yield name def can_scan(): - if sys.version_info > (3, 3): - return False # Can't scan recent formats if not sys.platform.startswith('java') and sys.platform != 'cli': # CPython, PyPy, etc. return True -- cgit v1.2.1 From c8558d8d3b6c2cae273637ccec616489c2e7b439 Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Tue, 21 Aug 2012 17:29:47 +0200 Subject: Add failing test for #301. --HG-- branch : distribute extra : rebase_source : 2972e762cdab88e90c1c8b9b9a336afc641e996f --- setuptools/command/test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'setuptools/command') diff --git a/setuptools/command/test.py b/setuptools/command/test.py index b7aef969..59c10e84 100644 --- a/setuptools/command/test.py +++ b/setuptools/command/test.py @@ -141,9 +141,10 @@ class test(Command): import unittest loader_ep = EntryPoint.parse("x="+self.test_loader) loader_class = loader_ep.load(require=False) + cks = loader_class() unittest.main( None, None, [unittest.__file__]+self.test_args, - testLoader = loader_class() + testLoader = cks ) -- cgit v1.2.1 From 42afe54cf9e15ef655e7ed5fef9483682fcd5af2 Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Tue, 21 Aug 2012 20:52:16 +0200 Subject: Added fix for the develop command, #299. --HG-- branch : distribute extra : rebase_source : ef69472e5a9ce97d9102578898e81e516f06497a --- setuptools/command/develop.py | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 93b7773c..c8bef72e 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -84,11 +84,35 @@ class develop(easy_install): " installation directory", p, normalize_path(os.curdir)) def install_for_development(self): - # Ensure metadata is up-to-date - self.run_command('egg_info') - # Build extensions in-place - self.reinitialize_command('build_ext', inplace=1) - self.run_command('build_ext') + if getattr(self.distribution, 'use_2to3', False): + # If we run 2to3 we can not do this inplace: + + # Ensure metadata is up-to-date + self.reinitialize_command('build_py', inplace=0) + self.run_command('build_py') + bpy_cmd = self.get_finalized_command("build_py") + build_path = normalize_path(bpy_cmd.build_lib) + + # Build extensions + self.reinitialize_command('egg_info', egg_base=build_path) + self.run_command('egg_info') + + self.reinitialize_command('build_ext', inplace=0) + self.run_command('build_ext') + + # Fixup egg-link and easy-install.pth + ei_cmd = self.get_finalized_command("egg_info") + self.egg_path = build_path + self.dist.location = build_path + self.dist._provider = PathMetadata(build_path, ei_cmd.egg_info) # XXX + else: + # Without 2to3 inplace works fine: + self.run_command('egg_info') + + # Build extensions in-place + self.reinitialize_command('build_ext', inplace=1) + self.run_command('build_ext') + self.install_site_py() # ensure that target dir is site-safe if setuptools.bootstrap_install_from: self.easy_install(setuptools.bootstrap_install_from) -- cgit v1.2.1 From 9dc9fea4a5661e119f30f4cdec3ef99e46b5f919 Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Wed, 22 Aug 2012 12:32:11 +0200 Subject: Issue #306: Even if 2to3 is used, we build in-place under Python 2. --HG-- branch : distribute extra : rebase_source : db4a1a3059533ad0c894f12c31e3fe1c238f4292 --- setuptools/command/develop.py | 4 ++-- setuptools/command/test.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index c8bef72e..709e349c 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -3,7 +3,7 @@ from distutils.util import convert_path, subst_vars from pkg_resources import Distribution, PathMetadata, normalize_path from distutils import log from distutils.errors import DistutilsError, DistutilsOptionError -import os, setuptools, glob +import os, sys, setuptools, glob class develop(easy_install): """Set up package for development""" @@ -84,7 +84,7 @@ class develop(easy_install): " installation directory", p, normalize_path(os.curdir)) def install_for_development(self): - if getattr(self.distribution, 'use_2to3', False): + if sys.version_info >= (3,) and getattr(self.distribution, 'use_2to3', False): # If we run 2to3 we can not do this inplace: # Ensure metadata is up-to-date diff --git a/setuptools/command/test.py b/setuptools/command/test.py index 59c10e84..e5cb9bb5 100644 --- a/setuptools/command/test.py +++ b/setuptools/command/test.py @@ -81,7 +81,7 @@ class test(Command): def with_project_on_sys_path(self, func): - if getattr(self.distribution, 'use_2to3', False): + if sys.version_info >= (3,) and getattr(self.distribution, 'use_2to3', False): # If we run 2to3 we can not do this inplace: # Ensure metadata is up-to-date -- cgit v1.2.1 From a3b6b2bba70b44b62865e6474e5a007400d62884 Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Wed, 22 Aug 2012 14:14:07 +0200 Subject: Issue #307: Prints the full path when .svn/entries is broken. --HG-- branch : distribute extra : rebase_source : 1836125ab8204364c8fb197d7c20c296a25f89c0 --- setuptools/command/sdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 1f88e93b..edb3b7f3 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -97,7 +97,7 @@ def entries_finder(dirname, filename): for match in entries_pattern.finditer(data): yield joinpath(dirname,unescape(match.group(1))) else: - log.warn("unrecognized .svn/entries format in %s", dirname) + log.warn("unrecognized .svn/entries format in %s", os.path.abspath(dirname)) finders = [ -- cgit v1.2.1 From cafaa3bd07185df0c17a19edee8820494d34267c Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Wed, 22 Aug 2012 14:25:48 +0200 Subject: Merged the two lists of acceptable names of README.txt --HG-- branch : distribute extra : rebase_source : 604b23f6559c4688d1b43bc102601e0a0ed914a9 --- setuptools/command/sdist.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index edb3b7f3..16d3c37b 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -4,6 +4,8 @@ from distutils import log import os, re, sys, pkg_resources from glob import glob +READMES = ('README', 'README.rst', 'README.txt') + entities = [ ("<","<"), (">", ">"), (""", '"'), ("'", "'"), ("&", "&") @@ -155,7 +157,7 @@ class sdist(_sdist): dist_files.append(data) def add_defaults(self): - standards = [('README', 'README.rst', 'README.txt'), + standards = [READMES, self.distribution.script_name] for fn in standards: if isinstance(fn, tuple): @@ -220,13 +222,12 @@ class sdist(_sdist): read_template = __read_template_hack def check_readme(self): - alts = ("README", "README.txt") - for f in alts: + for f in READMES: if os.path.exists(f): return else: self.warn( - "standard file not found: should have one of " +', '.join(alts) + "standard file not found: should have one of " +', '.join(READMES) ) -- cgit v1.2.1 From ec0ed85656b96812402439fa23c877fd27b99de5 Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Wed, 22 Aug 2012 16:36:29 +0200 Subject: Issue #313: Support for sdist subcommands (Python 2.7) --HG-- branch : distribute extra : rebase_source : 5461cca20f4c91fec21b69128f76f6e6a0df205c --- setuptools/command/sdist.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'setuptools/command') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 16d3c37b..91c4fd1b 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -147,7 +147,17 @@ class sdist(_sdist): self.filelist = ei_cmd.filelist self.filelist.append(os.path.join(ei_cmd.egg_info,'SOURCES.txt')) self.check_readme() - self.check_metadata() + + # Run sub commands + for cmd_name in self.get_sub_commands(): + self.run_command(cmd_name) + + # Call check_metadata only if no 'check' command + # (distutils <= 2.6) + import distutils.command + if 'check' not in distutils.command.__all__: + self.check_metadata() + self.make_distribution() dist_files = getattr(self.distribution,'dist_files',[]) -- cgit v1.2.1 From 0d962727403be73b0b1eac234ed81b941dd7cae9 Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Wed, 22 Aug 2012 18:01:49 +0200 Subject: Issue #310: Non-ascii characters in a namespace __init__.py causes errors. --HG-- branch : distribute extra : rebase_source : 668e1c79a2bcc314bcf1f7213b317766bb8511ab --- setuptools/command/build_py.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py index d53960fe..505dd4f3 100644 --- a/setuptools/command/build_py.py +++ b/setuptools/command/build_py.py @@ -215,8 +215,8 @@ class build_py(_build_py, Mixin2to3): else: return init_py - f = open(init_py,'rU') - if 'declare_namespace' not in f.read(): + f = open(init_py,'rbU') + if 'declare_namespace'.encode() not in f.read(): from distutils import log log.warn( "WARNING: %s is a namespace package, but its __init__.py does\n" -- cgit v1.2.1 From 077a69aef0973333cafe4c7548dceb5418d1c36f Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Mon, 8 Oct 2012 13:29:03 +0200 Subject: Purge modules under test from sys.modules prior to running tests. Fixes #301. --HG-- branch : distribute extra : rebase_source : 87561670c15ec8315f47157cdc0c06328ce8c20f --- setuptools/command/test.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'setuptools/command') diff --git a/setuptools/command/test.py b/setuptools/command/test.py index e5cb9bb5..a02ac142 100644 --- a/setuptools/command/test.py +++ b/setuptools/command/test.py @@ -2,6 +2,7 @@ from setuptools import Command from distutils.errors import DistutilsOptionError import sys from pkg_resources import * +from pkg_resources import _namespace_packages from unittest import TestLoader, main class ScanningLoader(TestLoader): @@ -139,6 +140,22 @@ class test(Command): def run_tests(self): import unittest + + # Purge modules under test from sys.modules. The test loader will + # re-import them from the build location. Required when 2to3 is used + # with namespace packages. + if sys.version_info >= (3,) and getattr(self.distribution, 'use_2to3', False): + module = self.test_args[-1].split('.')[0] + if module in _namespace_packages: + del_modules = [] + if module in sys.modules: + del_modules.append(module) + module += '.' + for name in sys.modules: + if name.startswith(module): + del_modules.append(name) + map(sys.modules.__delitem__, del_modules) + loader_ep = EntryPoint.parse("x="+self.test_loader) loader_class = loader_ep.load(require=False) cks = loader_class() -- cgit v1.2.1 From 6851d4e38e1e4e5a2bbbf2556523fd19675cdbf7 Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Mon, 8 Oct 2012 19:48:19 +0200 Subject: Make sure the manifest never contains decomposed UTF-8. --HG-- branch : distribute extra : rebase_source : 0e0fb3beac56f66f12670ec69ebfd3996d12d912 --- setuptools/command/egg_info.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'setuptools/command') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 46cdf4e0..e932d46a 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -287,6 +287,19 @@ class FileList(FileList): +def compose(path): + # Apple's HFS Plus returns decomposed UTF-8. Since just about + # everyone else chokes on it, we must make sure to return fully + # composed UTF-8 only. + if sys.getfilesystemencoding().lower() == 'utf-8': + from unicodedata import normalize + if sys.version_info >= (3,): + path = normalize('NFC', path) + else: + path = normalize('NFC', path.decode('utf-8')).encode('utf-8') + return path + + class manifest_maker(sdist): template = "MANIFEST.in" @@ -311,6 +324,7 @@ class manifest_maker(sdist): self.prune_file_list() self.filelist.sort() self.filelist.remove_duplicates() + self.filelist.files = [compose(path) for path in self.filelist.files] self.write_manifest() def write_manifest (self): -- cgit v1.2.1 From d76ec4bfdf2fe9a2bced5ca2a3610831020453c6 Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Mon, 8 Oct 2012 19:52:32 +0200 Subject: Read and write manifest in UTF-8 under Python 3. Fixes #303. --HG-- branch : distribute extra : rebase_source : 609c654effd2711aa803f6a0e84013294026608f --- setuptools/command/sdist.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'setuptools/command') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index a176f635..d5259c2b 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -262,7 +262,34 @@ class sdist(_sdist): self.get_finalized_command('egg_info').save_version_info(dest) + def _manifest_is_not_generated(self): + # check for special comment used in 2.7.1 and higher + if not os.path.isfile(self.manifest): + return False + fp = open(self.manifest, 'rbU') + try: + first_line = fp.readline() + finally: + fp.close() + return first_line != '# file GENERATED by distutils, do NOT edit\n'.encode() + + def read_manifest(self): + """Read the manifest file (named by 'self.manifest') and use it to + fill in 'self.filelist', the list of files to include in the source + distribution. + """ + log.info("reading manifest file '%s'", self.manifest) + manifest = open(self.manifest, 'rbU') + for line in manifest: + if sys.version_info >= (3,): + line = line.decode('UTF-8') + # ignore comments and blank lines + line = line.strip() + if line.startswith('#') or not line: + continue + self.filelist.append(line) + manifest.close() -- cgit v1.2.1 From 645b5b084aa46696b490344a038875f105793308 Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Mon, 8 Oct 2012 20:37:54 +0200 Subject: Remove a missing fixer warning which showed during normal operations. Fixes #305. --HG-- branch : distribute extra : rebase_source : 3e5912a80758abf1e198d400c29ab03112eb68d6 --- setuptools/command/build_py.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py index 505dd4f3..8751acd4 100644 --- a/setuptools/command/build_py.py +++ b/setuptools/command/build_py.py @@ -51,10 +51,8 @@ try: 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) + if fixer_name in self.fixer_names: + self.fixer_names.remove(fixer_name) except ImportError: class Mixin2to3: -- cgit v1.2.1 From 9553dd9910df577351ea04bb1613767096beeca0 Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Mon, 8 Oct 2012 20:58:18 +0200 Subject: marshall.load() does not necessarily raise ValueError. Fixes #283. --HG-- branch : distribute extra : rebase_source : 203cee618118fb65bf109d2db0275aa90aa5a12d --- setuptools/command/bdist_egg.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/bdist_egg.py b/setuptools/command/bdist_egg.py index 0ee9c55b..17fae984 100644 --- a/setuptools/command/bdist_egg.py +++ b/setuptools/command/bdist_egg.py @@ -425,12 +425,12 @@ def scan_module(egg_dir, base, name, stubs): return True # Extension module pkg = base[len(egg_dir)+1:].replace(os.sep,'.') module = pkg+(pkg and '.' or '')+os.path.splitext(name)[0] - f = open(filename,'rb'); f.read(8) # skip magic & date - try: - code = marshal.load(f); f.close() - except ValueError: - f.seek(0); f.read(12) # skip magic & date & file size; file size added in Python 3.3 - code = marshal.load(f); f.close() + if sys.version_info < (3, 3): + skip = 8 # skip magic & date + else: + skip = 12 # skip magic & date & file size + f = open(filename,'rb'); f.read(skip) + code = marshal.load(f); f.close() safe = True symbols = dict.fromkeys(iter_symbols(code)) for bad in ['__file__', '__path__']: -- cgit v1.2.1 From 907d9f46c3e0ef8dbc55528da9efe5087c182c9f Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Mon, 8 Oct 2012 21:06:52 +0200 Subject: Fix duplicate application of version tags in 'egg_info' command. Fixes #299. --HG-- branch : distribute extra : rebase_source : 9f6fb87944bc3b9828b04bf8ac5ba7b3a40bfc95 --- setuptools/command/egg_info.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'setuptools/command') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index e932d46a..2dc59187 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -162,7 +162,12 @@ class egg_info(Command): os.unlink(filename) def tagged_version(self): - return safe_version(self.distribution.get_version() + self.vtags) + version = self.distribution.get_version() + # egg_info may be called more than once for a distribution, + # in which case the version string already contains all tags. + if self.vtags and version.endswith(self.vtags): + return safe_version(version) + return safe_version(version + self.vtags) def run(self): self.mkpath(self.egg_info) -- cgit v1.2.1