if __name__ == '__main__':
from setuptools.command.easy_install import main
main()
-
# Exceptions
'ResolutionError','VersionConflict','DistributionNotFound','UnknownExtra',
'ExtractionError',
-
+
# Parsing functions and string utilities
'parse_requirements', 'parse_version', 'safe_name', 'safe_version',
'get_platform', 'compatible_platforms', 'yield_lines', 'split_sections',
old_exc = sys.exc_info()[1]
cache_path = self.extraction_path or get_default_cache()
-
+
err = ExtractionError("""Can't extract file(s) to egg cache
The following error occurred while trying to extract file(s) to the Python egg
ensure_directory(target_path)
except:
self.extraction_error()
-
+
self.cached_files[target_path] = 1
return target_path
try:
rename(tmpnam, real_path)
-
- except os.error:
+
+ except os.error:
if os.path.isfile(real_path):
stat = os.stat(real_path)
-
+
if stat.st_size==size and stat.st_mtime==timestamp:
# size and stamp match, somebody did it just ahead of
# us, so we're done
# calling ``require()``) will get activated as well.
add_activation_listener(lambda dist: dist.activate())
working_set.entries=[]; map(working_set.add_entry,sys.path) # match order
-
class cls(cls,object): pass
mro = cls.__mro__[1:]
except TypeError:
- mro = object, # must be an ExtensionClass or some such :(
+ mro = object, # must be an ExtensionClass or some such :(
for t in mro:
if t in registry:
return registry[t](*args,**kw)
wrapper.__dict__ = func.__dict__
wrapper.__doc__ = func.__doc__
wrapper.register = register
- return wrapper
+ return wrapper
def walk_packages(path=None, prefix='', onerror=None):
modname = inspect.getmodulename(fn)
if modname=='__init__' or modname in yielded:
continue
-
+
path = os.path.join(self.path, fn)
ispkg = False
try:
import zipimport
from zipimport import zipimporter
-
+
def iter_zipimport_modules(importer, prefix=''):
dirlist = zipimport._zip_directory_cache[importer.archive].keys()
dirlist.sort()
return out
setup = distutils.core.setup
-
+
_Command = _get_unpatched(_Command)
class Command(_Command):
_Command.__init__(self,dist)
for k,v in kw.items():
setattr(self,k,v)
-
+
def reinitialize_command(self, command, reinit_subcommands=0, **kw):
cmd = _Command.reinitialize_command(self, command, reinit_subcommands)
for k,v in kw.items():
import distutils.core
distutils.core.Command = Command # we can't patch distutils.cmd, alas
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
"""Couldn't recognize the archive type"""
def default_filter(src,dst):
- """The default progress/filter callback; returns True for all files"""
+ """The default progress/filter callback; returns True for all files"""
return dst
name = member.name
# don't extract absolute paths or ones with .. in them
if not name.startswith('/') and '..' not in name:
- dst = os.path.join(extract_dir, *name.split('/'))
+ dst = os.path.join(extract_dir, *name.split('/'))
dst = progress_filter(name, dst)
if dst:
if dst.endswith(os.sep):
extraction_drivers = unpack_directory, unpack_zipfile, unpack_tarfile
-
-
-
-
-
if sys.version>='2.5':
# In Python 2.5 and above, distutils includes its own upload command
__all__.remove('upload')
-
+
from distutils.command.bdist import bdist
if c in arg: return repr(arg)
if arg.split()<>[arg]:
return repr(arg)
- return arg
+ return arg
class alias(option_base):
"""Define a shortcut that invokes one or more commands"""
-
+
description = "define a shortcut to invoke one or more commands"
command_consumes_arguments = True
user_options = [
- ('remove', 'r', 'remove (unset) the alias'),
+ ('remove', 'r', 'remove (unset) the alias'),
] + option_base.user_options
boolean_options = option_base.boolean_options + ['remove']
else:
source = '--filename=%r' % source
return source+name+' '+command
-
-
-
if self.exclude_source_files:
self.zap_pyfiles()
-
+
# Make the archive
make_zipfile(self.egg_output, archive_root, verbose=self.verbose,
dry_run=self.dry_run)
def make_init_files(self):
"""Create missing package __init__ files"""
- init_files = []
+ init_files = []
for base,dirs,files in walk_egg(self.bdist_dir):
if base==self.bdist_dir:
# don't put an __init__ in the root
filename = os.path.join(base,'__init__.py')
if not self.dry_run:
f = open(filename,'w'); f.write(NS_PKG_STUB)
- f.close()
+ f.close()
init_files.append(filename)
break
else:
def walk_egg(egg_dir):
"""Walk an unpacked egg's contents, skipping the metadata directory"""
walker = os.walk(egg_dir)
- base,dirs,files = walker.next()
+ base,dirs,files = walker.next()
if 'EGG-INFO' in dirs:
dirs.remove('EGG-INFO')
yield base,dirs,files
os.path.walk(base_dir, visit, None)
return zip_filename
-
-
]
spec.insert(spec.index(line24)+1, "%define unmangled_version "+version)
return spec
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
self.create_static_lib(
objects, basename, output_dir, debug, target_lang
)
-
-
ei_cmd = self.get_finalized_command('egg_info')
for path in ei_cmd.filelist.files:
if path.endswith('.py'):
- continue
+ continue
d,f = os.path.split(assert_relative(path))
prev = None
while d and d!=prev and d not in src_dirs:
f = open(init_py,'rU')
if 'declare_namespace' not in f.read():
- from distutils.errors import DistutilsError
+ from distutils.errors import DistutilsError
raise DistutilsError(
"Namespace package problem: %s is a namespace package, but its\n"
"__init__.py does not call declare_namespace()! Please fix it.\n"
globs = (self.exclude_package_data.get('', [])
+ self.exclude_package_data.get(package, []))
bad = []
- for pattern in globs:
+ for pattern in globs:
bad.extend(
fnmatch.filter(
files, os.path.join(src_dir, convert_path(pattern))
setup.py directory, *never* absolute paths.
""" % path
)
-
-
-
-
-
-
-
-
-
-
-
-
-
"Please rename %r to %r before using 'develop'"
% (ei.egg_info, ei.broken_egg_info)
)
- self.args = [ei.egg_name]
+ 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
# create wrapper scripts in the script dir, pointing to dist.scripts
# new-style...
- self.install_wrapper_scripts(dist)
+ self.install_wrapper_scripts(dist)
# ...and old-style
for script_name in self.distribution.scripts or []:
script_text = f.read()
f.close()
self.install_script(dist, script_name, script_text, script_path)
-
-
-
-
-
-
-
"""Write changed .pth file back to disk"""
if not self.dirty:
return
-
+
data = '\n'.join(map(self.make_relative,self.paths))
if data:
log.debug("Saving %s", self.filename)
del zdc[p]
return
-
+
def get_script_args(dist, executable=sys_executable):
"""Yield write_script() argument tuples for a distribution's entrypoints"""
spec = str(dist.as_requirement())
distclass=DistributionWithoutHelpCommands, **kw
)
)
-
-
-
-
-
if match:
return int(match.group(1))
return 0
-
-
-
-
caller = sys._getframe(2)
caller_module = caller.f_globals.get('__name__','')
caller_name = caller.f_code.co_name
-
+
if caller_module != 'distutils.dist' or caller_name!='run_commands':
# We weren't called from the command line or setup(), so we
# should run in backward-compatibility mode to support bdist_*
_install.run(self)
else:
self.do_egg_install()
-
+
cmd.args = args
cmd.run()
setuptools.bootstrap_install_from = None
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
None, None, ei_cmd.egg_name, ei_cmd.egg_version
).egg_name()+'.egg-info'
self.source = ei_cmd.egg_info
- self.target = os.path.join(self.install_dir, basename)
+ self.target = os.path.join(self.install_dir, basename)
self.outputs = [self.target]
def run(self):
return self.outputs
def copytree(self):
- # Copy the .egg-info tree to site-packages
+ # Copy the .egg-info tree to site-packages
def skimmer(src,dst):
# filter out source-control directories; note that 'src' is always
# a '/'-separated path, regardless of platform. 'dst' is a
"(p not in mp) and mp.append(p)\n"
% locals()
)
- f.close()
-
+ f.close()
if exclude:
return [f for f in outputs if f not in exclude]
return outputs
-
-
-
-
-
-
def initialize_options(self):
_install_scripts.initialize_options(self)
self.no_ep = False
-
+
def run(self):
self.run_command("egg_info")
if self.distribution.scripts:
self.outfiles = []
if self.no_ep:
# don't install entry point scripts into .egg file!
- return
+ return
- ei_cmd = self.get_finalized_command("egg_info")
+ ei_cmd = self.get_finalized_command("egg_info")
dist = Distribution(
ei_cmd.egg_base, PathMetadata(ei_cmd.egg_base, ei_cmd.egg_info),
ei_cmd.egg_name, ei_cmd.egg_version,
os.chmod(target,0755)
except (AttributeError, os.error):
pass
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
"(e.g. '.zip' or '.egg')"
)
if self.keep is None:
- raise DistutilsOptionError("Must specify number of files to keep")
+ raise DistutilsOptionError("Must specify number of files to keep")
try:
self.keep = int(self.keep)
except ValueError:
log.info("Deleting %s", f)
if not self.dry_run:
os.unlink(f)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
settings.setdefault(cmd,{})[opt] = val
edit_config(self.filename, settings, self.dry_run)
-
self.filelist.append(os.path.join(ei_cmd.egg_info,'SOURCES.txt'))
self.check_metadata()
- self.make_distribution()
+ self.make_distribution()
dist_files = getattr(self.distribution,'dist_files',[])
for file in self.archive_files:
# dying and thus masking the real error
sys.exc_info()[2].tb_next.tb_frame.f_locals['template'].close()
raise
-
class option_base(Command):
"""Abstract base class for commands that mess with config files"""
-
+
user_options = [
('global-config', 'g',
"save options to the site-wide distutils.cfg file"),
boolean_options = [
'global-config', 'user-config',
- ]
+ ]
def initialize_options(self):
self.global_config = None
"Must specify only one configuration file option",
filenames
)
- self.filename, = filenames
+ self.filename, = filenames
('command=', 'c', 'command to set an option for'),
('option=', 'o', 'option to set'),
('set-value=', 's', 'value of the option'),
- ('remove', 'r', 'remove (unset) the value'),
+ ('remove', 'r', 'remove (unset) the value'),
] + option_base.user_options
boolean_options = option_base.boolean_options + ['remove']
},
self.dry_run
)
-
-
-
-
-
-
self.reinitialize_command('build_ext', inplace=1)
self.run_command('build_ext')
- if self.distribution.tests_require:
+ if self.distribution.tests_require:
self.distribution.fetch_build_eggs(self.distribution.tests_require)
if self.test_suite:
None, None, [unittest.__file__]+self.test_args,
testLoader = loader_class()
)
-
-
-
-
return const
else:
const = default
-
-
-
-
-
-
-
" doesn't contain any packages or modules under %s"
% (self.description, item, item)
)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
"""Extension that uses '.c' files in place of '.pyx' files"""
if not have_pyrex:
- # convert .pyx extensions to .c
+ # convert .pyx extensions to .c
def __init__(self,*args,**kw):
_Extension.__init__(self,*args,**kw)
sources = []
distutils.extension.Extension = Extension
if 'distutils.command.build_ext' in sys.modules:
sys.modules['distutils.command.build_ext'].Extension = Extension
-
def find_packages(self, requirement):
self.scan_url(self.index_url + requirement.unsafe_name+'/')
-
+
if not self.package_pages.get(requirement.key):
# Fall back to safe version of the name
self.scan_url(self.index_url + requirement.project_name+'/')
"Can't process plain .py files without an '#egg=name-version'"
" suffix to enable automatic setup script generation."
)
-
+
dl_blocksize = 8192
def _download_to(self, url, filename):
self.url_ok(url,True) # raises error if not allowed
# DNS-bl0ck1n9 f1r3w4llz sUx0rs!
_sf_mirrors[:] = ['dl.sourceforge.net']
return random.choice(_sf_mirrors)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
support alternate installation locations even if you run its setup
script by hand. Please inform the package's author and the EasyInstall
maintainers to find out if a fix or workaround is available.""" % self.args
-
-
def __boot():
- import sys, imp, os, os.path
+ import sys, imp, os, os.path
PYTHONPATH = os.environ.get('PYTHONPATH')
if PYTHONPATH is None or (sys.platform=='win32' and not PYTHONPATH):
PYTHONPATH = []
addsitedir(item)
sys.__egginsert += oldpos # restore effective old position
-
+
d,nd = makepath(stdpath[0])
insert_at = None
new_path = []
# new path after the insert point, back-insert it
new_path.insert(insert_at, item)
insert_at += 1
-
+
sys.path[:] = new_path
-if __name__=='site':
+if __name__=='site':
__boot()
del __boot
-
-
-
-
-
-
-
-
ts5 = makeSetup().get_command_obj('test')
ts5.ensure_finalized()
self.assertEqual(ts5.test_suite, None)
-
-
-
-
-
self.assertRaises(VersionConflict, ws.resolve,
parse_requirements("Foo==0.9"), ad)
ws = WorkingSet([]) # reset
-
+
# Request an extra that causes an unresolved dependency for "Baz"
self.assertRaises(
DistributionNotFound, ws.resolve,parse_requirements("Foo[bar]"), ad
self.assertRaises( VersionConflict,
ws.resolve, parse_requirements("Foo==1.2\nFoo!=1.2"), ad
)
-
+
def testDistroDependsOptions(self):
d = self.distRequires("""
Twisted>=1.5
for p,v1 in enumerate(torture):
for v2 in torture[p+1:]:
c(v2,v1)
-
-
-
-
-
-
-
-
-