Commit e8dbb411 authored by Jason R. Coombs's avatar Jason R. Coombs

Merge setuptools/command/*

--HG--
branch : Setuptools-Distribute merge
parents 3b7000ad ff75a6cb
......@@ -9,7 +9,7 @@ def shquote(arg):
"""Quote an argument for later parsing by shlex.split()"""
for c in '"', "'", "\\", "#":
if c in arg: return repr(arg)
if arg.split()<>[arg]:
if arg.split()!=[arg]:
return repr(arg)
return arg
......@@ -33,7 +33,7 @@ class alias(option_base):
def finalize_options(self):
option_base.finalize_options(self)
if self.remove and len(self.args)<>1:
if self.remove and len(self.args)!=1:
raise DistutilsOptionError(
"Must specify exactly one argument (the alias name) when "
"using --remove"
......
......@@ -170,12 +170,13 @@ class bdist_egg(Command):
def run(self):
# Generate metadata first
self.run_command("egg_info")
# We run install_lib before install_data, because some data hacks
# pull their data path from the install_lib command.
log.info("installing library code to %s" % self.bdist_dir)
instcmd = self.get_finalized_command('install')
old_root = instcmd.root; instcmd.root = None
if self.distribution.has_c_libraries() and not self.skip_build:
self.run_command('build_clib')
cmd = self.call_command('install_lib', warn_dir=0)
instcmd.root = old_root
......@@ -195,7 +196,6 @@ class bdist_egg(Command):
to_compile.extend(self.make_init_files())
if to_compile:
cmd.byte_compile(to_compile)
if self.distribution.data_files:
self.do_install_data()
......@@ -407,7 +407,7 @@ def write_safety_flag(egg_dir, safe):
for flag,fn in safety_flags.items():
fn = os.path.join(egg_dir, fn)
if os.path.exists(fn):
if safe is None or bool(safe)<>flag:
if safe is None or bool(safe)!=flag:
os.unlink(fn)
elif safe is not None and bool(safe)==flag:
f=open(fn,'wt'); f.write('\n'); f.close()
......
......@@ -2,26 +2,24 @@ from distutils.command.bdist_wininst import bdist_wininst as _bdist_wininst
import os, sys
class bdist_wininst(_bdist_wininst):
_good_upload = _bad_upload = None
def create_exe(self, arcname, fullname, bitmap=None):
_bdist_wininst.create_exe(self, arcname, fullname, bitmap)
dist_files = getattr(self.distribution, 'dist_files', [])
installer_name = self.get_installer_filename(fullname)
if self.target_version:
installer_name = os.path.join(self.dist_dir,
"%s.win32-py%s.exe" %
(fullname, self.target_version))
pyversion = self.target_version
# fix 2.5 bdist_wininst ignoring --target-version spec
bad = ('bdist_wininst','any',installer_name)
if bad in dist_files:
dist_files.remove(bad)
# fix 2.5+ bdist_wininst ignoring --target-version spec
self._bad_upload = ('bdist_wininst', 'any', installer_name)
else:
installer_name = os.path.join(self.dist_dir,
"%s.win32.exe" % fullname)
pyversion = 'any'
good = ('bdist_wininst', pyversion, installer_name)
self._good_upload = ('bdist_wininst', pyversion, installer_name)
def _fix_upload_names(self):
good, bad = self._good_upload, self._bad_upload
dist_files = getattr(self.distribution, 'dist_files', [])
if bad in dist_files:
dist_files.remove(bad)
if good not in dist_files:
dist_files.append(good)
......@@ -36,6 +34,49 @@ class bdist_wininst(_bdist_wininst):
self._is_running = True
try:
_bdist_wininst.run(self)
self._fix_upload_names()
finally:
self._is_running = False
if not hasattr(_bdist_wininst, 'get_installer_filename'):
def get_installer_filename(self, fullname):
# Factored out to allow overriding in subclasses
if self.target_version:
# if we create an installer for a specific python version,
# it's better to include this in the name
installer_name = os.path.join(self.dist_dir,
"%s.win32-py%s.exe" %
(fullname, self.target_version))
else:
installer_name = os.path.join(self.dist_dir,
"%s.win32.exe" % fullname)
return installer_name
# get_installer_filename()
......@@ -82,17 +82,15 @@ class build_ext(_build_ext):
def get_ext_filename(self, fullname):
filename = _build_ext.get_ext_filename(self,fullname)
if fullname not in self.ext_map:
return filename
ext = self.ext_map[fullname]
if isinstance(ext,Library):
fn, ext = os.path.splitext(filename)
return self.shlib_compiler.library_filename(fn,libtype)
elif use_stubs and ext._links_to_dynamic:
d,fn = os.path.split(filename)
return os.path.join(d,'dl-'+fn)
else:
return filename
if fullname in self.ext_map:
ext = self.ext_map[fullname]
if isinstance(ext,Library):
fn, ext = os.path.splitext(filename)
return self.shlib_compiler.library_filename(fn,libtype)
elif use_stubs and ext._links_to_dynamic:
d,fn = os.path.split(filename)
return os.path.join(d,'dl-'+fn)
return filename
def initialize_options(self):
_build_ext.initialize_options(self)
......
......@@ -224,18 +224,21 @@ class egg_info(Command):
data = f.read()
f.close()
if data.startswith('10') or data.startswith('9') or data.startswith('8'):
if data.startswith('<?xml'):
dirurl = urlre.search(data).group(1) # get repository URL
localrev = max([int(m.group(1)) for m in revre.finditer(data)]+[0])
else:
try: svnver = int(data.splitlines()[0])
except: svnver=-1
if data<8:
log.warn("unrecognized .svn/entries format; skipping %s", base)
dirs[:] = []
continue
data = map(str.splitlines,data.split('\n\x0c\n'))
del data[0][0] # get rid of the '8' or '9' or '10'
dirurl = data[0][3]
localrev = max([int(d[9]) for d in data if len(d)>9 and d[9]]+[0])
elif data.startswith('<?xml'):
dirurl = urlre.search(data).group(1) # get repository URL
localrev = max([int(m.group(1)) for m in revre.finditer(data)]+[0])
else:
log.warn("unrecognized .svn/entries format; skipping %s", base)
dirs[:] = []
continue
if base==os.curdir:
base_url = dirurl+'/' # save the root url
elif not dirurl.startswith(base_url):
......@@ -248,9 +251,6 @@ class egg_info(Command):
def find_sources(self):
"""Generate SOURCES.txt manifest file"""
manifest_filename = os.path.join(self.egg_info,"SOURCES.txt")
......
from distutils.command.sdist import sdist as _sdist
from distutils.util import convert_path
from distutils import log
from glob import glob
import os, re, sys, pkg_resources
from glob import glob
......@@ -41,7 +42,6 @@ def joinpath(prefix,suffix):
def walk_revctrl(dirname=''):
"""Find all files under revision control"""
for ep in pkg_resources.iter_entry_points('setuptools.file_finders'):
......@@ -89,18 +89,22 @@ def entries_finder(dirname, filename):
f = open(filename,'rU')
data = f.read()
f.close()
if data.startswith('10') or data.startswith('9') or data.startswith('8'):
if data.startswith('<?xml'):
for match in entries_pattern.finditer(data):
yield joinpath(dirname,unescape(match.group(1)))
else:
svnver=-1
try: svnver = int(data.splitlines()[0])
except: pass
if svnver<8:
log.warn("unrecognized .svn/entries format in %s", os.path.abspath(dirname))
return
for record in map(str.splitlines, data.split('\n\x0c\n')[1:]):
# subversion 1.6/1.5/1.4
if not record or len(record)>=6 and record[5]=="delete":
continue # skip deleted
yield joinpath(dirname, record[0])
elif data.startswith('<?xml'):
for match in entries_pattern.finditer(data):
yield joinpath(dirname,unescape(match.group(1)))
else:
log.warn("unrecognized .svn/entries format in %s", os.path.abspath(dirname))
finders = [
(convert_path('CVS/Entries'),
......@@ -121,10 +125,6 @@ finders = [
class sdist(_sdist):
"""Smart sdist that finds anything supported by revision control"""
......@@ -301,13 +301,4 @@ class sdist(_sdist):
#
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