[Python-checkins]
python/nondist/sandbox/setuptools/setuptools/command
depends.py, 1.2, 1.3
pje at users.sourceforge.net
pje at users.sourceforge.net
Sun Mar 21 20:12:33 EST 2004
Update of /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10308/setuptools/command
Modified Files:
depends.py
Log Message:
Compute command line that should be passed to child setup scripts.
Warn user if unsupported options are supplied, and cancel unless
'depends -i' (aka '--ignore-extra-args') was used.
Index: depends.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command/depends.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** depends.py 20 Mar 2004 20:52:11 -0000 1.2
--- depends.py 22 Mar 2004 01:12:31 -0000 1.3
***************
*** 23,33 ****
]
def initialize_options(self):
! self.temp = None
def finalize_options(self):
self.set_undefined_options('build',('build_temp', 'temp'))
self.set_search_path()
def set_search_path(self):
--- 23,74 ----
]
+ # Command options that can be safely passed to dependencies' setup scripts
+ safe_opts = {
+ 'install': [
+ 'prefix','exec-prefix','home','install-base','install-platbase',
+ 'root','optimize','force','verbose','quiet'
+ ],
+ 'build': ['compiler','debug','force','verbose','quiet'],
+ }
+
+ # Options with string arguments that are *not* directories or files, and
+ # so should *not* have absolute-path fixups applied.
+ non_fs_opts = {'build':['compiler'] }
+
def initialize_options(self):
! self.temp = None; self.ignore_extra_args = None
def finalize_options(self):
self.set_undefined_options('build',('build_temp', 'temp'))
self.set_search_path()
+ self.set_subcommand_args()
+
+ def set_subcommand_args(self):
+ safe = {'install':[]} # ensure we at least perform an install
+ unsafe = {}
+ copts = self.distribution.get_cmdline_options()
+
+ if 'depends' in copts:
+ del copts['depends']
+
+ for cmd,opts in copts.items():
+ safe_opts = self.safe_opts.get(cmd,())
+ non_fs_opts = self.non_fs_opts.get(cmd,())
+
+ for opt,val in opts.items():
+ if opt in safe_opts:
+ cmdline = safe.setdefault(cmd,[])
+ if val is not None and opt not in non_fs_opts:
+ val = os.path.abspath(val)
+ else:
+ cmdline = unsafe.setdefault(cmd,[])
+
+ cmdline.append('--'+opt)
+ if val is not None:
+ cmdline.append(val)
+
+ self.safe_options = safe
+ self.unsafe_options = unsafe
def set_search_path(self):
***************
*** 42,60 ****
def run(self):
self.announce("checking for installed dependencies")
needed = [
dep for dep in self.distribution.requires if self.is_needed(dep)
]
if not needed:
self.announce("all dependencies are present and up-to-date")
return
# Alert the user to missing items
fmt = "\t%s\t%s\n"
items = [fmt % (dep.full_name(),dep.homepage) for dep in needed]
! items.insert(0,"Please install the following packages first:\n")
items.append('')
raise SystemExit('\n'.join(items)) # dump msg to stderr and exit
def is_needed(self,dep):
"""Does the specified dependency need to be installed/updated?"""
--- 83,135 ----
def run(self):
self.announce("checking for installed dependencies")
+
needed = [
dep for dep in self.distribution.requires if self.is_needed(dep)
]
+
if not needed:
self.announce("all dependencies are present and up-to-date")
return
+ argv = [sys.executable,'setup.py']
+ for cmd,line in self.safe_options.items():
+ argv.append(cmd); argv.extend(line)
+
+ self.announce(
+ "dependencies will be installed using:\n "+' '.join(argv)+'\n'
+ )
+
+ # Alert for unsupported commands/options, unless '-i' was used
+ if self.unsafe_options:
+ self.warn_unsafe_options_used()
+ if not self.ignore_extra_args:
+ raise SystemExit(
+ "Unsupported options for building dependencies; please"
+ " add 'depends -i'\nto your command line if you want to"
+ " force the build to proceed.\nOtherwise, you will need"
+ " to omit the unsupported options,\nor install the"
+ " dependencies manually."
+ )
+
+
# Alert the user to missing items
fmt = "\t%s\t%s\n"
items = [fmt % (dep.full_name(),dep.homepage) for dep in needed]
! items.insert(0,"Please install the following packages *first*:\n")
items.append('')
raise SystemExit('\n'.join(items)) # dump msg to stderr and exit
+
+ def warn_unsafe_options_used(self):
+ lines = []; write = lines.append
+ write("the following command options are not supported for building")
+ write("dependencies, and will be IGNORED:")
+ for cmd,line in self.unsafe_options.items():
+ write('\t%s %s' % (cmd,' '.join(line)))
+ write('')
+ self.warn('\n'.join(lines))
+
+
def is_needed(self,dep):
"""Does the specified dependency need to be installed/updated?"""
***************
*** 81,82 ****
--- 156,164 ----
+
+
+
+
+
+
+
More information about the Python-checkins
mailing list