def finalize_options(self): # suppress(unused-function) """Finalize all options.""" for option in ["suppress-codes", "exclusions", "disable-linters"]: attribute = option.replace("-", "_") if isinstance(getattr(self, attribute), str): setattr(self, attribute, getattr(self, attribute).split(",")) if not isinstance(getattr(self, attribute), list): raise DistutilsArgError("""--{0} must be """ """a list""".format(option)) if not isinstance(self.cache_directory, str): raise DistutilsArgError("""--cache-directory=CACHE """ """must be a string""") if not isinstance(self.stamp_directory, str): raise DistutilsArgError("""--stamp-directory=STAMP """ """must be a string""") if not isinstance(self.stamp_directory, str): raise DistutilsArgError("""--stamp-directory=STAMP """ """must be a string""") if not isinstance(self.show_lint_files, int): raise DistutilsArgError("""--show-lint-files must be a int""") self.cache_directory = _get_cache_dir(self.cache_directory)
def finalize_options(self): install.finalize_options(self) if self.init_system and isinstance(self.init_system, str): self.init_system = self.init_system.split(",") if len(self.init_system) == 0: raise DistutilsArgError( ("You must specify one of (%s) when" " specifying init system(s)!") % (", ".join(INITSYS_TYPES))) bad = [f for f in self.init_system if f not in INITSYS_TYPES] if len(bad) != 0: raise DistutilsArgError( "Invalid --init-system: %s" % (','.join(bad))) for system in self.init_system: # add data files for anything that starts with '<system>.' datakeys = [k for k in INITSYS_ROOTS if k.partition(".")[0] == system] for k in datakeys: self.distribution.data_files.append( (INITSYS_ROOTS[k], INITSYS_FILES[k])) # Force that command to reinitalize (with new file list) self.distribution.reinitialize_command('install_data', True)
def finalize_options(self): install.finalize_options(self) for optname in ('root_dir', 'config_dir', 'cache_dir', 'sock_dir', 'srv_root_dir', 'base_file_roots_dir', 'base_pillar_roots_dir', 'base_master_roots_dir', 'logs_dir', 'pidfile_dir'): optvalue = getattr(self, 'salt_{0}'.format(optname)) if not optvalue: raise DistutilsArgError( 'The value of --salt-{0} needs a proper path value'.format( optname.replace('_', '-'))) setattr(self.distribution, 'salt_{0}'.format(optname), optvalue) if self.salt_transport not in ('zeromq', 'raet', 'both', 'none'): raise DistutilsArgError( 'The value of --salt-transport needs be \'zeromq\', ' '\'raet\', \'both\' or \'none\' not {0!r}'.format( self.salt_transport)) elif self.salt_transport == 'none': for requirement in _parse_requirements_file(SALT_ZEROMQ_REQS): if requirement not in self.distribution.install_requires: continue self.distribution.install_requires.remove(requirement) elif self.salt_transport in ('raet', 'both'): self.distribution.install_requires.extend( _parse_requirements_file(SALT_RAET_REQS)) if self.salt_transport == 'raet': for requirement in _parse_requirements_file(SALT_ZEROMQ_REQS): if requirement not in self.distribution.install_requires: continue self.distribution.install_requires.remove(requirement)
def build_test_suite(self): #Clear the cache of anything to do with this build so it will reload. #If this is not done then strange ImportError are thrown. def list_tests(suite): ret = [] for t in suite: if isinstance(t, unittest.TestSuite): ret.extend(list_tests(t)) else: ret.append(t) return ret cacheclear = [ i for i in sys.path_importer_cache if os.path.abspath(i).startswith(os.getcwd()) ] for i in cacheclear: del sys.path_importer_cache[i] #Find all test suites to run if self.suite: self.suite = unittest.TestLoader().loadTestsFromName(self.suite) elif self.debug: self.suite = unittest.TestLoader().loadTestsFromName(self.debug) tests = list_tests(self.suite) if len(tests) < 1: raise DistutilsArgError("No test case to execute.") if len(tests) > 1: raise DistutilsArgError( "Only one test case for debug allowed.") else: self.cov.start() self.suite = getattr(__import__('TestSuite'), self.suite_name)() self.cov.stop()
def run_build(self): if self.with_nvvl: if self.system_nvvl: raise DistutilsArgError( "system-nvvl and with-nvvl are mutually exclusive") libpath = os.path.join(self.with_nvvl, "libnvvl.so") if not os.path.isfile(libpath): raise DistutilsFileError("Provided with-nvvl path, but " + libpath + " doesn't exit.") for ext in self.extensions: ext.library_dirs += [self.with_nvvl] self.distribution.data_files = [('nvvl/lib', [libpath])] elif not self.system_nvvl: output_dir = os.path.join(self.build_temp, "nvvl-build") mkpath(output_dir, 0o777, dry_run=self.dry_run) cmake_cmd = ["cmake", "-B" + output_dir, "-H" + nvvl_path] spawn(cmake_cmd, dry_run=self.dry_run) make_cmd = ["make", "-C", output_dir, "-j4"] spawn(make_cmd, dry_run=self.dry_run) for ext in self.extensions: ext.library_dirs += [output_dir] ext.runtime_library_dirs = ["$ORIGIN"] self.distribution.data_files = [ ('nvvl/lib', [os.path.join(output_dir, "libnvvl.so")]) ] build_ext_orig.run(self)
def getopt(self, args=None, object=None): """Parse command-line options in args. Store as attributes on object. If 'args' is None or not supplied, uses 'sys.argv[1:]'. If 'object' is None or not supplied, creates a new OptionDummy object, stores option values there, and returns a tuple (args, object). If 'object' is supplied, it is modified in place and 'getopt()' just returns 'args'; in both cases, the returned 'args' is a modified copy of the passed-in 'args' list, which is left untouched. """ if args is None: args = sys.argv[1:] if object is None: object = OptionDummy() created_object = 1 else: created_object = 0 self._grok_option_table() short_opts = string.join(self.short_opts) try: opts, args = getopt.getopt(args, short_opts, self.long_opts) except getopt.error as msg: raise DistutilsArgError(msg) for opt, val in opts: if len(opt) == 2 and opt[0] == '-': # it's a short option opt = self.short2long[opt[1]] else: assert len(opt) > 2 and opt[:2] == '--' opt = opt[2:] alias = self.alias.get(opt) if alias: opt = alias if not self.takes_arg[opt]: # boolean option? assert val == '', "boolean option can't have value" alias = self.negative_alias.get(opt) if alias: opt = alias val = 0 else: val = 1 attr = self.attr_name[opt] # The only repeating option at the moment is 'verbose'. # It has a negative option -q quiet, which should set verbose = 0. if val and self.repeat.get(attr) is not None: val = getattr(object, attr, 0) + 1 setattr(object, attr, val) self.option_order.append((opt, val)) # for opts if created_object: return args, object else: return args
def parse_command_line(self): args = distutils.dist.Distribution.parse_command_line(self) # Setup our property functions after class initialization and # after parsing the command line since most are set to None for funcname in dir(self): if not funcname.startswith('_property_'): continue property_name = funcname.split('_property_', 1)[-1] setattr(self, property_name, getattr(self, funcname)) if not self.ssh_packaging and PACKAGED_FOR_SALT_SSH: self.ssh_packaging = 1 if self.ssh_packaging: self.metadata.name = 'salt-ssh' self.salt_transport = 'ssh' elif self.salt_transport is None: self.salt_transport = 'zeromq' if self.salt_transport not in ('zeromq', 'raet', 'both', 'ssh', 'none'): raise DistutilsArgError( 'The value of --salt-transport needs be \'zeromq\', ' '\'raet\', \'both\', \'ssh\' or \'none\' not {0!r}'.format( self.salt_transport)) return args
def finalize_options(self): install.finalize_options(self) if self.init_system and isinstance(self.init_system, str): self.init_system = self.init_system.split(",") if (len(self.init_system) == 0 and not platform.system().endswith('BSD')): self.init_system = ['systemd'] bad = [f for f in self.init_system if f not in INITSYS_TYPES] if len(bad) != 0: raise DistutilsArgError("Invalid --init-system: %s" % (','.join(bad))) for system in self.init_system: # add data files for anything that starts with '<system>.' datakeys = [ k for k in INITSYS_ROOTS if k.partition(".")[0] == system ] for k in datakeys: if not INITSYS_FILES[k]: continue self.distribution.data_files.append( (INITSYS_ROOTS[k], INITSYS_FILES[k])) # Force that command to reinitialize (with new file list) self.distribution.reinitialize_command('install_data', True)
def parse_command_line(self): args = distutils.dist.Distribution.parse_command_line(self) if not self.ssh_packaging and PACKAGED_FOR_SALT_SSH: self.ssh_packaging = 1 if self.ssh_packaging: self.metadata.name = 'salt-ssh' self.salt_transport = 'ssh' elif self.salt_transport is None: self.salt_transport = 'zeromq' if self.salt_transport not in ('zeromq', 'both', 'ssh', 'none'): raise DistutilsArgError( 'The value of --salt-transport needs be \'zeromq\', ' '\'both\', \'ssh\', or \'none\' not \'{0}\''.format( self.salt_transport)) # Setup our property functions after class initialization and # after parsing the command line since most are set to None # ATTENTION: This should be the last step before returning the args or # some of the requirements won't be correctly set for funcname in dir(self): if not funcname.startswith('_property_'): continue property_name = funcname.split('_property_', 1)[-1] setattr(self, property_name, getattr(self, funcname)) return args
def run(self): path = None if self.install_ida_plugin is not None: base = None if self.install_ida_plugin == '': # Try IDAUSR first base = os.getenv("IDAUSR") if base is None: # Use default from IDA docs base = os.getenv("APPDATA") if base is not None: base = os.path.join(base, 'Hex-Rays', 'IDA Pro') else: base = self.install_ida_plugin if base and os.path.exists(base): path = os.path.join(base, 'plugins') if path is None: raise DistutilsArgError( "Unable to locate IDA installation, pleasy specify") install.install.do_egg_install(self) # Install plugin if path is not None: log.info("Installing IDA plugin to: {}".format(path)) if not os.path.exists(path): os.makedirs(path) plugin_file = 'annotate_lineinfo_plugin.py' shutil.copyfile(plugin_file, os.path.join(path, plugin_file))
def run(self): """Run command.""" self.run_command('lupload') lupload_cmd = self.get_finalized_command('lupload') s3_bucket = getattr(lupload_cmd, 's3_bucket') s3_key = getattr(lupload_cmd, 's3_object_key') s3_object_version = getattr(lupload_cmd, 's3_object_version') if s3_bucket is None or s3_key is None or s3_object_version is None: raise DistutilsArgError('\'lupload\' missing attributes') aws_lambda = boto3.client( 'lambda', aws_access_key_id=getattr(lupload_cmd, 'access_key'), aws_secret_access_key=getattr(lupload_cmd, 'secret_access_key'), config=Config(signature_version='s3v4'), region_name=getattr(self, 'region')) for function_name in getattr(self, 'function_names').split(','): try: log.info('Updating and publishing {}'.format(function_name)) aws_lambda.update_function_code( FunctionName=function_name, S3Bucket=s3_bucket, S3Key=s3_key, S3ObjectVersion=s3_object_version, Publish=True) except ClientError as err: log.warn('Error updating {}\n{}'.format(function_name, err))
def __getattribute__(cls, attr): if attr in ('description', 'error_msg'): # Allow cls.description to work so that `./setup.py # --help-commands` still works return super(_DummyCommandMeta, cls).__getattribute__(attr) raise DistutilsArgError(cls.error_msg)
def finalize_options(self): install.finalize_options(self) logged_warnings = False for optname in ('root_dir', 'config_dir', 'cache_dir', 'sock_dir', 'srv_root_dir', 'base_file_roots_dir', 'base_pillar_roots_dir', 'base_master_roots_dir', 'logs_dir', 'pidfile_dir'): optvalue = getattr(self, 'salt_{0}'.format(optname)) if optvalue is not None: dist_opt_value = getattr(self.distribution, 'salt_{0}'.format(optname)) logged_warnings = True log.warn( 'The \'--salt-{0}\' setting is now a global option just pass it ' 'right after \'setup.py\'. This install setting will still work ' 'until Salt Boron but please migrate to the global setting as ' 'soon as possible.'.format(optname.replace('_', '-'))) if dist_opt_value is not None: raise DistutilsArgError( 'The \'--salt-{0}\' setting was passed as a global option ' 'and as an option to the install command. Please only pass ' 'one of them, preferably the global option since the other ' 'is now deprecated and will be removed in Salt Boron.'. format(optname.replace('_', '-'))) setattr(self.distribution, 'salt_{0}'.format(optname), optvalue) if logged_warnings is True: time.sleep(3)
def run(self): """Run command.""" self.run_command('ldist') ldist_cmd = self.get_finalized_command('ldist') dist_path = getattr(ldist_cmd, 'dist_path', None) dist_name = getattr(ldist_cmd, 'dist_name', None) if dist_path is None or dist_name is None: raise DistutilsArgError('\'ldist\' missing attributes') dist_name = getattr(self, 's3_prefix') + dist_name s3 = boto3.client('s3', aws_access_key_id=getattr(self, 'access_key'), aws_secret_access_key=getattr( self, 'secret_access_key'), config=Config(signature_version='s3v4')) log.info('uploading {} to {} using kms key {}'.format( dist_name, getattr(self, 's3_bucket'), getattr(self, 'kms_key_id'))) with open(dist_path, 'rb') as dist: if getattr(self, 'kms_key_id'): response = s3.put_object(Body=dist, Bucket=getattr(self, 's3_bucket'), Key=dist_name, ServerSideEncryption='aws:kms', SSEKMSKeyId=getattr( self, 'kms_key_id')) else: response = s3.put_object(Body=dist, Bucket=getattr(self, 's3_bucket'), Key=dist_name, ServerSideEncryption='AES256') log.info('upload complete:\n{}'.format( json.dumps(response, sort_keys=True, indent=4, separators=(',', ': '))))
def finalize_options(self): orig.install.finalize_options(self) if self.root: self.single_version_externally_managed = True elif self.single_version_externally_managed: if not self.root and not self.record: raise DistutilsArgError( "You must specify --record or --root when building system" " packages")
def finalize_options(self): if self.site_path is None: raise DistutilsArgError( "You must specify a path to the site to be deployed") self.site_path = os.path.abspath(self.site_path) if self.virtualenv is None: raise DistutilsArgError( "You must specify a virtualenv for the site to be deployed into" ) self.virtualenv = os.path.abspath(self.virtualenv) if self.listen_externally and not self.development: raise DistutilsArgError( "You can not listen externally when in non-development mode, only development installs start the server!" ) if self.port and not self.development: raise DistutilsArgError( "You specify a port when in non-development mode, only development installs start the server!" ) if self.port is None: self.port = 8000
def finalize_options(self): install.finalize_options(self) if self.init_system and self.init_system not in INITSYS_TYPES: raise DistutilsArgError( ("You must specify one of (%s) when" " specifying a init system!") % (", ".join(INITSYS_TYPES))) elif self.init_system: self.distribution.data_files.append( (INITSYS_ROOTS[self.init_system], INITSYS_FILES[self.init_system])) # Force that command to reinitalize (with new file list) self.distribution.reinitialize_command('install_data', True)
def run(self): """Run command.""" self.run_command('gdist') gdist_cmd = self.get_finalized_command('gdist') dist_path = getattr(gdist_cmd, 'gdist_path') dist_name = getattr(gdist_cmd, 'gdist_name') script_name = getattr(gdist_cmd, 'gdist_script_name') script_path = getattr(gdist_cmd, 'gdist_script_path') if dist_path is None or dist_name is None: raise DistutilsArgError('\'gdist\' missing attributes') dist_name = getattr(self, 's3_prefix') + dist_name script_name = getattr(self, 's3_prefix') + script_name if len(getattr(self, 'endpoint_url')): s3 = boto3.client('s3', aws_access_key_id=getattr(self, 'access_key'), aws_secret_access_key=getattr( self, 'secret_access_key'), config=Config(signature_version='s3v4'), endpoint_url=getattr(self, 'endpoint_url')) else: s3 = boto3.client('s3', aws_access_key_id=getattr(self, 'access_key'), aws_secret_access_key=getattr( self, 'secret_access_key'), config=Config(signature_version='s3v4')) log.info('uploading {} to {} at {} using kms key {}'.format( dist_name, getattr(self, 's3_bucket'), getattr(self, 'endpoint_url') if len(getattr(self, 'endpoint_url')) else 'default endpoint', getattr(self, 'kms_key_id'))) for (file, fname) in [(dist_path, dist_name), (script_path, script_name)]: with open(file, 'rb') as dist: if getattr(self, 'kms_key_id'): response = s3.put_object(Body=dist, Bucket=getattr(self, 's3_bucket'), Key=fname, ServerSideEncryption='aws:kms', SSEKMSKeyId=getattr( self, 'kms_key_id')) else: response = s3.put_object(Body=dist, Bucket=getattr(self, 's3_bucket'), Key=fname, ServerSideEncryption='AES256') log.info('upload complete {}:\n{}'.format( fname, json.dumps(response, sort_keys=True, indent=4, separators=(',', ': ')))) setattr(self, 's3_object_key', dist_name) setattr(self, 's3_object_key_script', script_name)
def finalize_options(self): install.finalize_options(self) for optname in ('root_dir', 'config_dir', 'cache_dir', 'sock_dir', 'srv_root_dir', 'base_file_roots_dir', 'base_pillar_roots_dir', 'base_master_roots_dir', 'logs_dir', 'pidfile_dir'): optvalue = getattr(self, 'salt_{0}'.format(optname)) if not optvalue: raise DistutilsArgError( 'The value of --salt-{0} needs a proper path value'.format( optname.replace('_', '-'))) setattr(self.distribution, 'salt_{0}'.format(optname), optvalue)
def run(self): """Run command.""" self.run_command('lupload') ldist_cmd = self.get_finalized_command('ldist') lupload_cmd = self.get_finalized_command('lupload') s3_bucket = getattr(lupload_cmd, 's3_bucket') s3_key = getattr(lupload_cmd, 's3_object_key') s3_object_version = getattr(lupload_cmd, 's3_object_version') # s3_object_version could be None if Versioning is not enabled in that # bucket. That will be okay as it is optional to update_function_code. if s3_bucket is None or s3_key is None: raise DistutilsArgError('\'lupload\' missing attributes') aws_lambda = boto3.client('lambda', config=Config(signature_version='s3v4'), region_name=getattr(self, 'region')) for lambda_name in set(getattr(self, 'lambda_names').split(',')): if not lambda_name: continue if not getattr(ldist_cmd, 'build_layer', False): try: log.info('Updating and publishing function {}'.format( lambda_name)) kwargs = dict(FunctionName=lambda_name, S3Bucket=s3_bucket, S3Key=s3_key, Publish=True) if s3_object_version: kwargs['S3ObjectVersion'] = s3_object_version aws_lambda.update_function_code(**kwargs) except ClientError as err: log.warn('Error updating function {}\n{}'.format( lambda_name, err)) else: try: log.info('Publishing layer {}'.format(lambda_name)) content = dict(S3Bucket=s3_bucket, S3Key=s3_key) if s3_object_version: content['S3ObjectVersion'] = s3_object_version aws_lambda.publish_layer_version( LayerName=lambda_name, Description='{}-{}'.format( self.distribution.get_name(), self.distribution.get_version()), Content=content, CompatibleRuntimes=getattr(self, 'layer_runtimes')) except ClientError as err: log.warn('Error publishing layer {}\n{}'.format( lambda_name, err))
def finalize_options(self): if self.base_dir is not None: if not os.path.isdir(self.base_dir): raise DistutilsArgError('%s is not a valid directory' % self.base_dir) else: self.base_dir = '.' _, ext = os.path.splitext(self.msgfmt) if os.name == 'nt' and ext != '.exe': self.msgfmt += '.exe' msgfmt = utils.which(self.msgfmt) if msgfmt is None: utils.error('"%s" is not an executable', self.msgfmt) else: self.msgfmt = msgfmt
def initialize_options(self): install.initialize_options(self) # pylint: disable=undefined-variable if __saltstack_version__.info >= SaltStackVersion.from_name('Boron'): # XXX: Remove the Salt Specific Options In Salt Boron. They are now global options raise DistutilsArgError( 'Developers, please remove the salt paths configuration ' 'setting from the setup\'s install command') # pylint: enable=undefined-variable self.salt_root_dir = None self.salt_config_dir = None self.salt_cache_dir = None self.salt_sock_dir = None self.salt_srv_root_dir = None self.salt_base_file_roots_dir = None self.salt_base_pillar_roots_dir = None self.salt_base_master_roots_dir = None self.salt_logs_dir = None self.salt_pidfile_dir = None
def finalize_options(self): if self.version: print 'distribute %s' % get_distribution('distribute').version sys.exit() py_version = sys.version.split()[0] self.config_vars = { 'dist_name': self.distribution.get_name(), 'dist_version': self.distribution.get_version(), 'dist_fullname': self.distribution.get_fullname(), 'py_version': py_version, 'py_version_short': py_version[0:3], 'py_version_nodot': py_version[0] + py_version[2], } self._expand('install_dir') normpath = map(normalize_path, sys.path) self.index_url = self.index_url or "http://pypi.python.org/simple" hosts = ['*'] if self.package_index is None: self.package_index = self.create_index( self.index_url, hosts=hosts, ) self.local_index = Environment(sys.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.package_index.add_find_links(self.find_links) if not self.args: raise DistutilsArgError( "No urls, filenames, or requirements specified (see --help)") self.outputs = []
def run(self): # Create the virtualenv print "Creating a virtualenv for Molly...", try: venv = Virtualenv.create(self.virtualenv, self.force, PYTHON26) except NotAVirtualenvError: raise DistutilsArgError( 'Virtualenv already exists here, use -f to force install') print "DONE!" # Now install our Molly prereqs print "Installing Python dependencies:" pip = os.path.join(self.virtualenv, 'bin', 'pip') for name, package in PIP_PACKAGES: print " * " + name + '...', sys.stdout.flush() venv('pip install -U %s' % package) print "DONE!" print return venv
def _parse_command_opts(self, parser, args): # noqa: C901 """Parse the command-line options for a single command. 'parser' must be a FancyGetopt instance; 'args' must be the list of arguments, starting with the current command (whose options we are about to parse). Returns a new version of 'args' with the next command at the front of the list; will be the empty list if there are no more commands on the command line. Returns None if the user asked for help on this command. """ # late import because of mutual dependence between these modules from distutils.cmd import Command # Pull the current command from the head of the command line command = args[0] if not command_re.match(command): raise SystemExit("invalid command name '%s'" % command) self.commands.append(command) # Dig up the command class that implements this command, so we # 1) know that it's a valid command, and 2) know which options # it takes. try: cmd_class = self.get_command_class(command) except DistutilsModuleError as msg: raise DistutilsArgError(msg) # Require that the command class be derived from Command -- want # to be sure that the basic "command" interface is implemented. if not issubclass(cmd_class, Command): raise DistutilsClassError( "command class %s must subclass Command" % cmd_class) # Also make sure that the command object provides a list of its # known options. if not (hasattr(cmd_class, 'user_options') and isinstance(cmd_class.user_options, list)): msg = ("command class %s must provide " "'user_options' attribute (a list of tuples)") raise DistutilsClassError(msg % cmd_class) # If the command class has a list of negative alias options, # merge it in with the global negative aliases. negative_opt = self.negative_opt if hasattr(cmd_class, 'negative_opt'): negative_opt = negative_opt.copy() negative_opt.update(cmd_class.negative_opt) # Check for help_options in command class. They have a different # format (tuple of four) so we need to preprocess them here. if hasattr(cmd_class, 'help_options') and isinstance( cmd_class.help_options, list): help_options = fix_help_options(cmd_class.help_options) else: help_options = [] # All commands support the global options too, just by adding # in 'global_options'. parser.set_option_table(self.global_options + cmd_class.user_options + help_options) parser.set_negative_aliases(negative_opt) (args, opts) = parser.getopt(args[1:]) if hasattr(opts, 'help') and opts.help: self._show_help(parser, display_options=0, commands=[cmd_class]) return if hasattr(cmd_class, 'help_options') and isinstance( cmd_class.help_options, list): help_option_found = 0 for (help_option, short, desc, func) in cmd_class.help_options: if hasattr(opts, parser.get_attr_name(help_option)): help_option_found = 1 if callable(func): func() else: raise DistutilsClassError( "invalid help function %r for help option '%s': " "must be a callable object (function, etc.)" % (func, help_option)) if help_option_found: return # Put the options from the command-line into their official # holding pen, the 'command_options' dictionary. opt_dict = self.get_option_dict(command) for (name, value) in vars(opts).items(): opt_dict[name] = ("command line", value) return args
def parse_command_line(self): """Parse the setup script's command line, taken from the 'script_args' instance attribute (which defaults to 'sys.argv[1:]' -- see 'setup()' in core.py). This list is first processed for "global options" -- options that set attributes of the Distribution instance. Then, it is alternately scanned for Distutils commands and options for that command. Each new command terminates the options for the previous command. The allowed options for a command are determined by the 'user_options' attribute of the command class -- thus, we have to be able to load command classes in order to parse the command line. Any error in that 'options' attribute raises DistutilsGetoptError; any error on the command-line raises DistutilsArgError. If no Distutils commands were found on the command line, raises DistutilsArgError. Return true if command-line was successfully parsed and we should carry on with executing commands; false if no errors but we shouldn't execute commands (currently, this only happens if user asks for help). """ # # We now have enough information to show the Macintosh dialog # that allows the user to interactively specify the "command line". # toplevel_options = self._get_toplevel_options() # We have to parse the command line a bit at a time -- global # options, then the first command, then its options, and so on -- # because each command will be handled by a different class, and # the options that are valid for a particular class aren't known # until we have loaded the command class, which doesn't happen # until we know what the command is. self.commands = [] parser = FancyGetopt(toplevel_options + self.display_options) parser.set_negative_aliases(self.negative_opt) parser.set_aliases({'licence': 'license'}) args = parser.getopt(args=self.script_args, object=self) option_order = parser.get_option_order() log.set_verbosity(self.verbose) # for display options we return immediately if self.handle_display_options(option_order): return while args: args = self._parse_command_opts(parser, args) if args is None: # user asked for help (and got it) return # Handle the cases of --help as a "global" option, ie. # "setup.py --help" and "setup.py --help command ...". For the # former, we show global options (--verbose, --dry-run, etc.) # and display-only options (--name, --version, etc.); for the # latter, we omit the display-only options and show help for # each command listed on the command line. if self.help: self._show_help(parser, display_options=len(self.commands) == 0, commands=self.commands) return # Oops, no commands found -- an end-user error if not self.commands: raise DistutilsArgError("no commands supplied") # All is well: return true return True
def finalize_options(self): if self.format not in self.FORMATS: raise DistutilsArgError("--format should be one of {!r}".format( self.FORMATS)) if self.start_tag: self.start_tag = self._tag_version(self.start_tag)
def finalize_options(self): raise DistutilsArgError('DBPrep not supported on this platform')
def finalize_options(self): if self.site is None: raise DistutilsArgError( 'You must specify a path to where the site is to be created')
def finalize_options(self): install.finalize_options(self) if self.lang not in (None, 'hu'): raise DistutilsArgError("Only 'hu' language is allowed.")