Python-checkins
Threads by month
- ----- 2026 -----
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
July 2005
- 22 participants
- 376 discussions
python/nondist/sandbox/setuptools EasyInstall.txt, 1.21, 1.22 ez_setup.py, 1.8, 1.9 setup.py, 1.18, 1.19
by pje@users.sourceforge.net July 6, 2005
by pje@users.sourceforge.net July 6, 2005
July 6, 2005
Update of /cvsroot/python/python/nondist/sandbox/setuptools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14165
Modified Files:
EasyInstall.txt ez_setup.py setup.py
Log Message:
Bump version to 0.5a5.
Index: EasyInstall.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/EasyInstall.txt,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- EasyInstall.txt 6 Jul 2005 03:46:15 -0000 1.21
+++ EasyInstall.txt 6 Jul 2005 03:47:04 -0000 1.22
@@ -23,13 +23,13 @@
-------------------------
Windows users can just download and run the `setuptools binary installer for
-Windows <http://peak.telecommunity.com/dist/setuptools-0.5a4.win32.exe>`_.
+Windows <http://peak.telecommunity.com/dist/setuptools-0.5a5.win32.exe>`_.
All others should just download `ez_setup.py
<http://peak.telecommunity.com/dist/ez_setup.py>`_, and run it; this will
download and install the `Python 2.3 egg`_ or `Python 2.4 egg`_ for you.
-.. _Python 2.3 egg: http://peak.telecommunity.com/dist/setuptools-0.5a4-py2.3.egg
-.. _Python 2.4 egg: http://peak.telecommunity.com/dist/setuptools-0.5a4-py2.4.egg
+.. _Python 2.3 egg: http://peak.telecommunity.com/dist/setuptools-0.5a5-py2.3.egg
+.. _Python 2.4 egg: http://peak.telecommunity.com/dist/setuptools-0.5a5-py2.4.egg
You may receive a message telling you about an obsolete version of
setuptools being present; if so, you must be sure to delete it entirely, along
@@ -66,7 +66,7 @@
**Example 2**. Install or upgrade a package by name and version by finding
links on a given "download page"::
- easy_install -f http://peak.telecommunity.com/dist "setuptools>=0.5a4"
+ easy_install -f http://peak.telecommunity.com/dist "setuptools>=0.5a5"
**Example 3**. Download a source distribution from a specified URL,
automatically building and installing it::
Index: ez_setup.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/ez_setup.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- ez_setup.py 6 Jul 2005 02:10:48 -0000 1.8
+++ ez_setup.py 6 Jul 2005 03:47:04 -0000 1.9
@@ -14,7 +14,7 @@
This file can also be run as a script to install or upgrade setuptools.
"""
-DEFAULT_VERSION = "0.5a4"
+DEFAULT_VERSION = "0.5a5"
DEFAULT_URL = "http://peak.telecommunity.com/dist/"
import sys, os
Index: setup.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setup.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- setup.py 6 Jul 2005 02:10:48 -0000 1.18
+++ setup.py 6 Jul 2005 03:47:04 -0000 1.19
@@ -1,7 +1,7 @@
#!/usr/bin/env python
"""Distutils setup file, used to install or test 'setuptools'"""
-VERSION = "0.5a4"
+VERSION = "0.5a5"
from setuptools import setup, find_packages, Require
setup(
1
0
[Python-checkins] python/nondist/sandbox/setuptools/setuptools/command develop.py, NONE, 1.1 __init__.py, 1.3, 1.4 easy_install.py, 1.1, 1.2 test.py, 1.2, 1.3
by pje@users.sourceforge.net July 6, 2005
by pje@users.sourceforge.net July 6, 2005
July 6, 2005
Update of /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13765/setuptools/command
Modified Files:
__init__.py easy_install.py test.py
Added Files:
develop.py
Log Message:
Added ``develop`` command to ``setuptools``-based packages. This command
installs an ``.egg-link`` pointing to the package's source directory, and
script wrappers that ``execfile()`` the source versions of the package's
scripts. This lets you put your development checkout(s) on sys.path
without having to actually install them. (To uninstall the link, use
use ``setup.py develop --uninstall``.)
--- NEW FILE: develop.py ---
from setuptools.command.easy_install import easy_install
from distutils.util import convert_path
from pkg_resources import Distribution, PathMetadata
from distutils import log
import sys, os
class develop(easy_install):
"""Set up package for development"""
description = "install package in 'development mode'"
user_options = [
("install-dir=", "d", "link package from DIR"),
("script-dir=", "s", "create script wrappers in DIR"),
("multi-version", "m", "make apps have to require() a version"),
("exclude-scripts", "x", "Don't install scripts"),
("always-copy", "a", "Copy all needed dependencies to install dir"),
("uninstall", "u", "Uninstall this source package"),
]
boolean_options = [
'multi-version', 'exclude-scripts', 'always-copy', 'uninstall'
]
command_consumes_arguments = False # override base
def initialize_options(self):
self.uninstall = None
easy_install.initialize_options(self)
def finalize_options(self):
ei = self.get_finalized_command("egg_info")
self.args = [ei.egg_name]
easy_install.finalize_options(self)
self.egg_link = os.path.join(self.install_dir, ei.egg_name+'.egg-link')
self.egg_base = ei.egg_base
self.egg_path = os.path.abspath(ei.egg_base)
# Make a distribution for the package's source
self.dist = Distribution(
self.egg_path,
PathMetadata(self.egg_path, os.path.abspath(ei.egg_info)),
name = ei.egg_name
)
def run(self):
if self.uninstall:
self.multi_version = True
self.uninstall_link()
else:
self.install_for_development()
def install_for_development(self):
# Ensure metadata is up-to-date
self.run_command('egg_info')
ei = self.get_finalized_command("egg_info")
# Build extensions in-place
self.reinitialize_command('build_ext', inplace=1)
self.run_command('build_ext')
# create an .egg-link in the installation dir, pointing to our egg
log.info("Creating %s (link to %s)", self.egg_link, self.egg_base)
if not self.dry_run:
f = open(self.egg_link,"w")
f.write(self.egg_path)
f.close()
# postprocess the installed distro, fixing up .pth, installing scripts,
# and handling requirements
self.process_distribution(None, self.dist)
def uninstall_link(self):
if os.path.exists(self.egg_link):
log.info("Removing %s (link to %s)", self.egg_link, self.egg_base)
contents = [line.rstrip() for line in file(self.egg_link)]
if contents != [self.egg_path]:
log.warn("Link points to %s: uninstall aborted", contents)
return
if not self.dry_run:
os.unlink(self.egg_link)
self.update_pth(self.dist) # remove any .pth link to us
if self.distribution.scripts:
log.warn("Note: you must uninstall or replace scripts manually!")
def install_egg_scripts(self, dist):
if dist is not self.dist:
# Installing a dependency, so fall back to normal behavior
return easy_install.install_egg_scripts(self,dist)
# create wrapper scripts in the script dir, pointing to dist.scripts
for script_name in self.distribution.scripts or []:
script_path = os.path.abspath(convert_path(script_name))
script_name = os.path.basename(script_path)
f = open(script_path,'rU')
script_text = f.read()
f.close()
self.install_script(dist, script_name, script_text, script_path)
Index: __init__.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command/__init__.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- __init__.py 21 Mar 2005 19:50:46 -0000 1.3
+++ __init__.py 6 Jul 2005 03:46:16 -0000 1.4
@@ -1,6 +1,6 @@
import distutils.command
-__all__ = ['test', 'depends', 'bdist_egg']
+__all__ = ['test', 'develop', 'bdist_egg']
# Make our commands available as though they were part of the distutils
Index: easy_install.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command/easy_install.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- easy_install.py 6 Jul 2005 02:10:48 -0000 1.1
+++ easy_install.py 6 Jul 2005 03:46:16 -0000 1.2
@@ -126,7 +126,7 @@
for path_item in self.install_dir, self.script_dir:
if path_item not in self.shadow_path:
self.shadow_path.insert(0, self.install_dir)
-
+
if self.package_index is None:
self.package_index = self.create_index(
self.index_url, search_path = self.shadow_path
@@ -207,12 +207,12 @@
tmpdir = self.alloc_tmp()
download = None
- try:
+ try:
if not isinstance(spec,Requirement):
if URL_SCHEME(spec):
# It's a url, download it to tmpdir and process
download = self.package_index.download(spec, tmpdir)
- return self.install_item(None, download, tmpdir, True)
+ return self.install_item(None, download, tmpdir, True)
elif os.path.exists(spec):
# Existing file or directory, just process it directly
@@ -290,40 +290,81 @@
if self.exclude_scripts or not metadata.metadata_isdir('scripts'):
return
- from distutils.command.build_scripts import first_line_re
-
for script_name in metadata.metadata_listdir('scripts'):
- target = os.path.join(self.script_dir, script_name)
+ self.install_script(
+ dist, script_name,
+ metadata.get_metadata('scripts/'+script_name).replace('\r','\n')
+ )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- log.info("Installing %s script to %s", script_name,self.script_dir)
- script_text = metadata.get_metadata('scripts/'+script_name)
- script_text = script_text.replace('\r','\n')
- first, rest = script_text.split('\n',1)
- match = first_line_re.match(first)
- options = ''
- if match:
- options = match.group(1) or ''
- if options:
- options = ' '+options
- spec = '%s==%s' % (dist.name,dist.version)
- script_text = '\n'.join([
- "#!%s%s" % (os.path.normpath(sys.executable),options),
- "# EASY-INSTALL-SCRIPT: %r,%r" % (spec, script_name),
- "import pkg_resources",
- "pkg_resources.run_main(%r, %r)" % (spec, script_name)
- ])
- if not self.dry_run:
- f = open(target,"w")
- f.write(script_text)
- f.close()
- try:
- os.chmod(target,0755)
- except (AttributeError, os.error):
- pass
+
+
+
+ def install_script(self, dist, script_name, script_text, dev_path=None):
+ log.info("Installing %s script to %s", script_name,self.script_dir)
+ target = os.path.join(self.script_dir, script_name)
+ first, rest = script_text.split('\n',1)
+ from distutils.command.build_scripts import first_line_re
+ match = first_line_re.match(first)
+ options = ''
+ if match:
+ options = match.group(1) or ''
+ if options:
+ options = ' '+options
+ spec = '%s==%s' % (dist.name,dist.version)
+ executable = os.path.normpath(sys.executable)
+
+ if dev_path:
+ script_text = (
+ "#!%(executable)s%(options)s\n"
+ "# EASY-INSTALL-DEV-SCRIPT: %(spec)r,%(script_name)r\n"
+ "from pkg_resources import require; require(%(spec)r)\n"
+ "del require\n"
+ "__file__ = %(dev_path)r\n"
+ "execfile(__file__)\n"
+ ) % locals()
+ else:
+ script_text = (
+ "#!%(executable)s%(options)s\n"
+ "# EASY-INSTALL-SCRIPT: %(spec)r,%(script_name)r\n"
+ "import pkg_resources\n"
+ "pkg_resources.run_main(%(spec)r, %(script_name)r)\n"
+ ) % locals()
+
+ if not self.dry_run:
+ f = open(target,"w")
+ f.write(script_text)
+ f.close()
+ try:
+ os.chmod(target,0755)
+ except (AttributeError, os.error):
+ pass
def install_eggs(self, dist_filename, zip_ok, tmpdir):
@@ -373,7 +414,7 @@
else:
metadata = EggMetadata(zipimport.zipimporter(egg_path))
return Distribution.from_filename(egg_path,metadata=metadata)
-
+
def install_egg(self, egg_path, zip_ok, tmpdir):
destination = os.path.join(self.install_dir,os.path.basename(egg_path))
destination = os.path.abspath(destination)
@@ -443,7 +484,7 @@
verbose=self.verbose, dry_run=self.dry_run
)
- # install the .egg
+ # install the .egg
return self.install_egg(egg_path, self.zip_ok, tmpdir)
@@ -474,7 +515,7 @@
# extract, tracking .pyd/.dll->native_libs and .py -> to_compile
unpack_archive(dist_filename, egg_tmp, process)
-
+
for res in native_libs:
if res.lower().endswith('.pyd'): # create stubs for .pyd's
parts = res.split('/')
@@ -482,9 +523,9 @@
pyfile = os.path.join(egg_tmp, *parts)
to_compile.append(pyfile)
bdist_egg.write_stub(resource, pyfile)
-
+
self.byte_compile(to_compile) # compile .py's
-
+
if native_libs: # write EGG-INFO/native_libs.txt
nl_txt = os.path.join(egg_tmp, 'EGG-INFO', 'native_libs.txt')
ensure_directory(nl_txt)
@@ -599,6 +640,7 @@
if dist.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')
f.write(dist.path+'\n')
f.close()
@@ -612,7 +654,6 @@
-
def unpack_and_compile(self, egg_path, destination):
to_compile = []
@@ -632,7 +673,7 @@
# try to make the byte compile messages quieter
log.set_verbosity(self.verbose - 1)
- byte_compile(to_compile, optimize=0, force=1, dry_run=self.dry_run)
+ byte_compile(to_compile, optimize=0, force=1, dry_run=self.dry_run)
if self.optimize:
byte_compile(
to_compile, optimize=self.optimize, force=1,
@@ -667,7 +708,7 @@
prepended = (endrec[9] - endrec[5]) - endrec[6]
if prepended < 12: # no wininst data here
- return None
+ return None
f.seek(prepended-12)
import struct, StringIO, ConfigParser
@@ -683,7 +724,7 @@
return None
if not cfg.has_section('metadata') or not cfg.has_section('Setup'):
return None
- return cfg
+ return cfg
finally:
f.close()
Index: test.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command/test.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- test.py 6 Jul 2005 01:54:07 -0000 1.2
+++ test.py 6 Jul 2005 03:46:16 -0000 1.3
@@ -4,9 +4,9 @@
class test(Command):
- """Command to run unit tests after installation"""
+ """Command to run unit tests after in-place build"""
- description = "run unit tests after installation"
+ description = "run unit tests after in-place build"
user_options = [
('test-module=','m', "Run 'test_suite' in specified module"),
1
0
python/nondist/sandbox/setuptools EasyInstall.txt, 1.20, 1.21 pkg_resources.py, 1.35, 1.36
by pje@users.sourceforge.net July 6, 2005
by pje@users.sourceforge.net July 6, 2005
July 6, 2005
Update of /cvsroot/python/python/nondist/sandbox/setuptools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13765
Modified Files:
EasyInstall.txt pkg_resources.py
Log Message:
Added ``develop`` command to ``setuptools``-based packages. This command
installs an ``.egg-link`` pointing to the package's source directory, and
script wrappers that ``execfile()`` the source versions of the package's
scripts. This lets you put your development checkout(s) on sys.path
without having to actually install them. (To uninstall the link, use
use ``setup.py develop --uninstall``.)
Index: EasyInstall.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/EasyInstall.txt,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- EasyInstall.txt 6 Jul 2005 02:10:47 -0000 1.20
+++ EasyInstall.txt 6 Jul 2005 03:46:15 -0000 1.21
@@ -482,10 +482,17 @@
time out or be missing a file.
0.5a5
+ * Added ``develop`` command to ``setuptools``-based packages. This command
+ installs an ``.egg-link`` pointing to the package's source directory, and
+ script wrappers that ``execfile()`` the source versions of the package's
+ scripts. This lets you put your development checkout(s) on sys.path without
+ having to actually install them. (To uninstall the link, use
+ use ``setup.py develop --uninstall``.)
+
* Added ``egg_info`` command to ``setuptools``-based packages. This command
just creates or updates the "projectname.egg-info" directory, without
- building an egg. It's used by the ``bdist_egg`` and ``test`` commands now,
- and will be used by the ``develop`` command later on.
+ building an egg. (It's used by the ``bdist_egg``, ``test``, and ``develop``
+ commands.)
* Enhanced the ``test`` command so that it doesn't install the package, but
instead builds any C extensions in-place, updates the ``.egg-info``
Index: pkg_resources.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/pkg_resources.py,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- pkg_resources.py 27 Jun 2005 00:31:02 -0000 1.35
+++ pkg_resources.py 6 Jul 2005 03:46:16 -0000 1.36
@@ -984,10 +984,8 @@
def find_nothing(importer,path_item):
return ()
-
register_finder(object,find_nothing)
-
def find_on_path(importer,path_item):
"""Yield distributions accessible on a sys.path directory"""
if not os.path.exists(path_item):
@@ -1004,25 +1002,27 @@
# scan for .egg and .egg-info in directory
for entry in os.listdir(path_item):
fullpath = os.path.join(path_item, entry)
- if entry.lower().endswith('.egg'):
+ lower = entry.lower()
+ if lower.endswith('.egg'):
for dist in find_on_path(importer,fullpath):
yield dist
- elif entry.lower().endswith('.egg-info'):
+ elif lower.endswith('.egg-info'):
if os.path.isdir(fullpath):
# development egg
metadata = PathMetadata(path_item, fullpath)
dist_name = os.path.splitext(entry)[0]
yield Distribution(path_item,metadata,name=dist_name)
- elif path_item.lower().endswith('.egg'):
- # packed egg
+ elif lower.endswith('.egg-link'):
+ for line in file(fullpath):
+ if not line.strip(): continue
+ for item in find_distributions(line.rstrip()):
+ yield item
+ elif path_item.lower().endswith('.egg'): # packed egg
metadata = EggMetadata(zipimport.zipimporter(path_item))
yield Distribution.from_filename(path_item, metadata=metadata)
register_finder(ImpWrapper,find_on_path)
-
-
-
_namespace_handlers = {}
_namespace_packages = {}
1
0
python/nondist/sandbox/setuptools/setuptools dist.py, 1.9, 1.10
by pje@users.sourceforge.net July 6, 2005
by pje@users.sourceforge.net July 6, 2005
July 6, 2005
Update of /cvsroot/python/python/nondist/sandbox/setuptools/setuptools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29898/setuptools
Modified Files:
dist.py
Log Message:
Made ``easy_install`` a standard ``setuptools`` command, moving it from
the ``easy_install`` module to ``setuptools.command.easy_install``. Note
that if you were importing or extending it, you must now change your
imports accordingly. ``easy_install.py`` is still installed as a script,
but not as a module.
Index: dist.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/dist.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- dist.py 4 Jul 2005 18:45:41 -0000 1.9
+++ dist.py 6 Jul 2005 02:10:48 -0000 1.10
@@ -395,7 +395,7 @@
self.run_command(cmd)
def install_eggs(self):
- from easy_install import easy_install
+ from setuptools.command.easy_install import easy_install
cmd = easy_install(self, args="x")
cmd.ensure_finalized() # finalize before bdist_egg munges install cmd
self.run_command('bdist_egg')
1
0
python/nondist/sandbox/setuptools EasyInstall.txt, 1.19, 1.20 easy_install.py, 1.25, 1.26 ez_setup.py, 1.7, 1.8 setup.py, 1.17, 1.18
by pje@users.sourceforge.net July 6, 2005
by pje@users.sourceforge.net July 6, 2005
July 6, 2005
Update of /cvsroot/python/python/nondist/sandbox/setuptools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29898
Modified Files:
EasyInstall.txt easy_install.py ez_setup.py setup.py
Log Message:
Made ``easy_install`` a standard ``setuptools`` command, moving it from
the ``easy_install`` module to ``setuptools.command.easy_install``. Note
that if you were importing or extending it, you must now change your
imports accordingly. ``easy_install.py`` is still installed as a script,
but not as a module.
Index: EasyInstall.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/EasyInstall.txt,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- EasyInstall.txt 6 Jul 2005 01:54:07 -0000 1.19
+++ EasyInstall.txt 6 Jul 2005 02:10:47 -0000 1.20
@@ -493,12 +493,18 @@
directly on the source. This avoids an "unmanaged" installation of the
package to ``site-packages`` or elsewhere.
+ * Made ``easy_install`` a standard ``setuptools`` command, moving it from
+ the ``easy_install`` module to ``setuptools.command.easy_install``. Note
+ that if you were importing or extending it, you must now change your imports
+ accordingly. ``easy_install.py`` is still installed as a script, but not as
+ a module.
+
0.5a4
* Added ``--always-copy/-a`` option to always copy needed packages to the
installation directory, even if they're already present elsewhere on
sys.path. (In previous versions, this was the default behavior, but now
you must request it.)
-
+
* Added ``--upgrade/-U`` option to force checking PyPI for latest available
version(s) of all packages requested by name and version, even if a matching
version is available locally.
@@ -522,7 +528,7 @@
* Setup scripts using setuptools now always install using ``easy_install``
internally, for ease of uninstallation and upgrading. Note: you *must*
remove any ``extra_path`` argument from your setup script, as it conflicts
- with the proper functioning of the ``easy_install`` command. (Also, added
+ with the proper functioning of the ``easy_install`` command. (Also, added
the ``--record`` option to ``easy_install`` for the benefit of tools that
run ``setup.py install --record=filename`` on behalf of another packaging
system.)
@@ -535,7 +541,7 @@
0.5a3
* Fixed not setting script permissions to allow execution.
-
+
* Improved sandboxing so that setup scripts that want a temporary directory
(e.g. pychecker) can still run in the sandbox.
Index: easy_install.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/easy_install.py,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- easy_install.py 4 Jul 2005 18:45:02 -0000 1.25
+++ easy_install.py 6 Jul 2005 02:10:47 -0000 1.26
@@ -11,810 +11,9 @@
__ http://peak.telecommunity.com/DevCenter/EasyInstall
"""
-import sys, os.path, zipimport, shutil, tempfile, zipfile
-
-from setuptools import Command
-from setuptools.sandbox import run_setup
-from distutils import log, dir_util
-from distutils.sysconfig import get_python_lib
-from distutils.errors import DistutilsArgError, DistutilsOptionError
-from setuptools.archive_util import unpack_archive
-from setuptools.package_index import PackageIndex, parse_bdist_wininst
-from setuptools.package_index import URL_SCHEME
-from setuptools.command import bdist_egg
-from pkg_resources import *
-
-__all__ = [
- 'samefile', 'easy_install', 'PthDistributions', 'extract_wininst_cfg',
- 'main', 'get_exe_prefixes',
-]
-
-def samefile(p1,p2):
- if hasattr(os.path,'samefile') and (
- os.path.exists(p1) and os.path.exists(p2)
- ):
- return os.path.samefile(p1,p2)
- return (
- os.path.normpath(os.path.normcase(p1)) ==
- os.path.normpath(os.path.normcase(p2))
- )
-
-class easy_install(Command):
- """Manage a download/build/install process"""
-
- description = "Find/get/install Python packages"
- command_consumes_arguments = True
- user_options = [
- ("zip-ok", "z", "install package as a zipfile"),
- ("multi-version", "m", "make apps have to require() a version"),
- ("upgrade", "U", "force upgrade (searches PyPI for latest versions)"),
- ("install-dir=", "d", "install package to DIR"),
- ("script-dir=", "s", "install scripts to DIR"),
- ("exclude-scripts", "x", "Don't install scripts"),
- ("always-copy", "a", "Copy all needed packages to install dir"),
- ("index-url=", "i", "base URL of Python Package Index"),
- ("find-links=", "f", "additional URL(s) to search for packages"),
- ("build-directory=", "b",
- "download/extract/build in DIR; keep the results"),
- ('optimize=', 'O',
- "also compile with optimization: -O1 for \"python -O\", "
- "-O2 for \"python -OO\", and -O0 to disable [default: -O0]"),
- ('record=', None,
- "filename in which to record list of installed files"),
- ]
- boolean_options = [
- 'zip-ok', 'multi-version', 'exclude-scripts', 'upgrade', 'always-copy'
- ]
- create_index = PackageIndex
-
- def initialize_options(self):
- self.zip_ok = None
- self.install_dir = self.script_dir = self.exclude_scripts = None
- self.index_url = None
- self.find_links = None
- self.build_directory = None
- self.args = None
- self.optimize = self.record = None
- self.upgrade = self.always_copy = self.multi_version = None
- # Options not specifiable via command line
- self.package_index = None
- self.pth_file = None
-
- def finalize_options(self):
- # If a non-default installation directory was specified, default the
- # script directory to match it.
- if self.script_dir is None:
- self.script_dir = self.install_dir
-
- # Let install_dir get set by install_lib command, which in turn
- # gets its info from the install command, and takes into account
- # --prefix and --home and all that other crud.
- self.set_undefined_options('install_lib',
- ('install_dir','install_dir')
- )
- # Likewise, set default script_dir from 'install_scripts.install_dir'
- self.set_undefined_options('install_scripts',
- ('install_dir', 'script_dir')
- )
- # default --record from the install command
- self.set_undefined_options('install', ('record', 'record'))
-
- site_packages = get_python_lib()
- instdir = self.install_dir
-
- if instdir is None or samefile(site_packages,instdir):
- instdir = site_packages
- if self.pth_file is None:
- self.pth_file = PthDistributions(
- os.path.join(instdir,'easy-install.pth')
- )
- self.install_dir = instdir
-
- elif self.multi_version is None:
- self.multi_version = True
-
- elif not self.multi_version:
- # explicit false set from Python code; raise an error
- raise DistutilsArgError(
- "Can't do single-version installs outside site-packages"
- )
-
- self.index_url = self.index_url or "http://www.python.org/pypi"
-
- self.shadow_path = sys.path[:]
-
- for path_item in self.install_dir, self.script_dir:
- if path_item not in self.shadow_path:
- self.shadow_path.insert(0, self.install_dir)
-
- if self.package_index is None:
- self.package_index = self.create_index(
- self.index_url, search_path = self.shadow_path
- )
-
- self.local_index = AvailableDistributions(self.shadow_path)
-
- if self.find_links is not None:
- if isinstance(self.find_links, basestring):
- self.find_links = self.find_links.split()
- else:
- self.find_links = []
-
- self.set_undefined_options('install_lib', ('optimize','optimize'))
-
- if not isinstance(self.optimize,int):
- try:
- self.optimize = int(self.optimize)
- if not (0 <= self.optimize <= 2): raise ValueError
- except ValueError:
- raise DistutilsOptionError("--optimize must be 0, 1, or 2")
-
- if not self.args:
- raise DistutilsArgError(
- "No urls, filenames, or requirements specified (see --help)")
-
- elif len(self.args)>1 and self.build_directory is not None:
- raise DistutilsArgError(
- "Build directory can only be set when using one URL"
- )
-
- self.outputs = []
-
-
-
- def alloc_tmp(self):
- if self.build_directory is None:
- return tempfile.mkdtemp(prefix="easy_install-")
- tmpdir = os.path.realpath(self.build_directory)
- if not os.path.isdir(tmpdir):
- os.makedirs(tmpdir)
- return tmpdir
-
-
- def run(self):
- if self.verbose<>self.distribution.verbose:
- log.set_verbosity(self.verbose)
- try:
- for link in self.find_links:
- self.package_index.scan_url(link)
- for spec in self.args:
- self.easy_install(spec)
- if self.record:
- from distutils import file_util
- self.execute(
- file_util.write_file, (self.record, self.outputs),
- "writing list of installed files to '%s'" %
- self.record
- )
- finally:
- log.set_verbosity(self.distribution.verbose)
-
-
- def add_output(self, path):
- if os.path.isdir(path):
- for base, dirs, files in os.walk(path):
- for filename in files:
- self.outputs.append(os.path.join(base,filename))
- else:
- self.outputs.append(path)
-
-
-
-
-
-
- def easy_install(self, spec):
- tmpdir = self.alloc_tmp()
- download = None
-
- try:
- if not isinstance(spec,Requirement):
- if URL_SCHEME(spec):
- # It's a url, download it to tmpdir and process
- download = self.package_index.download(spec, tmpdir)
- return self.install_item(None, download, tmpdir, True)
-
- elif os.path.exists(spec):
- # Existing file or directory, just process it directly
- return self.install_item(None, spec, tmpdir, True)
- else:
- try:
- spec = Requirement.parse(spec)
- except ValueError:
- raise RuntimeError(
- "Not a URL, existing file, or requirement spec: %r"
- % (spec,)
- )
-
- if isinstance(spec, Requirement):
- download = self.package_index.fetch(spec, tmpdir, self.upgrade)
- else:
- spec = None
-
- if download is None:
- raise RuntimeError(
- "Could not find distribution for %r" % spec
- )
-
- return self.install_item(spec, download, tmpdir)
-
- finally:
- if self.build_directory is None:
- shutil.rmtree(tmpdir)
-
-
-
- def install_item(self, spec, download, tmpdir, install_needed=False):
- # Installation is also needed if file in tmpdir or is not an egg
- install_needed = install_needed or os.path.dirname(download) == tmpdir
- install_needed = install_needed or not download.endswith('.egg')
- log.info("Processing %s", os.path.basename(download))
- if install_needed or self.always_copy:
- dists = self.install_eggs(download, self.zip_ok, tmpdir)
- for dist in dists:
- self.process_distribution(spec, dist)
- else:
- dists = [self.egg_distribution(download)]
- self.process_distribution(spec, dists[0], "Using")
- if spec is not None:
- for dist in dists:
- if dist in spec:
- return dist
-
- def process_distribution(self, requirement, dist, *info):
- self.update_pth(dist)
- self.package_index.add(dist)
- self.local_index.add(dist)
- 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))
- if dist in requirement:
- log.info("Processing dependencies for %s", requirement)
- try:
- self.local_index.resolve(
- [requirement], self.shadow_path, self.easy_install
- )
- except DistributionNotFound, e:
- raise RuntimeError(
- "Could not find required distribution %s" % e.args
- )
- except VersionConflict, e:
- raise RuntimeError(
- "Installed distribution %s conflicts with requirement %s"
- % e.args
- )
-
- def install_egg_scripts(self, dist):
- metadata = dist.metadata
- if self.exclude_scripts or not metadata.metadata_isdir('scripts'):
- return
-
- from distutils.command.build_scripts import first_line_re
-
- for script_name in metadata.metadata_listdir('scripts'):
- target = os.path.join(self.script_dir, script_name)
-
- log.info("Installing %s script to %s", script_name,self.script_dir)
-
- script_text = metadata.get_metadata('scripts/'+script_name)
- script_text = script_text.replace('\r','\n')
- first, rest = script_text.split('\n',1)
-
- match = first_line_re.match(first)
- options = ''
- if match:
- options = match.group(1) or ''
- if options:
- options = ' '+options
-
- spec = '%s==%s' % (dist.name,dist.version)
-
- script_text = '\n'.join([
- "#!%s%s" % (os.path.normpath(sys.executable),options),
- "# EASY-INSTALL-SCRIPT: %r,%r" % (spec, script_name),
- "import pkg_resources",
- "pkg_resources.run_main(%r, %r)" % (spec, script_name)
- ])
- if not self.dry_run:
- f = open(target,"w")
- f.write(script_text)
- f.close()
- try:
- os.chmod(target,0755)
- except (AttributeError, os.error):
- pass
-
-
- def install_eggs(self, dist_filename, zip_ok, tmpdir):
- # .egg dirs or files are already built, so just return them
- if dist_filename.lower().endswith('.egg'):
- return [self.install_egg(dist_filename, True, tmpdir)]
-
- if dist_filename.lower().endswith('.exe'):
- return [self.install_exe(dist_filename, tmpdir)]
-
- # Anything else, try to extract and build
- if os.path.isfile(dist_filename):
- unpack_archive(dist_filename, tmpdir, self.unpack_progress)
-
- # Find the setup.py file
- from glob import glob
- setup_script = os.path.join(tmpdir, 'setup.py')
- if not os.path.exists(setup_script):
- setups = glob(os.path.join(tmpdir, '*', 'setup.py'))
- if not setups:
- raise RuntimeError(
- "Couldn't find a setup script in %s" % dist_filename
- )
- if len(setups)>1:
- raise RuntimeError(
- "Multiple setup scripts in %s" % dist_filename
- )
- setup_script = setups[0]
-
- self.build_egg(tmpdir, setup_script)
- dist_dir = os.path.join(os.path.dirname(setup_script),'dist')
-
- eggs = []
- for egg in glob(os.path.join(dist_dir,'*.egg')):
- eggs.append(self.install_egg(egg, zip_ok, tmpdir))
-
- if not eggs and not self.dry_run:
- log.warn("No eggs found in %s (setup script problem?)", dist_dir)
-
- return eggs
-
-
-
- def egg_distribution(self, egg_path):
- if os.path.isdir(egg_path):
- metadata = PathMetadata(egg_path,os.path.join(egg_path,'EGG-INFO'))
- else:
- metadata = EggMetadata(zipimport.zipimporter(egg_path))
- return Distribution.from_filename(egg_path,metadata=metadata)
-
- def install_egg(self, egg_path, zip_ok, tmpdir):
- destination = os.path.join(self.install_dir,os.path.basename(egg_path))
- destination = os.path.abspath(destination)
-
- if not self.dry_run:
- ensure_directory(destination)
-
- if not samefile(egg_path, destination):
- if os.path.isdir(destination):
- dir_util.remove_tree(destination, dry_run=self.dry_run)
- elif os.path.isfile(destination):
- self.execute(os.unlink,(destination,),"Removing "+destination)
-
- if os.path.isdir(egg_path):
- if egg_path.startswith(tmpdir):
- f,m = shutil.move, "Moving"
- else:
- f,m = shutil.copytree, "Copying"
- elif zip_ok:
- if egg_path.startswith(tmpdir):
- f,m = shutil.move, "Moving"
- else:
- f,m = shutil.copy2, "Copying"
- else:
- self.mkpath(destination)
- f,m = self.unpack_and_compile, "Extracting"
-
- self.execute(f, (egg_path, destination),
- (m+" %s to %s") %
- (os.path.basename(egg_path),os.path.dirname(destination)))
-
- self.add_output(destination)
- return self.egg_distribution(destination)
-
- def install_exe(self, dist_filename, tmpdir):
- # See if it's valid, get data
- cfg = extract_wininst_cfg(dist_filename)
- if cfg is None:
- raise RuntimeError(
- "%s is not a valid distutils Windows .exe" % dist_filename
- )
-
- # Create a dummy distribution object until we build the real distro
- dist = Distribution(None,
- name=cfg.get('metadata','name'),
- version=cfg.get('metadata','version'),
- platform="win32"
- )
-
- # Convert the .exe to an unpacked egg
- egg_path = dist.path = os.path.join(tmpdir, dist.egg_name()+'.egg')
- egg_tmp = egg_path+'.tmp'
- self.exe_to_egg(dist_filename, egg_tmp)
-
- # Write EGG-INFO/PKG-INFO
- pkg_inf = os.path.join(egg_tmp, 'EGG-INFO', 'PKG-INFO')
- f = open(pkg_inf,'w')
- f.write('Metadata-Version: 1.0\n')
- for k,v in cfg.items('metadata'):
- if k<>'target_version':
- f.write('%s: %s\n' % (k.replace('_','-').title(), v))
- f.close()
-
- # Build .egg file from tmpdir
- bdist_egg.make_zipfile(
- egg_path, egg_tmp,
- verbose=self.verbose, dry_run=self.dry_run
- )
-
- # install the .egg
- return self.install_egg(egg_path, self.zip_ok, tmpdir)
-
-
-
-
- def exe_to_egg(self, dist_filename, egg_tmp):
- """Extract a bdist_wininst to the directories an egg would use"""
-
- # Check for .pth file and set up prefix translations
- prefixes = get_exe_prefixes(dist_filename)
- to_compile = []
- native_libs = []
-
- def process(src,dst):
- for old,new in prefixes:
- if src.startswith(old):
- src = new+src[len(old):]
- dst = os.path.join(egg_tmp, *src.split('/'))
- dl = dst.lower()
- if dl.endswith('.pyd') or dl.endswith('.dll'):
- native_libs.append(src)
- elif dl.endswith('.py') and old!='SCRIPTS/':
- to_compile.append(dst)
- return dst
- if not src.endswith('.pth'):
- log.warn("WARNING: can't process %s", src)
- return None
-
- # extract, tracking .pyd/.dll->native_libs and .py -> to_compile
- unpack_archive(dist_filename, egg_tmp, process)
-
- for res in native_libs:
- if res.lower().endswith('.pyd'): # create stubs for .pyd's
- parts = res.split('/')
- resource, parts[-1] = parts[-1], parts[-1][:-1]
- pyfile = os.path.join(egg_tmp, *parts)
- to_compile.append(pyfile)
- bdist_egg.write_stub(resource, pyfile)
-
- self.byte_compile(to_compile) # compile .py's
-
- if native_libs: # write EGG-INFO/native_libs.txt
- nl_txt = os.path.join(egg_tmp, 'EGG-INFO', 'native_libs.txt')
- ensure_directory(nl_txt)
- open(nl_txt,'w').write('\n'.join(native_libs)+'\n')
-
- def installation_report(self, dist, what="Installed"):
- """Helpful installation message for display to package users"""
-
- msg = "\n%(what)s %(eggloc)s"
- if self.multi_version:
- msg += """
-
-Because this distribution was installed --multi-version or --install-dir,
-before you can import modules from this package in an application, you
-will need to 'import pkg_resources' and then use a 'require()' call
-similar to one of these examples, in order to select the desired version:
-
- pkg_resources.require("%(name)s") # latest installed version
- pkg_resources.require("%(name)s==%(version)s") # this exact version
- pkg_resources.require("%(name)s>=%(version)s") # this version or higher
-"""
- if not samefile(get_python_lib(),self.install_dir):
- msg += """
-
-Note also that the installation directory must be on sys.path at runtime for
-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
- version = dist.version
- return msg % locals()
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- def build_egg(self, tmpdir, setup_script):
- sys.modules.setdefault('distutils.command.bdist_egg', bdist_egg)
-
- args = ['bdist_egg']
- if self.verbose>2:
- v = 'v' * self.verbose - 1
- args.insert(0,'-'+v)
- elif self.verbose<2:
- args.insert(0,'-q')
- if self.dry_run:
- args.insert(0,'-n')
-
- log.info("Running %s %s", setup_script[len(tmpdir)+1:], ' '.join(args))
- try:
- try:
- run_setup(setup_script, args)
- except SystemExit, v:
- raise RuntimeError(
- "Setup script exited with %s" % (v.args[0],)
- )
- finally:
- log.set_verbosity(self.verbose) # restore our log verbosity
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- def update_pth(self,dist):
- if self.pth_file is None:
- return
-
- for d in self.pth_file.get(dist.key,()): # drop old entries
- if self.multi_version or d.path != dist.path:
- log.info("Removing %s from easy-install.pth file", d)
- self.pth_file.remove(d)
- if d.path in self.shadow_path:
- self.shadow_path.remove(d.path)
-
- if not self.multi_version:
- if dist.path in self.pth_file.paths:
- log.info(
- "%s is already the active version in easy-install.pth",
- dist
- )
- else:
- log.info("Adding %s to easy-install.pth file", dist)
- self.pth_file.add(dist) # add new entry
- if dist.path not in self.shadow_path:
- self.shadow_path.append(dist.path)
-
- self.pth_file.save()
-
- if dist.name=='setuptools':
- # Ensure that setuptools itself never becomes unavailable!
- f = open(os.path.join(self.install_dir,'setuptools.pth'), 'w')
- f.write(dist.path+'\n')
- f.close()
-
-
- def unpack_progress(self, src, dst):
- # Progress filter for unpacking
- log.debug("Unpacking %s to %s", src, dst)
- return dst # only unpack-and-compile skips files for dry run
-
-
-
-
-
- def unpack_and_compile(self, egg_path, destination):
- to_compile = []
-
- def pf(src,dst):
- if dst.endswith('.py'):
- to_compile.append(dst)
- self.unpack_progress(src,dst)
- return not self.dry_run and dst or None
-
- unpack_archive(egg_path, destination, pf)
- self.byte_compile(to_compile)
-
-
- def byte_compile(self, to_compile):
- from distutils.util import byte_compile
- try:
- # try to make the byte compile messages quieter
- log.set_verbosity(self.verbose - 1)
-
- byte_compile(to_compile, optimize=0, force=1, dry_run=self.dry_run)
- if self.optimize:
- byte_compile(
- to_compile, optimize=self.optimize, force=1,
- dry_run=self.dry_run
- )
- finally:
- log.set_verbosity(self.verbose) # restore original verbosity
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-def extract_wininst_cfg(dist_filename):
- """Extract configuration data from a bdist_wininst .exe
-
- Returns a ConfigParser.RawConfigParser, or None
- """
- f = open(dist_filename,'rb')
- try:
- endrec = zipfile._EndRecData(f)
- if endrec is None:
- return None
-
- prepended = (endrec[9] - endrec[5]) - endrec[6]
- if prepended < 12: # no wininst data here
- return None
- f.seek(prepended-12)
-
- import struct, StringIO, ConfigParser
- tag, cfglen, bmlen = struct.unpack("<iii",f.read(12))
- if tag<>0x1234567A:
- return None # not a valid tag
-
- f.seek(prepended-(12+cfglen+bmlen))
- cfg = ConfigParser.RawConfigParser({'version':'','target_version':''})
- try:
- cfg.readfp(StringIO.StringIO(f.read(cfglen)))
- except ConfigParser.Error:
- return None
- if not cfg.has_section('metadata') or not cfg.has_section('Setup'):
- return None
- return cfg
-
- finally:
- f.close()
-
-
-
-
-
-
-
-
-def get_exe_prefixes(exe_filename):
- """Get exe->egg path translations for a given .exe file"""
-
- prefixes = [
- ('PURELIB/', ''),
- ('PLATLIB/', ''),
- ('SCRIPTS/', 'EGG-INFO/scripts/')
- ]
- z = zipfile.ZipFile(exe_filename)
- try:
- for info in z.infolist():
- name = info.filename
- if not name.endswith('.pth'):
- continue
- parts = name.split('/')
- if len(parts)<>2:
- continue
- if parts[0] in ('PURELIB','PLATLIB'):
- pth = z.read(name).strip()
- prefixes[0] = ('PURELIB/%s/' % pth), ''
- prefixes[1] = ('PLATLIB/%s/' % pth), ''
- break
- finally:
- z.close()
-
- return prefixes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-class PthDistributions(AvailableDistributions):
- """A .pth file with Distribution paths in it"""
-
- dirty = False
-
- def __init__(self, filename):
- self.filename = filename; self._load()
- AvailableDistributions.__init__(
- self, list(yield_lines(self.paths)), None, None
- )
-
- def _load(self):
- self.paths = []
- if os.path.isfile(self.filename):
- self.paths = [line.rstrip() for line in open(self.filename,'rt')]
- while self.paths and not self.paths[-1].strip(): self.paths.pop()
-
- def save(self):
- """Write changed .pth file back to disk"""
- if self.dirty:
- data = '\n'.join(self.paths+[''])
- f = open(self.filename,'wt')
- f.write(data)
- f.close()
- self.dirty = False
-
- def add(self,dist):
- """Add `dist` to the distribution map"""
- if dist.path not in self.paths:
- self.paths.append(dist.path); self.dirty = True
- AvailableDistributions.add(self,dist)
-
- def remove(self,dist):
- """Remove `dist` from the distribution map"""
- while dist.path in self.paths:
- self.paths.remove(dist.path); self.dirty = True
- AvailableDistributions.remove(self,dist)
-
-
-
-
-def main(argv, cmds={'easy_install':easy_install}):
- from setuptools import setup
- try:
- setup(cmdclass = cmds, script_args = ['-q','easy_install', '-v']+argv)
- except RuntimeError, v:
- print >>sys.stderr,"error:",v
- sys.exit(1)
-
+import sys
+from setuptools.command.easy_install import *
if __name__ == '__main__':
main(sys.argv[1:])
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Index: ez_setup.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/ez_setup.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- ez_setup.py 27 Jun 2005 00:31:02 -0000 1.7
+++ ez_setup.py 6 Jul 2005 02:10:48 -0000 1.8
@@ -132,7 +132,7 @@
try:
egg = download_setuptools(version, to_dir=tmpdir)
sys.path.insert(0,egg)
- from easy_install import main
+ from setuptools.command.easy_install import main
main(list(argv)+[egg])
finally:
shutil.rmtree(tmpdir)
@@ -146,12 +146,12 @@
try:
pkg_resources.require(req)
except pkg_resources.VersionConflict:
- from easy_install import main
+ from setuptools.command.easy_install import main
main(list(argv)+[req])
sys.exit(0) # try to force an exit
else:
if argv:
- from easy_install import main
+ from setuptools.command.easy_install import main
main(argv)
else:
print "Setuptools successfully installed or upgraded."
Index: setup.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setup.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- setup.py 27 Jun 2005 00:31:02 -0000 1.17
+++ setup.py 6 Jul 2005 02:10:48 -0000 1.18
@@ -40,7 +40,7 @@
packages = find_packages(),
- py_modules = ['pkg_resources', 'easy_install'],
+ py_modules = ['pkg_resources'],
scripts = ['easy_install.py'],
classifiers = [f.strip() for f in """
1
0
[Python-checkins] python/nondist/sandbox/setuptools/setuptools/command easy_install.py, NONE, 1.1
by pje@users.sourceforge.net July 6, 2005
by pje@users.sourceforge.net July 6, 2005
July 6, 2005
Update of /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29898/setuptools/command
Added Files:
easy_install.py
Log Message:
Made ``easy_install`` a standard ``setuptools`` command, moving it from
the ``easy_install`` module to ``setuptools.command.easy_install``. Note
that if you were importing or extending it, you must now change your
imports accordingly. ``easy_install.py`` is still installed as a script,
but not as a module.
--- NEW FILE: easy_install.py ---
#!python
"""\
Easy Install
------------
A tool for doing automatic download/extract/build of distutils-based Python
packages. For detailed documentation, see the accompanying EasyInstall.txt
file, or visit the `EasyInstall home page`__.
__ http://peak.telecommunity.com/DevCenter/EasyInstall
"""
import sys, os.path, zipimport, shutil, tempfile, zipfile
from setuptools import Command
from setuptools.sandbox import run_setup
from distutils import log, dir_util
from distutils.sysconfig import get_python_lib
from distutils.errors import DistutilsArgError, DistutilsOptionError
from setuptools.archive_util import unpack_archive
from setuptools.package_index import PackageIndex, parse_bdist_wininst
from setuptools.package_index import URL_SCHEME
from setuptools.command import bdist_egg
from pkg_resources import *
__all__ = [
'samefile', 'easy_install', 'PthDistributions', 'extract_wininst_cfg',
'main', 'get_exe_prefixes',
]
def samefile(p1,p2):
if hasattr(os.path,'samefile') and (
os.path.exists(p1) and os.path.exists(p2)
):
return os.path.samefile(p1,p2)
return (
os.path.normpath(os.path.normcase(p1)) ==
os.path.normpath(os.path.normcase(p2))
)
class easy_install(Command):
"""Manage a download/build/install process"""
description = "Find/get/install Python packages"
command_consumes_arguments = True
user_options = [
("zip-ok", "z", "install package as a zipfile"),
("multi-version", "m", "make apps have to require() a version"),
("upgrade", "U", "force upgrade (searches PyPI for latest versions)"),
("install-dir=", "d", "install package to DIR"),
("script-dir=", "s", "install scripts to DIR"),
("exclude-scripts", "x", "Don't install scripts"),
("always-copy", "a", "Copy all needed packages to install dir"),
("index-url=", "i", "base URL of Python Package Index"),
("find-links=", "f", "additional URL(s) to search for packages"),
("build-directory=", "b",
"download/extract/build in DIR; keep the results"),
('optimize=', 'O',
"also compile with optimization: -O1 for \"python -O\", "
"-O2 for \"python -OO\", and -O0 to disable [default: -O0]"),
('record=', None,
"filename in which to record list of installed files"),
]
boolean_options = [
'zip-ok', 'multi-version', 'exclude-scripts', 'upgrade', 'always-copy'
]
create_index = PackageIndex
def initialize_options(self):
self.zip_ok = None
self.install_dir = self.script_dir = self.exclude_scripts = None
self.index_url = None
self.find_links = None
self.build_directory = None
self.args = None
self.optimize = self.record = None
self.upgrade = self.always_copy = self.multi_version = None
# Options not specifiable via command line
self.package_index = None
self.pth_file = None
def finalize_options(self):
# If a non-default installation directory was specified, default the
# script directory to match it.
if self.script_dir is None:
self.script_dir = self.install_dir
# Let install_dir get set by install_lib command, which in turn
# gets its info from the install command, and takes into account
# --prefix and --home and all that other crud.
self.set_undefined_options('install_lib',
('install_dir','install_dir')
)
# Likewise, set default script_dir from 'install_scripts.install_dir'
self.set_undefined_options('install_scripts',
('install_dir', 'script_dir')
)
# default --record from the install command
self.set_undefined_options('install', ('record', 'record'))
site_packages = get_python_lib()
instdir = self.install_dir
if instdir is None or samefile(site_packages,instdir):
instdir = site_packages
if self.pth_file is None:
self.pth_file = PthDistributions(
os.path.join(instdir,'easy-install.pth')
)
self.install_dir = instdir
elif self.multi_version is None:
self.multi_version = True
elif not self.multi_version:
# explicit false set from Python code; raise an error
raise DistutilsArgError(
"Can't do single-version installs outside site-packages"
)
self.index_url = self.index_url or "http://www.python.org/pypi"
self.shadow_path = sys.path[:]
for path_item in self.install_dir, self.script_dir:
if path_item not in self.shadow_path:
self.shadow_path.insert(0, self.install_dir)
if self.package_index is None:
self.package_index = self.create_index(
self.index_url, search_path = self.shadow_path
)
self.local_index = AvailableDistributions(self.shadow_path)
if self.find_links is not None:
if isinstance(self.find_links, basestring):
self.find_links = self.find_links.split()
else:
self.find_links = []
self.set_undefined_options('install_lib', ('optimize','optimize'))
if not isinstance(self.optimize,int):
try:
self.optimize = int(self.optimize)
if not (0 <= self.optimize <= 2): raise ValueError
except ValueError:
raise DistutilsOptionError("--optimize must be 0, 1, or 2")
if not self.args:
raise DistutilsArgError(
"No urls, filenames, or requirements specified (see --help)")
elif len(self.args)>1 and self.build_directory is not None:
raise DistutilsArgError(
"Build directory can only be set when using one URL"
)
self.outputs = []
def alloc_tmp(self):
if self.build_directory is None:
return tempfile.mkdtemp(prefix="easy_install-")
tmpdir = os.path.realpath(self.build_directory)
if not os.path.isdir(tmpdir):
os.makedirs(tmpdir)
return tmpdir
def run(self):
if self.verbose<>self.distribution.verbose:
log.set_verbosity(self.verbose)
try:
for link in self.find_links:
self.package_index.scan_url(link)
for spec in self.args:
self.easy_install(spec)
if self.record:
from distutils import file_util
self.execute(
file_util.write_file, (self.record, self.outputs),
"writing list of installed files to '%s'" %
self.record
)
finally:
log.set_verbosity(self.distribution.verbose)
def add_output(self, path):
if os.path.isdir(path):
for base, dirs, files in os.walk(path):
for filename in files:
self.outputs.append(os.path.join(base,filename))
else:
self.outputs.append(path)
def easy_install(self, spec):
tmpdir = self.alloc_tmp()
download = None
try:
if not isinstance(spec,Requirement):
if URL_SCHEME(spec):
# It's a url, download it to tmpdir and process
download = self.package_index.download(spec, tmpdir)
return self.install_item(None, download, tmpdir, True)
elif os.path.exists(spec):
# Existing file or directory, just process it directly
return self.install_item(None, spec, tmpdir, True)
else:
try:
spec = Requirement.parse(spec)
except ValueError:
raise RuntimeError(
"Not a URL, existing file, or requirement spec: %r"
% (spec,)
)
if isinstance(spec, Requirement):
download = self.package_index.fetch(spec, tmpdir, self.upgrade)
else:
spec = None
if download is None:
raise RuntimeError(
"Could not find distribution for %r" % spec
)
return self.install_item(spec, download, tmpdir)
finally:
if self.build_directory is None:
shutil.rmtree(tmpdir)
def install_item(self, spec, download, tmpdir, install_needed=False):
# Installation is also needed if file in tmpdir or is not an egg
install_needed = install_needed or os.path.dirname(download) == tmpdir
install_needed = install_needed or not download.endswith('.egg')
log.info("Processing %s", os.path.basename(download))
if install_needed or self.always_copy:
dists = self.install_eggs(download, self.zip_ok, tmpdir)
for dist in dists:
self.process_distribution(spec, dist)
else:
dists = [self.egg_distribution(download)]
self.process_distribution(spec, dists[0], "Using")
if spec is not None:
for dist in dists:
if dist in spec:
return dist
def process_distribution(self, requirement, dist, *info):
self.update_pth(dist)
self.package_index.add(dist)
self.local_index.add(dist)
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))
if dist in requirement:
log.info("Processing dependencies for %s", requirement)
try:
self.local_index.resolve(
[requirement], self.shadow_path, self.easy_install
)
except DistributionNotFound, e:
raise RuntimeError(
"Could not find required distribution %s" % e.args
)
except VersionConflict, e:
raise RuntimeError(
"Installed distribution %s conflicts with requirement %s"
% e.args
)
def install_egg_scripts(self, dist):
metadata = dist.metadata
if self.exclude_scripts or not metadata.metadata_isdir('scripts'):
return
from distutils.command.build_scripts import first_line_re
for script_name in metadata.metadata_listdir('scripts'):
target = os.path.join(self.script_dir, script_name)
log.info("Installing %s script to %s", script_name,self.script_dir)
script_text = metadata.get_metadata('scripts/'+script_name)
script_text = script_text.replace('\r','\n')
first, rest = script_text.split('\n',1)
match = first_line_re.match(first)
options = ''
if match:
options = match.group(1) or ''
if options:
options = ' '+options
spec = '%s==%s' % (dist.name,dist.version)
script_text = '\n'.join([
"#!%s%s" % (os.path.normpath(sys.executable),options),
"# EASY-INSTALL-SCRIPT: %r,%r" % (spec, script_name),
"import pkg_resources",
"pkg_resources.run_main(%r, %r)" % (spec, script_name)
])
if not self.dry_run:
f = open(target,"w")
f.write(script_text)
f.close()
try:
os.chmod(target,0755)
except (AttributeError, os.error):
pass
def install_eggs(self, dist_filename, zip_ok, tmpdir):
# .egg dirs or files are already built, so just return them
if dist_filename.lower().endswith('.egg'):
return [self.install_egg(dist_filename, True, tmpdir)]
if dist_filename.lower().endswith('.exe'):
return [self.install_exe(dist_filename, tmpdir)]
# Anything else, try to extract and build
if os.path.isfile(dist_filename):
unpack_archive(dist_filename, tmpdir, self.unpack_progress)
# Find the setup.py file
from glob import glob
setup_script = os.path.join(tmpdir, 'setup.py')
if not os.path.exists(setup_script):
setups = glob(os.path.join(tmpdir, '*', 'setup.py'))
if not setups:
raise RuntimeError(
"Couldn't find a setup script in %s" % dist_filename
)
if len(setups)>1:
raise RuntimeError(
"Multiple setup scripts in %s" % dist_filename
)
setup_script = setups[0]
self.build_egg(tmpdir, setup_script)
dist_dir = os.path.join(os.path.dirname(setup_script),'dist')
eggs = []
for egg in glob(os.path.join(dist_dir,'*.egg')):
eggs.append(self.install_egg(egg, zip_ok, tmpdir))
if not eggs and not self.dry_run:
log.warn("No eggs found in %s (setup script problem?)", dist_dir)
return eggs
def egg_distribution(self, egg_path):
if os.path.isdir(egg_path):
metadata = PathMetadata(egg_path,os.path.join(egg_path,'EGG-INFO'))
else:
metadata = EggMetadata(zipimport.zipimporter(egg_path))
return Distribution.from_filename(egg_path,metadata=metadata)
def install_egg(self, egg_path, zip_ok, tmpdir):
destination = os.path.join(self.install_dir,os.path.basename(egg_path))
destination = os.path.abspath(destination)
if not self.dry_run:
ensure_directory(destination)
if not samefile(egg_path, destination):
if os.path.isdir(destination):
dir_util.remove_tree(destination, dry_run=self.dry_run)
elif os.path.isfile(destination):
self.execute(os.unlink,(destination,),"Removing "+destination)
if os.path.isdir(egg_path):
if egg_path.startswith(tmpdir):
f,m = shutil.move, "Moving"
else:
f,m = shutil.copytree, "Copying"
elif zip_ok:
if egg_path.startswith(tmpdir):
f,m = shutil.move, "Moving"
else:
f,m = shutil.copy2, "Copying"
else:
self.mkpath(destination)
f,m = self.unpack_and_compile, "Extracting"
self.execute(f, (egg_path, destination),
(m+" %s to %s") %
(os.path.basename(egg_path),os.path.dirname(destination)))
self.add_output(destination)
return self.egg_distribution(destination)
def install_exe(self, dist_filename, tmpdir):
# See if it's valid, get data
cfg = extract_wininst_cfg(dist_filename)
if cfg is None:
raise RuntimeError(
"%s is not a valid distutils Windows .exe" % dist_filename
)
# Create a dummy distribution object until we build the real distro
dist = Distribution(None,
name=cfg.get('metadata','name'),
version=cfg.get('metadata','version'),
platform="win32"
)
# Convert the .exe to an unpacked egg
egg_path = dist.path = os.path.join(tmpdir, dist.egg_name()+'.egg')
egg_tmp = egg_path+'.tmp'
self.exe_to_egg(dist_filename, egg_tmp)
# Write EGG-INFO/PKG-INFO
pkg_inf = os.path.join(egg_tmp, 'EGG-INFO', 'PKG-INFO')
f = open(pkg_inf,'w')
f.write('Metadata-Version: 1.0\n')
for k,v in cfg.items('metadata'):
if k<>'target_version':
f.write('%s: %s\n' % (k.replace('_','-').title(), v))
f.close()
# Build .egg file from tmpdir
bdist_egg.make_zipfile(
egg_path, egg_tmp,
verbose=self.verbose, dry_run=self.dry_run
)
# install the .egg
return self.install_egg(egg_path, self.zip_ok, tmpdir)
def exe_to_egg(self, dist_filename, egg_tmp):
"""Extract a bdist_wininst to the directories an egg would use"""
# Check for .pth file and set up prefix translations
prefixes = get_exe_prefixes(dist_filename)
to_compile = []
native_libs = []
def process(src,dst):
for old,new in prefixes:
if src.startswith(old):
src = new+src[len(old):]
dst = os.path.join(egg_tmp, *src.split('/'))
dl = dst.lower()
if dl.endswith('.pyd') or dl.endswith('.dll'):
native_libs.append(src)
elif dl.endswith('.py') and old!='SCRIPTS/':
to_compile.append(dst)
return dst
if not src.endswith('.pth'):
log.warn("WARNING: can't process %s", src)
return None
# extract, tracking .pyd/.dll->native_libs and .py -> to_compile
unpack_archive(dist_filename, egg_tmp, process)
for res in native_libs:
if res.lower().endswith('.pyd'): # create stubs for .pyd's
parts = res.split('/')
resource, parts[-1] = parts[-1], parts[-1][:-1]
pyfile = os.path.join(egg_tmp, *parts)
to_compile.append(pyfile)
bdist_egg.write_stub(resource, pyfile)
self.byte_compile(to_compile) # compile .py's
if native_libs: # write EGG-INFO/native_libs.txt
nl_txt = os.path.join(egg_tmp, 'EGG-INFO', 'native_libs.txt')
ensure_directory(nl_txt)
open(nl_txt,'w').write('\n'.join(native_libs)+'\n')
def installation_report(self, dist, what="Installed"):
"""Helpful installation message for display to package users"""
msg = "\n%(what)s %(eggloc)s"
if self.multi_version:
msg += """
Because this distribution was installed --multi-version or --install-dir,
before you can import modules from this package in an application, you
will need to 'import pkg_resources' and then use a 'require()' call
similar to one of these examples, in order to select the desired version:
pkg_resources.require("%(name)s") # latest installed version
pkg_resources.require("%(name)s==%(version)s") # this exact version
pkg_resources.require("%(name)s>=%(version)s") # this version or higher
"""
if not samefile(get_python_lib(),self.install_dir):
msg += """
Note also that the installation directory must be on sys.path at runtime for
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
version = dist.version
return msg % locals()
def build_egg(self, tmpdir, setup_script):
sys.modules.setdefault('distutils.command.bdist_egg', bdist_egg)
args = ['bdist_egg']
if self.verbose>2:
v = 'v' * self.verbose - 1
args.insert(0,'-'+v)
elif self.verbose<2:
args.insert(0,'-q')
if self.dry_run:
args.insert(0,'-n')
log.info("Running %s %s", setup_script[len(tmpdir)+1:], ' '.join(args))
try:
try:
run_setup(setup_script, args)
except SystemExit, v:
raise RuntimeError(
"Setup script exited with %s" % (v.args[0],)
)
finally:
log.set_verbosity(self.verbose) # restore our log verbosity
def update_pth(self,dist):
if self.pth_file is None:
return
for d in self.pth_file.get(dist.key,()): # drop old entries
if self.multi_version or d.path != dist.path:
log.info("Removing %s from easy-install.pth file", d)
self.pth_file.remove(d)
if d.path in self.shadow_path:
self.shadow_path.remove(d.path)
if not self.multi_version:
if dist.path in self.pth_file.paths:
log.info(
"%s is already the active version in easy-install.pth",
dist
)
else:
log.info("Adding %s to easy-install.pth file", dist)
self.pth_file.add(dist) # add new entry
if dist.path not in self.shadow_path:
self.shadow_path.append(dist.path)
self.pth_file.save()
if dist.name=='setuptools':
# Ensure that setuptools itself never becomes unavailable!
f = open(os.path.join(self.install_dir,'setuptools.pth'), 'w')
f.write(dist.path+'\n')
f.close()
def unpack_progress(self, src, dst):
# Progress filter for unpacking
log.debug("Unpacking %s to %s", src, dst)
return dst # only unpack-and-compile skips files for dry run
def unpack_and_compile(self, egg_path, destination):
to_compile = []
def pf(src,dst):
if dst.endswith('.py'):
to_compile.append(dst)
self.unpack_progress(src,dst)
return not self.dry_run and dst or None
unpack_archive(egg_path, destination, pf)
self.byte_compile(to_compile)
def byte_compile(self, to_compile):
from distutils.util import byte_compile
try:
# try to make the byte compile messages quieter
log.set_verbosity(self.verbose - 1)
byte_compile(to_compile, optimize=0, force=1, dry_run=self.dry_run)
if self.optimize:
byte_compile(
to_compile, optimize=self.optimize, force=1,
dry_run=self.dry_run
)
finally:
log.set_verbosity(self.verbose) # restore original verbosity
def extract_wininst_cfg(dist_filename):
"""Extract configuration data from a bdist_wininst .exe
Returns a ConfigParser.RawConfigParser, or None
"""
f = open(dist_filename,'rb')
try:
endrec = zipfile._EndRecData(f)
if endrec is None:
return None
prepended = (endrec[9] - endrec[5]) - endrec[6]
if prepended < 12: # no wininst data here
return None
f.seek(prepended-12)
import struct, StringIO, ConfigParser
tag, cfglen, bmlen = struct.unpack("<iii",f.read(12))
if tag<>0x1234567A:
return None # not a valid tag
f.seek(prepended-(12+cfglen+bmlen))
cfg = ConfigParser.RawConfigParser({'version':'','target_version':''})
try:
cfg.readfp(StringIO.StringIO(f.read(cfglen)))
except ConfigParser.Error:
return None
if not cfg.has_section('metadata') or not cfg.has_section('Setup'):
return None
return cfg
finally:
f.close()
def get_exe_prefixes(exe_filename):
"""Get exe->egg path translations for a given .exe file"""
prefixes = [
('PURELIB/', ''),
('PLATLIB/', ''),
('SCRIPTS/', 'EGG-INFO/scripts/')
]
z = zipfile.ZipFile(exe_filename)
try:
for info in z.infolist():
name = info.filename
if not name.endswith('.pth'):
continue
parts = name.split('/')
if len(parts)<>2:
continue
if parts[0] in ('PURELIB','PLATLIB'):
pth = z.read(name).strip()
prefixes[0] = ('PURELIB/%s/' % pth), ''
prefixes[1] = ('PLATLIB/%s/' % pth), ''
break
finally:
z.close()
return prefixes
class PthDistributions(AvailableDistributions):
"""A .pth file with Distribution paths in it"""
dirty = False
def __init__(self, filename):
self.filename = filename; self._load()
AvailableDistributions.__init__(
self, list(yield_lines(self.paths)), None, None
)
def _load(self):
self.paths = []
if os.path.isfile(self.filename):
self.paths = [line.rstrip() for line in open(self.filename,'rt')]
while self.paths and not self.paths[-1].strip(): self.paths.pop()
def save(self):
"""Write changed .pth file back to disk"""
if self.dirty:
data = '\n'.join(self.paths+[''])
f = open(self.filename,'wt')
f.write(data)
f.close()
self.dirty = False
def add(self,dist):
"""Add `dist` to the distribution map"""
if dist.path not in self.paths:
self.paths.append(dist.path); self.dirty = True
AvailableDistributions.add(self,dist)
def remove(self,dist):
"""Remove `dist` from the distribution map"""
while dist.path in self.paths:
self.paths.remove(dist.path); self.dirty = True
AvailableDistributions.remove(self,dist)
def main(argv, **kw):
from setuptools import setup
try:
setup(script_args = ['-q','easy_install', '-v']+argv, **kw)
except RuntimeError, v:
print >>sys.stderr,"error:",v
sys.exit(1)
1
0
[Python-checkins] python/nondist/sandbox/setuptools/setuptools/command test.py, 1.1, 1.2
by pje@users.sourceforge.net July 6, 2005
by pje@users.sourceforge.net July 6, 2005
July 6, 2005
Update of /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21756/setuptools/command
Modified Files:
test.py
Log Message:
Enhanced the ``test`` command so that it doesn't install the package, but
instead builds any C extensions in-place, updates the ``.egg-info``
metadata, adds the source directory to ``sys.path``, and runs the tests
directly on the source. This avoids an "unmanaged" installation of the
package to ``site-packages`` or elsewhere. (Also, fix a breaking test of
older dependency support; this should probably be removed altogether, as
long as nobody's using it.)
Index: test.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command/test.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- test.py 19 Mar 2004 20:53:14 -0000 1.1
+++ test.py 6 Jul 2005 01:54:07 -0000 1.2
@@ -1,4 +1,4 @@
-from distutils.cmd import Command
+from setuptools import Command
from distutils.errors import DistutilsOptionError
import sys
@@ -40,35 +40,35 @@
def run(self):
+ # Ensure metadata is up-to-date
+ self.run_command('egg_info')
- # Install before testing
- self.run_command('install')
+ # Build extensions in-place
+ self.reinitialize_command('build_ext', inplace=1)
+ self.run_command('build_ext')
if self.test_suite:
cmd = ' '.join(self.test_args)
-
if self.dry_run:
self.announce('skipping "unittest %s" (dry run)' % cmd)
else:
self.announce('running "unittest %s"' % cmd)
- import unittest
- unittest.main(None, None, [unittest.__file__]+self.test_args)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ self.run_tests()
+ def run_tests(self):
+ import unittest, pkg_resources
+ old_path = sys.path[:]
+ ei_cmd = self.get_finalized_command("egg_info")
+ try:
+ # put the egg on sys.path, and require() it
+ sys.path.insert(0, ei_cmd.egg_base)
+ pkg_resources.require(
+ "%s==%s" % (ei_cmd.egg_name, ei_cmd.egg_version)
+ )
+ unittest.main(None, None, [unittest.__file__]+self.test_args)
+ finally:
+ sys.path[:] = old_path
+ # XXX later this might need to save/restore the WorkingSet
1
0
python/nondist/sandbox/setuptools EasyInstall.txt, 1.18, 1.19
by pje@users.sourceforge.net July 6, 2005
by pje@users.sourceforge.net July 6, 2005
July 6, 2005
Update of /cvsroot/python/python/nondist/sandbox/setuptools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21756
Modified Files:
EasyInstall.txt
Log Message:
Enhanced the ``test`` command so that it doesn't install the package, but
instead builds any C extensions in-place, updates the ``.egg-info``
metadata, adds the source directory to ``sys.path``, and runs the tests
directly on the source. This avoids an "unmanaged" installation of the
package to ``site-packages`` or elsewhere. (Also, fix a breaking test of
older dependency support; this should probably be removed altogether, as
long as nobody's using it.)
Index: EasyInstall.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/EasyInstall.txt,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- EasyInstall.txt 6 Jul 2005 01:37:41 -0000 1.18
+++ EasyInstall.txt 6 Jul 2005 01:54:07 -0000 1.19
@@ -484,8 +484,14 @@
0.5a5
* Added ``egg_info`` command to ``setuptools``-based packages. This command
just creates or updates the "projectname.egg-info" directory, without
- building an egg. It's used by the ``bdist_egg`` command now, and will be
- used by the ``test`` and ``develop`` commands later on.
+ building an egg. It's used by the ``bdist_egg`` and ``test`` commands now,
+ and will be used by the ``develop`` command later on.
+
+ * Enhanced the ``test`` command so that it doesn't install the package, but
+ instead builds any C extensions in-place, updates the ``.egg-info``
+ metadata, adds the source directory to ``sys.path``, and runs the tests
+ directly on the source. This avoids an "unmanaged" installation of the
+ package to ``site-packages`` or elsewhere.
0.5a4
* Added ``--always-copy/-a`` option to always copy needed packages to the
1
0
python/nondist/sandbox/setuptools/setuptools/tests __init__.py, 1.6, 1.7
by pje@users.sourceforge.net July 6, 2005
by pje@users.sourceforge.net July 6, 2005
July 6, 2005
Update of /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/tests
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21756/setuptools/tests
Modified Files:
__init__.py
Log Message:
Enhanced the ``test`` command so that it doesn't install the package, but
instead builds any C extensions in-place, updates the ``.egg-info``
metadata, adds the source directory to ``sys.path``, and runs the tests
directly on the source. This avoids an "unmanaged" installation of the
package to ``site-packages`` or elsewhere. (Also, fix a breaking test of
older dependency support; this should probably be removed altogether, as
long as nobody's using it.)
Index: __init__.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/tests/__init__.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- __init__.py 2 Apr 2005 02:43:21 -0000 1.6
+++ __init__.py 6 Jul 2005 01:54:08 -0000 1.7
@@ -122,19 +122,19 @@
def testDependsCmd(self):
- path1 = convert_path('foo/bar/baz')
- path2 = convert_path('foo/bar/baz/spam')
+ path = convert_path('foo/bar/baz')
dist = makeSetup(
- extra_path='spam',
- script_args=['install','--install-lib',path1]
+ script_args=['install','--install-lib',path]
)
cmd = dist.get_command_obj('depends')
cmd.ensure_finalized()
self.assertEqual(cmd.temp, dist.get_command_obj('build').build_temp)
- self.assertEqual(cmd.search_path, [path2,path1]+sys.path)
+ self.assertEqual(cmd.search_path, [path+os.path.sep,path]+sys.path)
+
+
1
0
python/nondist/sandbox/setuptools EasyInstall.txt, 1.17, 1.18
by pje@users.sourceforge.net July 6, 2005
by pje@users.sourceforge.net July 6, 2005
July 6, 2005
Update of /cvsroot/python/python/nondist/sandbox/setuptools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12500
Modified Files:
EasyInstall.txt
Log Message:
Added ``egg_info`` command to ``setuptools``-based packages. This command
just creates or updates the "projectname.egg-info" directory, without
building an egg. It's used by the ``bdist_egg`` command now, and will be
used by the ``test`` and ``develop`` commands later on.
Index: EasyInstall.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/EasyInstall.txt,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- EasyInstall.txt 4 Jul 2005 18:44:26 -0000 1.17
+++ EasyInstall.txt 6 Jul 2005 01:37:41 -0000 1.18
@@ -481,6 +481,12 @@
* There's no automatic retry for borked Sourceforge mirrors, which can easily
time out or be missing a file.
+0.5a5
+ * Added ``egg_info`` command to ``setuptools``-based packages. This command
+ just creates or updates the "projectname.egg-info" directory, without
+ building an egg. It's used by the ``bdist_egg`` command now, and will be
+ used by the ``test`` and ``develop`` commands later on.
+
0.5a4
* Added ``--always-copy/-a`` option to always copy needed packages to the
installation directory, even if they're already present elsewhere on
1
0