Commit f7288a7f authored by PJ Eby's avatar PJ Eby

Massive API refactoring; see setuptools.txt changelog for details. Also,

add ``#egg=project-version`` link support, and docs on how to make your
package available for EasyInstall to find.

--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041136
parent c7214855
...@@ -67,7 +67,7 @@ version, and automatically downloading, building, and installing it:: ...@@ -67,7 +67,7 @@ version, and automatically downloading, building, and installing it::
**Example 2**. Install or upgrade a package by name and version by finding **Example 2**. Install or upgrade a package by name and version by finding
links on a given "download page":: links on a given "download page"::
easy_install -f http://peak.telecommunity.com/dist "setuptools>=0.5a13" easy_install -f http://peak.telecommunity.com/dist "setuptools>=0.6a0"
**Example 3**. Download a source distribution from a specified URL, **Example 3**. Download a source distribution from a specified URL,
automatically building and installing it:: automatically building and installing it::
......
...@@ -14,7 +14,7 @@ the appropriate options to ``use_setuptools()``. ...@@ -14,7 +14,7 @@ the appropriate options to ``use_setuptools()``.
This file can also be run as a script to install or upgrade setuptools. This file can also be run as a script to install or upgrade setuptools.
""" """
DEFAULT_VERSION = "0.5a13" DEFAULT_VERSION = "0.6a0"
DEFAULT_URL = "http://www.python.org/packages/source/s/setuptools/" DEFAULT_URL = "http://www.python.org/packages/source/s/setuptools/"
import sys, os import sys, os
......
...@@ -232,7 +232,7 @@ class WorkingSet(object): ...@@ -232,7 +232,7 @@ class WorkingSet(object):
""" """
self.entry_keys.setdefault(entry, []) self.entry_keys.setdefault(entry, [])
self.entries.append(entry) self.entries.append(entry)
for dist in find_distributions(entry, False): for dist in find_distributions(entry, True):
self.add(dist, entry) self.add(dist, entry)
......
[aliases] [aliases]
source = register sdist binary
binary = bdist_egg upload --show-response binary = bdist_egg upload --show-response
develop = develop
source = register sdist binary
...@@ -15,7 +15,7 @@ def get_description(): ...@@ -15,7 +15,7 @@ def get_description():
f.close() f.close()
return ''.join(lines) return ''.join(lines)
VERSION = "0.5a13" VERSION = "0.6a0"
from setuptools import setup, find_packages from setuptools import setup, find_packages
......
...@@ -7,7 +7,7 @@ from distutils.core import Command as _Command ...@@ -7,7 +7,7 @@ from distutils.core import Command as _Command
from distutils.util import convert_path from distutils.util import convert_path
import os.path import os.path
__version__ = '0.5a13' __version__ = '0.6a0'
__all__ = [ __all__ = [
'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'Require', 'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'Require',
'find_packages' 'find_packages'
......
...@@ -419,7 +419,7 @@ class easy_install(Command): ...@@ -419,7 +419,7 @@ class easy_install(Command):
options = match.group(1) or '' options = match.group(1) or ''
if options: if options:
options = ' '+options options = ' '+options
spec = dist.as_requirement() spec = str(dist.as_requirement())
executable = os.path.normpath(sys.executable) executable = os.path.normpath(sys.executable)
if dev_path: if dev_path:
...@@ -789,7 +789,7 @@ PYTHONPATH, or by being added to sys.path by your code.) ...@@ -789,7 +789,7 @@ PYTHONPATH, or by being added to sys.path by your code.)
self.shadow_path.remove(d.location) self.shadow_path.remove(d.location)
if not self.multi_version: if not self.multi_version:
if dist.location in map(normalize_path,self.pth_file.paths): if dist.location in self.pth_file.paths:
log.info( log.info(
"%s is already the active version in easy-install.pth", "%s is already the active version in easy-install.pth",
dist dist
...@@ -802,10 +802,10 @@ PYTHONPATH, or by being added to sys.path by your code.) ...@@ -802,10 +802,10 @@ PYTHONPATH, or by being added to sys.path by your code.)
self.pth_file.save() self.pth_file.save()
if dist.project_name=='setuptools': if dist.key=='setuptools':
# Ensure that setuptools itself never becomes unavailable! # Ensure that setuptools itself never becomes unavailable!
# XXX should this check for latest version? # XXX should this check for latest version?
f = open(os.path.join(self.install_dir,'setuptools.pth'), 'w') f = open(os.path.join(self.install_dir,'setuptools.pth'), 'wt')
f.write(dist.location+'\n') f.write(dist.location+'\n')
f.close() f.close()
...@@ -1027,6 +1027,7 @@ class PthDistributions(AvailableDistributions): ...@@ -1027,6 +1027,7 @@ class PthDistributions(AvailableDistributions):
"""A .pth file with Distribution paths in it""" """A .pth file with Distribution paths in it"""
dirty = False dirty = False
def __init__(self, filename): def __init__(self, filename):
self.filename = filename; self._load() self.filename = filename; self._load()
AvailableDistributions.__init__( AvailableDistributions.__init__(
...@@ -1035,22 +1036,34 @@ class PthDistributions(AvailableDistributions): ...@@ -1035,22 +1036,34 @@ class PthDistributions(AvailableDistributions):
def _load(self): def _load(self):
self.paths = [] self.paths = []
seen = {}
if os.path.isfile(self.filename): if os.path.isfile(self.filename):
self.paths = [line.rstrip() for line in open(self.filename,'rt')] for line in open(self.filename,'rt'):
while self.paths and not self.paths[-1].strip(): self.paths.pop() path = line.rstrip()
# delete non-existent paths, in case somebody deleted a package self.paths.append(path)
# manually: if not path.strip() or path.strip().startswith('#'):
for line in list(yield_lines(self.paths)): continue
if not os.path.exists(line): # skip non-existent paths, in case somebody deleted a package
self.paths.remove(line); self.dirty = True # manually, and duplicate paths as well
path = self.paths[-1] = normalize_path(path)
if not os.path.exists(path) or path in seen:
self.paths.pop() # skip it
self.dirty = True # we cleaned up, so we're dirty now :)
continue
seen[path] = 1
while self.paths and not self.paths[-1].strip(): self.paths.pop()
def save(self): def save(self):
"""Write changed .pth file back to disk""" """Write changed .pth file back to disk"""
if self.dirty: if self.dirty:
log.debug("Saving %s", self.filename)
data = '\n'.join(self.paths+['']) data = '\n'.join(self.paths+[''])
f = open(self.filename,'wt'); f.write(data); f.close() f = open(self.filename,'wt'); f.write(data); f.close()
self.dirty = False self.dirty = False
def add(self,dist): def add(self,dist):
"""Add `dist` to the distribution map""" """Add `dist` to the distribution map"""
if dist.location not in self.paths: if dist.location not in self.paths:
...@@ -1085,19 +1098,6 @@ def main(argv, **kw): ...@@ -1085,19 +1098,6 @@ def main(argv, **kw):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment