Beispiel #1
0
    def _move_install_requirements_markers(self):
        """
        Move requirements in `install_requires` that are using environment
        markers `extras_require`.
        """

        # divide the install_requires into two sets, simple ones still
        # handled by install_requires and more complex ones handled
        # by extras_require.

        def is_simple_req(req):
            return not req.marker

        spec_inst_reqs = getattr(self, 'install_requires', None) or ()
        inst_reqs = list(pkg_resources.parse_requirements(spec_inst_reqs))
        simple_reqs = filter(is_simple_req, inst_reqs)
        complex_reqs = filterfalse(is_simple_req, inst_reqs)
        self.install_requires = list(map(str, simple_reqs))

        for r in complex_reqs:
            self._tmp_extras_require[':' + str(r.marker)].append(r)
        self.extras_require = dict(
            (k, [str(r) for r in map(self._clean_req, v)])
            for k, v in self._tmp_extras_require.items()
        )
def find_ca_bundle():
    """Return an existing CA bundle path, or None"""
    extant_cert_paths = filter(os.path.isfile, cert_paths)
    return (
        get_win_certfile()
        or next(extant_cert_paths, None)
        or _certifi_where()
    )
Beispiel #3
0
def _find_all_simple(path):
    """
    Find all files under 'path'
    """
    results = (
        os.path.join(base, file)
        for base, dirs, files in os.walk(path, followlinks=True)
        for file in files
    )
    return filter(os.path.isfile, results)
Beispiel #4
0
def _check_extra(extra, reqs):
    name, sep, marker = extra.partition(':')
    if marker and pkg_resources.invalid_marker(marker):
        raise DistutilsSetupError("Invalid environment marker: " + marker)

    # extras requirements cannot themselves have markers
    parsed = pkg_resources.parse_requirements(reqs)
    marked_reqs = filter(operator.attrgetter('marker'), parsed)
    bad_req = next(marked_reqs, None)
    if bad_req:
        tmpl = (
            "'extras_require' requirements cannot include "
            "environment markers, in {name!r}: '{bad_req!s}'"
        )
        raise DistutilsSetupError(tmpl.format(**locals()))
Beispiel #5
0
 def find_data_files(self, package, src_dir):
     """Return filenames for package's data files in 'src_dir'"""
     patterns = self._get_platform_patterns(
         self.package_data,
         package,
         src_dir,
     )
     globs_expanded = map(glob, patterns)
     # flatten the expanded globs into an iterable of matches
     globs_matches = itertools.chain.from_iterable(globs_expanded)
     glob_files = filter(os.path.isfile, globs_matches)
     files = itertools.chain(
         self.manifest_files.get(package, []),
         glob_files,
     )
     return self.exclude_data_files(package, src_dir, files)
Beispiel #6
0
    def paths_on_pythonpath(paths):
        """
        Add the indicated paths to the head of the PYTHONPATH environment
        variable so that subprocesses will also see the packages at
        these paths.

        Do this in a context that restores the value on exit.
        """
        nothing = object()
        orig_pythonpath = os.environ.get('PYTHONPATH', nothing)
        current_pythonpath = os.environ.get('PYTHONPATH', '')
        try:
            prefix = os.pathsep.join(paths)
            to_join = filter(None, [prefix, current_pythonpath])
            new_path = os.pathsep.join(to_join)
            if new_path:
                os.environ['PYTHONPATH'] = new_path
            yield
        finally:
            if orig_pythonpath is nothing:
                os.environ.pop('PYTHONPATH', None)
            else:
                os.environ['PYTHONPATH'] = orig_pythonpath
Beispiel #7
0
 def _add_defaults_optional(self):
     optional = ['test/test*.py', 'setup.cfg']
     for pattern in optional:
         files = filter(os.path.isfile, glob(pattern))
         self.filelist.extend(files)
def find_ca_bundle():
    """Return an existing CA bundle path, or None"""
    extant_cert_paths = list(filter(os.path.isfile, cert_paths))
    return (get_win_certfile() or next(extant_cert_paths, None)
            or _certifi_where())
 def _add_defaults_optional(self):
     optional = ['test/test*.py', 'setup.cfg']
     for pattern in optional:
         files = filter(os.path.isfile, glob(pattern))
         # noinspection PyUnresolvedReferences
         self.filelist.extend(files)
 def _add_defaults_optional(self):
     optional = ['test/test*.py', 'setup.cfg']
     for pattern in optional:
         files = filter(os.path.isfile, glob(pattern))
         self.filelist.extend(files)