示例#1
0
 def run(self):
     with honor_verbosity(self.distribution.verbose):
         if not self.distribution.clamp:
             raise DistutilsOptionError("Specify the modules to be built into a jar  with the 'clamp' setup keyword")
         build_jar(self.distribution.metadata.get_name(),
                   self.get_jar_name(), self.distribution.clamp, self.output)
    def finalize_options(self):
        """Sets the final values for the command options.

        Defaults were set in `initialize_options`, but could have been changed
        by command-line options or by other commands.
        """
        self.ensure_dirname('source_dir')
        self.ensure_string_list('extra_proto_paths')

        if self.output_dir is None:
            self.output_dir = '.'
        self.ensure_dirname('output_dir')

        # SUBTLE: if 'source_dir' is a subdirectory of any entry in
        # 'extra_proto_paths', then in general, the shortest --proto_path prefix
        # (and the longest relative .proto filenames) must be used for
        # correctness. For example, consider:
        #
        #     source_dir = 'a/b/c'
        #     extra_proto_paths = ['a/b', 'x/y']
        #
        # In this case, we must ensure that a/b/c/d/foo.proto resolves
        # canonically as c/d/foo.proto, not just d/foo.proto. Otherwise, this
        # import:
        #
        #     import "c/d/foo.proto";
        #
        # would result in different FileDescriptor.name keys from "d/foo.proto".
        # That will cause all the definitions in the file to be flagged as
        # duplicates, with an error similar to:
        #
        #     c/d/foo.proto: "packagename.MessageName" is already defined in file "d/foo.proto"
        #
        # For paths in self.proto_files, we transform them to be relative to
        # self.proto_root_path, which may be different from self.source_dir.
        #
        # Although the order of --proto_paths is significant, shadowed filenames
        # are errors: if 'a/b/c.proto' resolves to different files under two
        # different --proto_path arguments, then the path is rejected as an
        # error. (Implementation note: this is enforced in protoc's
        # DiskSourceTree class.)

        if self.proto_root_path is None:
            self.proto_root_path = os.path.normpath(self.source_dir)
            for root_candidate in self.extra_proto_paths:
                root_candidate = os.path.normpath(root_candidate)
                if self.proto_root_path.startswith(root_candidate):
                    self.proto_root_path = root_candidate
            if self.proto_root_path != self.source_dir:
                self.announce('using computed proto_root_path: ' +
                              self.proto_root_path,
                              level=2)

        if not self.source_dir.startswith(self.proto_root_path):
            raise DistutilsOptionError('source_dir ' + self.source_dir +
                                       ' is not under proto_root_path ' +
                                       self.proto_root_path)

        if self.proto_files is None:
            files = glob.glob(os.path.join(self.source_dir, '*.proto'))
            if self.recurse:
                files.extend(
                    glob.glob(os.path.join(self.source_dir, '**', '*.proto')))
            self.proto_files = [
                f.partition(self.proto_root_path + os.path.sep)[-1]
                for f in files
            ]
            if not self.proto_files:
                raise DistutilsOptionError(
                    'no .proto files were found under ' + self.source_dir)

        self.ensure_string_list('proto_files')

        if self.protoc is None:
            self.protoc = spawn.find_executable('protoc')
示例#3
0
 def finalize_options(self):
     option_base.finalize_options(self)
     if self.command is None or self.option is None:
         raise DistutilsOptionError("Must specify --command *and* --option")
     if self.set_value is None and not self.remove:
         raise DistutilsOptionError("Must specify --set-value or --remove")
示例#4
0
 def _assert_local(filepath):
     if not filepath.startswith(os.getcwd()):
         raise DistutilsOptionError('`file:` directive can not access %s' %
                                    filepath)
示例#5
0
 def finalize_options(self):
     """Post-process options."""
     if getattr(self, 'function_names') is None:
         raise DistutilsOptionError('function-names is required')
示例#6
0
 def run(self):
     if not self.distribution.dist_files:
         raise DistutilsOptionError(
             "No dist file created in earlier command")
     for command, pyversion, filename in self.distribution.dist_files:
         self.upload_file(command, pyversion, filename)
示例#7
0
def finalize_compiler_options(cmd):
    """Finalize compiler options for a command

    If compiler options (fcompiler, compiler, f2py) have not been
    specified for a command, check if they were specified for other
    commands on the command line--if so, grab from there. If not,
    set reasonable defaults.

    cmd: the command to finalize the options for
    """
    dist = cmd.distribution
    defaults = {'fcompiler': 'gnu95',
                'f2py': default_f2py(),
                'compiler': None,
                'f77exec': None,
                'f90exec': None,}
    optdict = dist.get_option_dict(cmd.get_command_name())
    #Check all options on all other commands, reverting to default
    #as necessary
    for option in defaults:
        if getattr(cmd, option) == None:
            for c in dist.commands:
                other_cmd = dist.get_command_obj(c)
                if other_cmd == cmd or not hasattr(other_cmd, option):
                    continue
                if getattr(other_cmd, option) != None:
                    setattr(cmd, option, getattr(other_cmd, option))
                    break
            if getattr(cmd, option) == None:
                setattr(cmd, option, defaults[option])
        #Also explicitly carry over command line option, needed for config_fc
        if not option in optdict:
            for c in dist.commands:
                otheroptdict = dist.get_option_dict(c)
                if option in otheroptdict:
                    optdict[option] = otheroptdict[option]
                    break
    #Special-case defaults, checks
    if not cmd.fcompiler in ('pg', 'gnu', 'gnu95', 'intelem', 'intel', 'none', 'None'):
        raise DistutilsOptionError(
            '--fcompiler={0} unknown'.format(cmd.fcompiler) +
            ', options: pg, gnu, gnu95, intelem, intel, None')
    if len('%x' % sys.maxsize)*4 == 32 and cmd.fcompiler == 'intelem':
        raise DistutilsOptionError(
            '--fcompiler=intelem requires a 64-bit architecture')
    if cmd.compiler == None and sys.platform == 'win32':
        cmd.compiler = 'mingw32'
    #Add interpreter to f2py if it needs it (usually on Windows)
    #If it's a list, it's already been patched up
    if sys.platform == 'win32' and isinstance(cmd.f2py, str) \
       and not is_win_exec(cmd.f2py):
        if egginfo_only: #Punt, we're not going to call it
            cmd.f2py = [cmd.f2py]
            return
        f2py = cmd.f2py
        if not os.path.isfile(f2py): #Not a file, and didn't exec
            f2pydir = next((d for d in os.environ['PATH'].split(os.pathsep)
                            if os.path.isfile(os.path.join(d, f2py))), None)
            if f2pydir: #Found the file, try it
                f2py = os.path.join(f2pydir, f2py)
                if not is_win_exec(f2py): #Try the interpreter
                    if is_win_exec(sys.executable, f2py):
                        cmd.f2py = [sys.executable, f2py]
                    else: #Nothing to be done
                        raise RuntimeError(
                            'f2py {0} found but not executable'.format(
                                cmd.f2py))
                else: #Found and executable (unlikely, since would have worked)
                    cmd.f2py = [f2py]
            else: #Couldn't find the file, just try the interpreter
                if is_win_exec(sys.executable, f2py):
                    cmd.f2py = [sys.executable, f2py]
                else: #Nothing to be done
                    raise RuntimeError(
                        'f2py {0} not found and not executable'.format(
                            cmd.f2py))
        else: #Not executable, but IS a file
            if is_win_exec(sys.executable, f2py):
                cmd.f2py = [sys.executable, f2py]
            else: #Nothing to be done
                raise RuntimeError(
                    'f2py {0} exists but not executable'.format(
                        cmd.f2py))
    else:
        cmd.f2py = [cmd.f2py]
示例#8
0
def process_config(config):
    """
    Processes the setup.cfg options and converts them to arguments accepted by
    setuptools' setup() function.
    """

    kwargs = {}

    for arg in SETUP_ARGS_TO_CFG:
        if len(SETUP_ARGS_TO_CFG[arg]) == 2:
            # The distutils field name is different than distutils2's.
            section, option = SETUP_ARGS_TO_CFG[arg]

        elif len(SETUP_ARGS_TO_CFG[arg]) == 1:
            # The distutils field name is the same thant distutils2's.
            section, option = SETUP_ARGS_TO_CFG[arg][0], arg

        in_cfg_value = has_get_option(config, section, option)
        if not in_cfg_value:
            # There is no such option in the setup.cfg
            if arg == "long_description":
                in_cfg_value = has_get_option(config, section,
                                              "description_file")
                if in_cfg_value:
                    in_cfg_value = split_multiline(in_cfg_value)
                    value = ''
                    for filename in in_cfg_value:
                        description_file = open(filename)
                        try:
                            value += description_file.read().strip() + '\n\n'
                        finally:
                            description_file.close()
                    in_cfg_value = value
            else:
                continue

        if arg in CSV_FIELDS:
            in_cfg_value = split_csv(in_cfg_value)
        if arg in MULTI_FIELDS:
            in_cfg_value = split_multiline(in_cfg_value)
        elif arg in BOOL_FIELDS:
            # Provide some flexibility here...
            if in_cfg_value.lower() in ('true', 't', '1', 'yes', 'y'):
                in_cfg_value = True
            else:
                in_cfg_value = False

        if in_cfg_value:
            if arg in ('install_requires', 'tests_require'):
                # Replaces PEP345-style version specs with the sort expected by
                # setuptools
                in_cfg_value = [
                    _VERSION_SPEC_RE.sub(r'\1\2', pred)
                    for pred in in_cfg_value
                ]
            elif arg == 'package_dir':
                in_cfg_value = {'': in_cfg_value}
            elif arg in ('package_data', 'data_files'):
                data_files = {}
                firstline = True
                prev = None
                for line in in_cfg_value:
                    if '=' in line:
                        key, value = line.split('=', 1)
                        key, value = (key.strip(), value.strip())
                        if key in data_files:
                            # Multiple duplicates of the same package name;
                            # this is for backwards compatibility of the old
                            # format prior to d2to1 0.2.6.
                            prev = data_files[key]
                            prev.extend(value.split())
                        else:
                            prev = data_files[key.strip()] = value.split()
                    elif firstline:
                        raise DistutilsOptionError(
                            'malformed package_data first line %r (misses '
                            '"=")' % line)
                    else:
                        prev.extend(line.strip().split())
                    firstline = False
                if arg == 'data_files':
                    # the data_files value is a pointlessly different structure
                    # from the package_data value
                    data_files = list(data_files.items())
                in_cfg_value = data_files
            elif arg == 'cmdclass':
                cmdclass = {}
                dist = Distribution()
                for cls in in_cfg_value:
                    cls = resolve_name(cls)
                    cmd = cls(dist)
                    cmdclass[cmd.get_command_name()] = cls
                in_cfg_value = cmdclass

        kwargs[arg] = in_cfg_value

    return kwargs
示例#9
0
 def finalize_options(self):
     if self.test_suite is None and self.test_module is None:
         self.test_module = 'test'
     elif self.test_module is not None and self.test_suite is not None:
         raise DistutilsOptionError(
             "You may specify a module or suite, but not both")
示例#10
0
    def add_files(self):
        db = self.db
        cab = msilib.CAB("distfiles")
        rootdir = os.path.abspath(self.bdist_dir)

        root = Directory(db, cab, None, rootdir, "TARGETDIR", "SourceDir")
        f = Feature(db, "Python", "Python", "Everything", 0, 1, directory="TARGETDIR")

        items = [(f, root, '')]
        for version in self.versions + [self.other_version]:
            target = "TARGETDIR" + version
            name = default = "Python" + version
            desc = "Everything"
            if version is self.other_version:
                title = "Python from another location"
                level = 2
            else:
                title = "Python %s from registry" % version
                level = 1
            f = Feature(db, name, title, desc, 1, level, directory=target)
            dir = Directory(db, cab, root, rootdir, target, default)
            items.append((f, dir, version))
        db.Commit()

        seen = {}
        for feature, dir, version in items:
            todo = [dir]
            while todo:
                dir = todo.pop()
                for file in os.listdir(dir.absolute):
                    afile = os.path.join(dir.absolute, file)
                    if os.path.isdir(afile):
                        short = "%s|%s" % (dir.make_short(file), file)
                        default = file + version
                        newdir = Directory(db, cab, dir, file, default, short)
                        todo.append(newdir)
                    else:
                        if not dir.component:
                            dir.start_component(dir.logical, feature, 0)
                        if afile not in seen:
                            key = seen[afile] = dir.add_file(file)
                            if file == self.install_script:
                                if self.install_script_key:
                                    raise DistutilsOptionError(
                                        "Multiple files with name %s" % file
                                    )
                                self.install_script_key = '[#%s]' % key
                        else:
                            key = seen[afile]
                            add_data(
                                self.db,
                                "DuplicateFile",
                                [
                                    (
                                        key + version,
                                        dir.component,
                                        key,
                                        None,
                                        dir.logical,
                                    )
                                ],
                            )
            db.Commit()
        cab.commit(db)
示例#11
0
 def finalize_options(self):
     self.valgrind = bool(self.valgrind)
     if self.valgrind_log_file and not self.valgrind:
         raise DistutilsOptionError("valgrind not enabled")
     self.gdb = bool(self.gdb)
     self.no_capture = bool(self.no_capture)
示例#12
0
 def finalize_options(self):
     if self.riak_admin is None:
         raise DistutilsOptionError("riak-admin option not set")
示例#13
0
 def finalize_options(self):
     if self.riak_conf is None:
         raise DistutilsOptionError("riak-conf option not set")
示例#14
0
 def finalize_options(self):
     option_base.finalize_options(self)
     if self.remove and len(self.args) != 1:
         raise DistutilsOptionError(
             "Must specify exactly one argument (the alias name) when "
             "using --remove")
示例#15
0
    def finalize_options(self):
        """Finalizes options."""
        # This method (and its pliant slaves, like 'finalize_unix()',
        # 'finalize_other()', and 'select_scheme()') is where the default
        # installation directories for modules, extension modules, and
        # anything else we care to install from a Python module
        # distribution.  Thus, this code makes a pretty important policy
        # statement about how third-party stuff is added to a Python
        # installation!  Note that the actual work of installation is done
        # by the relatively simple 'install_*' commands; they just take
        # their orders from the installation directory options determined
        # here.

        # Check for errors/inconsistencies in the options; first, stuff
        # that's wrong on any platform.

        if ((self.prefix or self.exec_prefix or self.home)
                and (self.install_base or self.install_platbase)):
            raise DistutilsOptionError(
                "must supply either prefix/exec-prefix/home or " +
                "install-base/install-platbase -- not both")

        if self.home and (self.prefix or self.exec_prefix):
            raise DistutilsOptionError(
                "must supply either home or prefix/exec-prefix -- not both")

        if self.user and (self.prefix or self.exec_prefix or self.home
                          or self.install_base or self.install_platbase):
            raise DistutilsOptionError(
                "can't combine user with prefix, "
                "exec_prefix/home, or install_(plat)base")

        # Next, stuff that's wrong (or dubious) only on certain platforms.
        if os.name != "posix":
            if self.exec_prefix:
                self.warn("exec-prefix option ignored on this platform")
                self.exec_prefix = None

        # Now the interesting logic -- so interesting that we farm it out
        # to other methods.  The goal of these methods is to set the final
        # values for the install_{lib,scripts,data,...}  options, using as
        # input a heady brew of prefix, exec_prefix, home, install_base,
        # install_platbase, user-supplied versions of
        # install_{purelib,platlib,lib,scripts,data,...}, and the
        # INSTALL_SCHEME dictionary above.  Phew!

        self.dump_dirs("pre-finalize_{unix,other}")

        if os.name == 'posix':
            self.finalize_unix()
        else:
            self.finalize_other()

        self.dump_dirs("post-finalize_{unix,other}()")

        # Expand configuration variables, tilde, etc. in self.install_base
        # and self.install_platbase -- that way, we can use $base or
        # $platbase in the other installation directories and not worry
        # about needing recursive variable expansion (shudder).

        py_version = sys.version.split()[0]
        (prefix, exec_prefix) = get_config_vars('prefix', 'exec_prefix')
        try:
            abiflags = sys.abiflags
        except AttributeError:
            # sys.abiflags may not be defined on all platforms.
            abiflags = ''
        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],
            'sys_prefix': prefix,
            'prefix': prefix,
            'sys_exec_prefix': exec_prefix,
            'exec_prefix': exec_prefix,
            'abiflags': abiflags,
        }

        if HAS_USER_SITE:
            self.config_vars['userbase'] = self.install_userbase
            self.config_vars['usersite'] = self.install_usersite

        self.expand_basedirs()

        self.dump_dirs("post-expand_basedirs()")

        # Now define config vars for the base directories so we can expand
        # everything else.
        self.config_vars['base'] = self.install_base
        self.config_vars['platbase'] = self.install_platbase

        if DEBUG:
            from pprint import pprint
            print("config vars:")
            pprint(self.config_vars)

        # Expand "~" and configuration variables in the installation
        # directories.
        self.expand_dirs()

        self.dump_dirs("post-expand_dirs()")

        # Create directories in the home dir:
        if self.user:
            self.create_home_path()

        # Pick the actual directory to install all modules to: either
        # install_purelib or install_platlib, depending on whether this
        # module distribution is pure or not.  Of course, if the user
        # already specified install_lib, use their selection.
        if self.install_lib is None:
            if self.distribution.ext_modules:  # has extensions: non-pure
                self.install_lib = self.install_platlib
            else:
                self.install_lib = self.install_purelib

        # Convert directories from Unix /-separated syntax to the local
        # convention.
        self.convert_paths('lib', 'purelib', 'platlib', 'scripts', 'data',
                           'headers', 'userbase', 'usersite')

        # Well, we're not actually fully completely finalized yet: we still
        # have to deal with 'extra_path', which is the hack for allowing
        # non-packagized module distributions (hello, Numerical Python!) to
        # get their own directories.
        self.handle_extra_path()
        self.install_libbase = self.install_lib  # needed for .pth file
        self.install_lib = os.path.join(self.install_lib, self.extra_dirs)

        # If a new root directory was supplied, make all the installation
        # dirs relative to it.
        if self.root is not None:
            self.change_roots('libbase', 'lib', 'purelib', 'platlib',
                              'scripts', 'data', 'headers')

        self.dump_dirs("after prepending root")

        # Find out the build directories, ie. where to install from.
        self.set_undefined_options('build', ('build_base', 'build_base'),
                                   ('build_lib', 'build_lib'))
示例#16
0
文件: setup.py 项目: isuruf/cysignals
 def run(self):
     from distutils.errors import DistutilsOptionError
     raise DistutilsOptionError(
         "The package cysignals will not function correctly when built as egg. Therefore, it cannot be installed using 'python setup.py install' or 'easy_install'. Instead, use 'pip install' to install cysignals."
     )
示例#17
0
 def finalize_options(self):
     if not self.input_file and not self.input_dir:
         raise DistutilsOptionError('you must specify either the input '
                                    'file or directory')
示例#18
0
 def finalize_options(self):
     if not self.lang:
         raise DistutilsOptionError("no --lang= given")
示例#19
0
 def finalize_options(self):
     if all([self.major, self.minor]):
         from distutils.errors import DistutilsOptionError
         raise DistutilsOptionError(
             "--major/--minor are mutually exclusive")
     self.part = "major" if self.major else "minor" if self.minor else None
示例#20
0
 def finalize_options(self):
     if (self.prefix or self.exec_prefix
             or self.home) and (self.install_base or self.install_platbase):
         raise DistutilsOptionError, 'must supply either prefix/exec-prefix/home or ' + 'install-base/install-platbase -- not both'
     if self.home and (self.prefix or self.exec_prefix):
         raise DistutilsOptionError, 'must supply either home or prefix/exec-prefix -- not both'
     if self.user and (self.prefix or self.exec_prefix or self.home
                       or self.install_base or self.install_platbase):
         raise DistutilsOptionError(
             "can't combine user with prefix, exec_prefix/home, or install_(plat)base"
         )
     if os.name != 'posix':
         if self.exec_prefix:
             self.warn('exec-prefix option ignored on this platform')
             self.exec_prefix = None
     self.dump_dirs('pre-finalize_{unix,other}')
     if os.name == 'posix':
         self.finalize_unix()
     else:
         self.finalize_other()
     self.dump_dirs('post-finalize_{unix,other}()')
     py_version = string.split(sys.version)[0]
     prefix, exec_prefix = get_config_vars('prefix', 'exec_prefix')
     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],
         'sys_prefix': prefix,
         'prefix': prefix,
         'sys_exec_prefix': exec_prefix,
         'exec_prefix': exec_prefix,
         'userbase': self.install_userbase,
         'usersite': self.install_usersite
     }
     self.expand_basedirs()
     self.dump_dirs('post-expand_basedirs()')
     self.config_vars['base'] = self.install_base
     self.config_vars['platbase'] = self.install_platbase
     if DEBUG:
         from pprint import pprint
         print 'config vars:'
         pprint(self.config_vars)
     self.expand_dirs()
     self.dump_dirs('post-expand_dirs()')
     if self.user:
         self.create_home_path()
     if self.install_lib is None:
         if self.distribution.ext_modules:
             self.install_lib = self.install_platlib
         else:
             self.install_lib = self.install_purelib
     self.convert_paths('lib', 'purelib', 'platlib', 'scripts', 'data',
                        'headers', 'userbase', 'usersite')
     self.handle_extra_path()
     self.install_libbase = self.install_lib
     self.install_lib = os.path.join(self.install_lib, self.extra_dirs)
     if self.root is not None:
         self.change_roots('libbase', 'lib', 'purelib', 'platlib',
                           'scripts', 'data', 'headers')
     self.dump_dirs('after prepending root')
     self.set_undefined_options('build', ('build_base', 'build_base'),
                                ('build_lib', 'build_lib'))
     return