diff options
author | PJ Eby <distutils-sig@python.org> | 2005-07-17 04:42:42 +0000 |
---|---|---|
committer | PJ Eby <distutils-sig@python.org> | 2005-07-17 04:42:42 +0000 |
commit | 30f1c5ad93e21ec007d371313e2a27e4d0efb661 (patch) | |
tree | b809540a247a26776845a6f9a96c91a20f983af1 | |
parent | c8ebbe361890f4c0a34d7c3c64aefb34c6fed3e6 (diff) | |
download | external_python_setuptools-30f1c5ad93e21ec007d371313e2a27e4d0efb661.tar.gz external_python_setuptools-30f1c5ad93e21ec007d371313e2a27e4d0efb661.tar.bz2 external_python_setuptools-30f1c5ad93e21ec007d371313e2a27e4d0efb661.zip |
Renamings for consistent terminology; distributions and requirements now
both have 'project_name' attributes, instead of one having 'name' and the
other 'distname'. Requirements no longer have 'options', they have
'extras'. This is the beginning of the terminology/architecture
refactoring described at:
http://mail.python.org/pipermail/distutils-sig/2005-June/004652.html
--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041132
-rw-r--r-- | pkg_resources.py | 40 | ||||
-rwxr-xr-x | setuptools.txt | 2 | ||||
-rwxr-xr-x | setuptools/command/develop.py | 2 | ||||
-rwxr-xr-x | setuptools/command/easy_install.py | 12 | ||||
-rwxr-xr-x | setuptools/package_index.py | 4 | ||||
-rw-r--r-- | setuptools/tests/test_resources.py | 10 |
6 files changed, 35 insertions, 35 deletions
diff --git a/pkg_resources.py b/pkg_resources.py index c81db3d1..81c6314d 100644 --- a/pkg_resources.py +++ b/pkg_resources.py @@ -355,7 +355,7 @@ class AvailableDistributions(object): # Oops, the "best" so far conflicts with a dependency raise VersionConflict(dist,req) # XXX put more info here - requirements.extend(dist.depends(req.options)[::-1]) + requirements.extend(dist.depends(req.extras)[::-1]) processed[req] = True return to_install # return list of distros to install @@ -911,7 +911,7 @@ class PathMetadata(DefaultProvider): base_dir = os.path.dirname(egg_info) metadata = PathMetadata(base_dir, egg_info) dist_name = os.path.splitext(os.path.basename(egg_info))[0] - dist = Distribution(basedir,name=dist_name,metadata=metadata) + dist = Distribution(basedir,project_name=dist_name,metadata=metadata) # Unpacked egg directories: @@ -1094,7 +1094,7 @@ def find_on_path(importer,path_item): # development egg metadata = PathMetadata(path_item, fullpath) dist_name = os.path.splitext(entry)[0] - yield Distribution(path_item,metadata,name=dist_name) + yield Distribution(path_item,metadata,project_name=dist_name) elif lower.endswith('.egg-link'): for line in file(fullpath): if not line.strip(): continue @@ -1314,11 +1314,11 @@ class Distribution(object): """Wrap an actual or potential sys.path entry w/metadata""" def __init__(self, - path_str, metadata=None, name=None, version=None, + path_str, metadata=None, project_name=None, version=None, py_version=PY_MAJOR, platform=None, distro_type = EGG_DIST ): - if name: - self.name = safe_name(name) + if project_name: + self.project_name = safe_name(project_name) if version is not None: self._version = safe_version(version) self.py_version = py_version @@ -1340,11 +1340,11 @@ class Distribution(object): if ext.lower()==".egg": match = EGG_NAME(basename) if match: - name,version,py_version,platform = match.group( + project_name,version,py_version,platform = match.group( 'name','ver','pyver','plat' ) return cls( - filename, metadata, name=name, version=version, + filename, metadata, project_name=project_name, version=version, py_version=py_version, platform=platform ) from_filename = classmethod(from_filename) @@ -1360,7 +1360,7 @@ class Distribution(object): try: return self._key except AttributeError: - self._key = key = self.name.lower() + self._key = key = self.project_name.lower() return key key = property(key) @@ -1436,7 +1436,7 @@ class Distribution(object): def egg_name(self): """Return what this distribution's standard .egg filename should be""" filename = "%s-%s-py%s" % ( - self.name.replace('-','_'), self.version.replace('-','_'), + self.project_name.replace('-','_'), self.version.replace('-','_'), self.py_version or PY_MAJOR ) @@ -1450,7 +1450,7 @@ class Distribution(object): def __str__(self): version = getattr(self,'version',None) or "[unknown version]" - return "%s %s" % (self.name,version) + return "%s %s" % (self.project_name,version) @@ -1520,7 +1520,7 @@ def parse_requirements(strs): match = DISTRO(line) if not match: raise ValueError("Missing distribution spec", line) - distname = match.group(1) + project_name = match.group(1) p = match.end() options = [] @@ -1531,7 +1531,7 @@ def parse_requirements(strs): line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec") specs = [(op,val.replace('_','-')) for op,val in specs] - yield Requirement(distname.replace('_','-'), specs, options) + yield Requirement(project_name.replace('_','-'), specs, options) def _sort_dists(dists): @@ -1558,25 +1558,25 @@ def _sort_dists(dists): class Requirement: - def __init__(self, distname, specs=(), options=()): - self.distname = distname - self.key = distname.lower() + def __init__(self, project_name, specs=(), extras=()): + self.project_name = project_name + self.key = project_name.lower() index = [(parse_version(v),state_machine[op],op,v) for op,v in specs] index.sort() self.specs = [(op,ver) for parsed,trans,op,ver in index] - self.index, self.options = index, tuple(options) + self.index, self.extras = index, tuple(extras) self.hashCmp = ( self.key, tuple([(op,parsed) for parsed,trans,op,ver in index]), - ImmutableSet(map(str.lower,options)) + ImmutableSet(map(str.lower,extras)) ) self.__hash = hash(self.hashCmp) def __str__(self): - return self.distname + ','.join([''.join(s) for s in self.specs]) + return self.project_name + ','.join([''.join(s) for s in self.specs]) def __repr__(self): return "Requirement(%r, %r, %r)" % \ - (self.distname,self.specs,self.options) + (self.project_name,self.specs,self.extras) def __eq__(self,other): return isinstance(other,Requirement) and self.hashCmp==other.hashCmp diff --git a/setuptools.txt b/setuptools.txt index 96091864..8a1edcf7 100755 --- a/setuptools.txt +++ b/setuptools.txt @@ -701,7 +701,7 @@ If you have to manage automated builds for multiple packages, each with different tagging and rotation policies, you may also want to check out the `alias`_ command, which would let each package define an alias like ``daily`` that would perform the necessary tag, build, and rotate commands. Then, a -simpler scriptor cron job could just run ``setup.py daily`` in each project +simpler script or cron job could just run ``setup.py daily`` in each project directory. (And, you could also define sitewide or per-user default versions of the ``daily`` alias, so that projects that didn't define their own would use the appropriate defaults.) diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index a757b2e5..40d22b28 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -51,7 +51,7 @@ class develop(easy_install): self.dist = Distribution( self.egg_path, PathMetadata(self.egg_path, os.path.abspath(ei.egg_info)), - name = ei.egg_name + project_name = ei.egg_name ) def install_for_development(self): diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 4451c586..6d61c951 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -350,7 +350,7 @@ class easy_install(Command): self.install_egg_scripts(dist) log.warn(self.installation_report(dist, *info)) if requirement is None: - requirement = Requirement.parse('%s==%s'%(dist.name,dist.version)) + requirement = Requirement.parse('%s==%s'%(dist.project_name,dist.version)) if dist in requirement: log.info("Processing dependencies for %s", requirement) try: @@ -419,7 +419,7 @@ class easy_install(Command): options = match.group(1) or '' if options: options = ' '+options - spec = '%s==%s' % (dist.name,dist.version) + spec = '%s==%s' % (dist.project_name,dist.version) executable = os.path.normpath(sys.executable) if dev_path: @@ -541,7 +541,7 @@ class easy_install(Command): # Create a dummy distribution object until we build the real distro dist = Distribution(None, - name=cfg.get('metadata','name'), + project_name=cfg.get('metadata','name'), version=cfg.get('metadata','version'), platform="win32" ) @@ -678,7 +678,7 @@ installing: (Note: you can run EasyInstall on '%s' with the --delete-conflicting option to attempt deletion of the above files and/or directories.) -""" % dist.name +""" % dist.project_name else: msg += """\ Note: you can attempt this installation again with EasyInstall, and use @@ -719,7 +719,7 @@ this to work. (e.g. by being the application's script directory, by being on PYTHONPATH, or by being added to sys.path by your code.) """ eggloc = dist.path - name = dist.name + name = dist.project_name version = dist.version return msg % locals() @@ -802,7 +802,7 @@ PYTHONPATH, or by being added to sys.path by your code.) self.pth_file.save() - if dist.name=='setuptools': + if dist.project_name=='setuptools': # Ensure that setuptools itself never becomes unavailable! # XXX should this check for latest version? f = open(os.path.join(self.install_dir,'setuptools.pth'), 'w') diff --git a/setuptools/package_index.py b/setuptools/package_index.py index 5412fd1f..f553c2da 100755 --- a/setuptools/package_index.py +++ b/setuptools/package_index.py @@ -245,12 +245,12 @@ class PackageIndex(AvailableDistributions): def find_packages(self, requirement): - self.scan_url(self.index_url + requirement.distname+'/') + self.scan_url(self.index_url + requirement.project_name+'/') if not self.package_pages.get(requirement.key): # We couldn't find the target package, so search the index page too self.warn( "Couldn't find index page for %r (maybe misspelled?)", - requirement.distname + requirement.project_name ) if self.index_url not in self.fetched_urls: self.warn( diff --git a/setuptools/tests/test_resources.py b/setuptools/tests/test_resources.py index 91199f47..10786144 100644 --- a/setuptools/tests/test_resources.py +++ b/setuptools/tests/test_resources.py @@ -73,7 +73,7 @@ class DistroTests(TestCase): self.assertEqual(ad.best_match(req,path).version, '1.4') def checkFooPkg(self,d): - self.assertEqual(d.name, "FooPkg") + self.assertEqual(d.project_name, "FooPkg") self.assertEqual(d.key, "foopkg") self.assertEqual(d.version, "1.3-1") self.assertEqual(d.py_version, "2.4") @@ -83,7 +83,7 @@ class DistroTests(TestCase): def testDistroBasics(self): d = Distribution( "/some/path", - name="FooPkg",version="1.3-1",py_version="2.4",platform="win32" + project_name="FooPkg",version="1.3-1",py_version="2.4",platform="win32" ) self.checkFooPkg(d) self.failUnless(d.installed_on(["/some/path"])) @@ -99,7 +99,7 @@ class DistroTests(TestCase): def testDistroMetadata(self): d = Distribution( - "/some/path", name="FooPkg", py_version="2.4", platform="win32", + "/some/path", project_name="FooPkg", py_version="2.4", platform="win32", metadata = Metadata( ('PKG-INFO',"Metadata-Version: 1.0\nVersion: 1.3-1\n") ) @@ -250,8 +250,8 @@ class RequirementsTests(TestCase): r3 = Requirement.parse("Twisted[BAR,FOO]>=1.2.0") self.assertEqual(r1,r2) self.assertEqual(r1,r3) - self.assertEqual(r1.options, ("foo","bar")) - self.assertEqual(r2.options, ("bar","FOO")) + self.assertEqual(r1.extras, ("foo","bar")) + self.assertEqual(r2.extras, ("bar","FOO")) self.assertEqual(hash(r1), hash(r2)) self.assertEqual( hash(r1), hash(("twisted", ((">=",parse_version("1.2")),), |