Ejemplo n.º 1
0
 def _check_deps(self, metadata):
     plugins = {k.__name__.replace('_', '-'): Distribution(
         os.path.dirname(k.__file__), None, k.__name__, k.__version__,
         None, SOURCE_DIST) for k in veles.__plugins__}
     failed_general = set()
     failed_veles = set()
     for rreq in metadata["requires"]:
         req = Requirement.parse(rreq)
         if req.project_name in plugins:
             if plugins[req.project_name] not in req:
                 failed_veles.add(req)
         else:
             try:
                 working_set.find(req).project_name
             except (AttributeError, VersionConflict):
                 failed_general.add(req)
     if len(failed_general) > 0:
         print("Unsatisfied package requirements:", file=sys.stderr)
         print(", ".join((str(f) for f in failed_general)), file=sys.stderr)
     if len(failed_veles):
         print("Unsatisfied VELES requirements:", file=sys.stderr)
         print(", ".join((str(f) for f in failed_veles)), file=sys.stderr)
Ejemplo n.º 2
0
    def run(self):
        self.run_command("egg_info")
        if self.distribution.scripts:
            _install_scripts.run(self)  # run first to set up self.outfiles
        else:
            self.outfiles = []
        if self.no_ep:
            # don't install entry point scripts into .egg file!
            return

        ei_cmd = self.get_finalized_command("egg_info")
        dist = Distribution(
            ei_cmd.egg_base,
            PathMetadata(ei_cmd.egg_base, ei_cmd.egg_info),
            ei_cmd.egg_name,
            ei_cmd.egg_version,
        )
        bs_cmd = self.get_finalized_command('build_scripts')
        executable = getattr(bs_cmd, 'executable', sys_executable)

        for args in get_script_args(dist, executable):
            self.write_script(*args)
Ejemplo n.º 3
0
    def run(self):
        import setuptools.command.easy_install as ei

        self.run_command("egg_info")
        if self.distribution.scripts:
            orig.install_scripts.run(self)  # run first to set up self.outfiles
        else:
            self.outfiles = []
        if self.no_ep:
            # don't install entry point scripts into .egg file!
            return

        ei_cmd = self.get_finalized_command("egg_info")
        dist = Distribution(
            ei_cmd.egg_base,
            PathMetadata(ei_cmd.egg_base, ei_cmd.egg_info),
            ei_cmd.egg_name,
            ei_cmd.egg_version,
        )
        bs_cmd = self.get_finalized_command("build_scripts")
        exec_param = getattr(bs_cmd, "executable", None)
        try:
            bw_cmd = self.get_finalized_command("bdist_wininst")
            is_wininst = getattr(bw_cmd, "_is_running", False)
        except ImportError:
            is_wininst = False
        writer = ei.ScriptWriter
        if is_wininst:
            exec_param = "python.exe"
            writer = ei.WindowsScriptWriter
        if exec_param == sys.executable:
            # In case the path to the Python executable contains a space, wrap
            # it so it's not split up.
            exec_param = [exec_param]
        # resolve the writer to the environment
        writer = writer.best()
        cmd = writer.command_spec_class.best().from_param(exec_param)
        for args in writer.get_args(dist, cmd.as_header()):
            self.write_script(*args)
Ejemplo n.º 4
0
    def finalize_options(self):
        ei = self.get_finalized_command("egg_info")
        if ei.broken_egg_info:
            raise DistutilsError(
                "Please rename %r to %r before using 'develop'" %
                (ei.egg_info, ei.broken_egg_info))
        self.args = [ei.egg_name]
        easy_install.finalize_options(self)
        # pick up setup-dir .egg files only: no .egg-info
        self.package_index.scan(glob.glob('*.egg'))

        self.egg_link = os.path.join(self.install_dir,
                                     ei.egg_name + '.egg-link')
        self.egg_base = ei.egg_base
        if self.egg_path is None:
            self.egg_path = os.path.abspath(ei.egg_base)

        target = normalize_path(self.egg_base)
        if normalize_path(os.path.join(self.install_dir,
                                       self.egg_path)) != target:
            raise DistutilsOptionError(
                "--egg-path must be a relative path from the install"
                " directory to " + target)

        # Make a distribution for the package's source
        self.dist = Distribution(target,
                                 PathMetadata(target,
                                              os.path.abspath(ei.egg_info)),
                                 project_name=ei.egg_name)

        p = self.egg_base.replace(os.sep, '/')
        if p != os.curdir:
            p = '../' * (p.count('/') + 1)
        self.setup_path = p
        p = normalize_path(os.path.join(self.install_dir, self.egg_path, p))
        if p != normalize_path(os.curdir):
            raise DistutilsOptionError(
                "Can't get a consistent path to setup script from"
                " installation directory", p, normalize_path(os.curdir))
Ejemplo n.º 5
0
    def finalize_options(self):
        ei = self.get_finalized_command("egg_info")
        if ei.broken_egg_info:
            template = "Please rename %r to %r before using 'develop'"
            args = ei.egg_info, ei.broken_egg_info
            raise DistutilsError(template % args)
        self.args = [ei.egg_name]

        easy_install.finalize_options(self)
        self.expand_basedirs()
        self.expand_dirs()
        # pick up setup-dir .egg files only: no .egg-info
        self.package_index.scan(glob.glob('*.egg'))

        egg_link_fn = ei.egg_name + '.egg-link'
        self.egg_link = os.path.join(self.install_dir, egg_link_fn)
        self.egg_base = ei.egg_base
        if self.egg_path is None:
            self.egg_path = os.path.abspath(ei.egg_base)

        target = normalize_path(self.egg_base)
        egg_path = normalize_path(os.path.join(self.install_dir,
                                               self.egg_path))
        if egg_path != target:
            raise DistutilsOptionError(
                "--egg-path must be a relative path from the install"
                " directory to " + target)

        # Make a distribution for the package's source
        self.dist = Distribution(target,
                                 PathMetadata(target,
                                              os.path.abspath(ei.egg_info)),
                                 project_name=ei.egg_name)

        self.setup_path = self._resolve_setup_path(
            self.egg_base,
            self.install_dir,
            self.egg_path,
        )
Ejemplo n.º 6
0
    def test_no_valid_file(self):
        working_set = mocks.WorkingSet(
            {
                'nunja.mold': [
                    'nunja.testing.badmold = nunja.testing:badmold',
                ]
            },
            dist=Distribution(project_name='nunjatesting', version='0.0'))

        with pretty_logging(logger='nunja', stream=mocks.StringIO()) as stream:
            registry = MoldRegistry('nunja.mold', _working_set=working_set)

        records = registry.get_records_for_package('nunjatesting')

        self.assertEqual(
            sorted(records.keys()),
            ['text!nunja.testing.badmold/nomold/empty.nja'],
        )

        self.assertIn('1 templates', stream.getvalue())
        self.assertIn('0 scripts', stream.getvalue())
        self.assertIn('generated 0 molds', stream.getvalue())
Ejemplo n.º 7
0
    def finalize_options(self):
        ei_cmd = self.ei_cmd = self.get_finalized_command("egg_info")
        self.egg_info = ei_cmd.egg_info

        if self.bdist_dir is None:
            bdist_base = self.get_finalized_command('bdist').bdist_base
            self.bdist_dir = os.path.join(bdist_base, 'egg')

        if self.plat_name is None:
            self.plat_name = get_build_platform()

        self.set_undefined_options('bdist', ('dist_dir', 'dist_dir'))

        if self.egg_output is None:
            # Compute filename of the output egg
            basename = Distribution(
                None, None, ei_cmd.egg_name, ei_cmd.egg_version,
                get_python_version(),
                self.distribution.has_ext_modules()
                and self.plat_name).egg_name()

            self.egg_output = os.path.join(self.dist_dir, basename + '.egg')
Ejemplo n.º 8
0
def main():
    from distutils.dist import Distribution
    from optparse import OptionParser

    parser = OptionParser(usage='usage: %prog [options] test_suite ...',
                          version='%%prog %s' % VERSION)
    parser.add_option('-o',
                      '--xml-output',
                      action='store',
                      dest='xml_output',
                      metavar='FILE',
                      help='write XML test results to FILE')
    parser.add_option('-d',
                      '--coverage-dir',
                      action='store',
                      dest='coverage_dir',
                      metavar='DIR',
                      help='store coverage results in DIR')
    parser.add_option('-s',
                      '--coverage-summary',
                      action='store',
                      dest='coverage_summary',
                      metavar='FILE',
                      help='write coverage summary to FILE')
    options, args = parser.parse_args()
    if len(args) < 1:
        parser.error('incorrect number of arguments')

    cmd = unittest(Distribution())
    cmd.initialize_options()
    cmd.test_suite = args[0]
    if hasattr(options, 'xml_output'):
        cmd.xml_output = options.xml_output
    if hasattr(options, 'coverage_summary'):
        cmd.coverage_summary = options.coverage_summary
    if hasattr(options, 'coverage_dir'):
        cmd.coverage_dir = options.coverage_dir
    cmd.finalize_options()
    cmd.run()
def interpret_distro_name(location,
                          basename,
                          metadata,
                          py_version=None,
                          precedence=SOURCE_DIST,
                          platform=None):
    """Generate alternative interpretations of a source distro name

    Note: if `location` is a filesystem filename, you should call
    ``pkg_resources.normalize_path()`` on it before passing it to this
    routine!
    """
    # Generate alternative interpretations of a source distro name
    # Because some packages are ambiguous as to name/versions split
    # e.g. "adns-python-1.1.0", "egenix-mx-commercial", etc.
    # So, we generate each possible interepretation (e.g. "adns, python-1.1.0"
    # "adns-python, 1.1.0", and "adns-python-1.1.0, no version").  In practice,
    # the spurious interpretations should be ignored, because in the event
    # there's also an "adns" package, the spurious "python-1.1.0" version will
    # compare lower than any numeric version number, and is therefore unlikely
    # to match a request for it.  It's still a potential problem, though, and
    # in the long run PyPI and the distutils should go for "safe" names and
    # versions in distribution archive names (sdist and bdist).

    parts = basename.split("-")
    if not py_version and any(re.match(r"py\d\.\d$", p) for p in parts[2:]):
        # it is a bdist_dumb, not an sdist -- bail out
        return

    for p in range(1, len(parts) + 1):
        yield Distribution(
            location,
            metadata,
            "-".join(parts[:p]),
            "-".join(parts[p:]),
            py_version=py_version,
            precedence=precedence,
            platform=platform,
        )
Ejemplo n.º 10
0
class test_link_package_versions(object):

    # patch this for travis which has distribute in it's base env for now
    @patch('pip.wheel.pkg_resources.get_distribution',
           lambda x: Distribution(project_name='setuptools', version='0.9'))
    def setup(self):
        self.version = '1.0'
        self.parsed_version = parse_version(self.version)
        self.search_name = 'pytest'
        self.finder = PackageFinder([], [], use_wheel=True)

    def test_link_package_versions_match_wheel(self):
        """Test that 'pytest' archives match for 'pytest'"""

        # TODO: Uncomment these, when #1217 is fixed
        # link = Link('http:/yo/pytest-1.0.tar.gz')
        # result = self.finder._link_package_versions(link, self.search_name)
        # assert result == [(self.parsed_version, link, self.version)], result

        link = Link('http:/yo/pytest-1.0-py2.py3-none-any.whl')
        result = self.finder._link_package_versions(link, self.search_name)
        assert result == [(self.parsed_version, link, self.version)], result

    def test_link_package_versions_substring_fails(self):
        """Test that 'pytest<something> archives won't match for 'pytest'"""

        # TODO: Uncomment these, when #1217 is fixed
        # link = Link('http:/yo/pytest-xdist-1.0.tar.gz')
        # result = self.finder._link_package_versions(link, self.search_name)
        # assert result == [], result

        # link = Link('http:/yo/pytest2-1.0.tar.gz')
        # result = self.finder._link_package_versions(link, self.search_name)
        # assert result == [], result

        link = Link('http:/yo/pytest_xdist-1.0-py2.py3-none-any.whl')
        result = self.finder._link_package_versions(link, self.search_name)
        assert result == [], result
Ejemplo n.º 11
0
    def test_registry_autoreload_base_support(self):
        # This is just to test the setup of the relevant entry correctly
        # but does not actually deal with the more dynamic functionality
        # that molds offer.
        setup_tmp_module(self)

        entry_points = ['tmp = tmp:mold']

        working_set = mocks.WorkingSet({'nunja.tmpl': entry_points},
                                       dist=Distribution(
                                           project_name='nunjatesting',
                                           version='0.0'))

        registry = JinjaTemplateRegistry.create(_working_set=working_set,
                                                auto_reload=False)
        self.assertFalse(registry.tracked_entry_points)
        with self.assertRaises(KeyError):
            registry.lookup_path('tmp/itemlist')

        registry = JinjaTemplateRegistry.create(_working_set=working_set,
                                                auto_reload=True)
        self.assertEqual(str(registry.tracked_entry_points['tmp']),
                         entry_points[0])
Ejemplo n.º 12
0
def test_list_one_installed(environment: Environment):
    env = Environment(search_path=[])
    environment.return_value = env
    metadata = """Metadata-Version: 2.1
Name: chaostoolkit-some-stuff
Version: 0.1.0
Summary: Chaos Toolkit some package
Home-page: http://chaostoolkit.org
Author: chaostoolkit Team
Author-email: [email protected]
License: Apache License 2.0
"""

    env.add(
        Distribution(project_name="chaostoolkit-some-stuff",
                     version="0.1.0",
                     metadata=InMemoryMetadata({"PKG-INFO": metadata})))
    extensions = list_extensions()
    assert len(extensions) == 1

    ext = extensions[0]
    assert ext.name == "chaostoolkit-some-stuff"
    assert ext.version == "0.1.0"
Ejemplo n.º 13
0
    def _venv_match(self, installed, requirements):
        """Return True if what is installed satisfies the requirements.

        This method has multiple exit-points, but only for False (because
        if *anything* is not satisified, the venv is no good). Only after
        all was checked, and it didn't exit, the venv is ok so return True.
        """
        if not requirements:
            # special case for no requirements, where we can't actually
            # check anything: the venv is useful if nothing installed too
            return not bool(installed)

        useful_inst = set()
        for repo, req_deps in requirements.items():
            if repo not in installed:
                # the venv doesn't even have the repo
                return False

            inst_deps = {
                Distribution(project_name=dep, version=ver)
                for (dep, ver) in installed[repo].items()
            }
            for req in req_deps:
                for inst in inst_deps:
                    if inst in req:
                        useful_inst.add(inst)
                        break
                else:
                    # nothing installed satisfied that requirement
                    return False

            # assure *all* that is installed is useful for the requirements
            if useful_inst != inst_deps:
                return False

        # it did it through!
        return True
Ejemplo n.º 14
0
def get_distrib(*dep_ver_pairs):
    """Build some Distributions with indicated info."""
    return [
        Distribution(project_name=dep, version=ver)
        for dep, ver in dep_ver_pairs
    ]
Ejemplo n.º 15
0
 def distRequires(self, txt):
     return Distribution("/foo", metadata=Metadata(('depends.txt', txt)))
Ejemplo n.º 16
0
 def distribution(self):
     return Distribution(project_name=self._interpreter,
                         version='.'.join(map(str, self._version)))
Ejemplo n.º 17
0
 def __init__(self, name, module_name):
     super(MockEntryPoint,
           self).__init__(name,
                          module_name,
                          dist=Distribution(version='1.2.3'))
Ejemplo n.º 18
0
 def create_fake_distribution(name):
     return Distribution(project_name="cerberus", version="1.2.3")
Ejemplo n.º 19
0
    def finalize_options(self):
        ei = self.get_finalized_command("egg_info")
        if ei.broken_egg_info:
            raise DistutilsError(
            "Please rename %r to %r before using 'develop'"
            % (ei.egg_info, ei.broken_egg_info)
            )
        self.args = [ei.egg_name]


        py_version = sys.version.split()[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,
                           }

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

        # fix the install_dir if "--user" was used
        if self.user:
            self.create_home_path()
            if self.install_userbase is None:
                raise DistutilsPlatformError(
                    "User base directory is not specified")
            self.install_base = self.install_platbase = self.install_userbase
            if os.name == 'posix':
                self.select_scheme("unix_user")
            else:
                self.select_scheme(os.name + "_user")

        self.expand_basedirs()
        self.expand_dirs()

        if self.user and self.install_purelib:
            self.install_dir = self.install_purelib
            self.script_dir = self.install_scripts

        easy_install.finalize_options(self)
        # pick up setup-dir .egg files only: no .egg-info
        self.package_index.scan(glob.glob('*.egg'))

        self.egg_link = os.path.join(self.install_dir, ei.egg_name+'.egg-link')
        self.egg_base = ei.egg_base
        if self.egg_path is None:
            self.egg_path = os.path.abspath(ei.egg_base)

        target = normalize_path(self.egg_base)
        if normalize_path(os.path.join(self.install_dir, self.egg_path)) != target:
            raise DistutilsOptionError(
                "--egg-path must be a relative path from the install"
                " directory to "+target
        )

        # Make a distribution for the package's source
        self.dist = Distribution(
            target,
            PathMetadata(target, os.path.abspath(ei.egg_info)),
            project_name = ei.egg_name
        )

        p = self.egg_base.replace(os.sep,'/')
        if p!= os.curdir:
            p = '../' * (p.count('/')+1)
        self.setup_path = p
        p = normalize_path(os.path.join(self.install_dir, self.egg_path, p))
        if  p != normalize_path(os.curdir):
            raise DistutilsOptionError(
                "Can't get a consistent path to setup script from"
                " installation directory", p, normalize_path(os.curdir))
Ejemplo n.º 20
0
 def _mock_distribution(name):
     return Distribution(version='1.2.3')
    def get_mock_plugin(name,
                        version,
                        reg=None,
                        alias=None,
                        after=None,
                        rules=None,
                        target_types=None):
        """Make a fake Distribution (optionally with entry points)

        Note the entry points do not actually point to code in the returned distribution --
        the distribution does not even have a location and does not contain any code, just metadata.

        A module is synthesized on the fly and installed into sys.modules under a random name.
        If optional entry point callables are provided, those are added as methods to the module and
        their name (foo/bar/baz in fake module) is added as the requested entry point to the mocked
        metadata added to the returned dist.

        :param string name: project_name for distribution (see pkg_resources)
        :param string version: version for distribution (see pkg_resources)
        :param callable reg: Optional callable for goal registration entry point
        :param callable alias: Optional callable for build_file_aliases entry point
        :param callable after: Optional callable for load_after list entry point
        :param callable rules: Optional callable for rules entry point
        :param callable target_types: Optional callable for target_types entry point
        """

        plugin_pkg = f"demoplugin{uuid.uuid4().hex}"
        pkg = types.ModuleType(plugin_pkg)
        sys.modules[plugin_pkg] = pkg
        module_name = f"{plugin_pkg}.demo"
        plugin = types.ModuleType(module_name)
        setattr(pkg, "demo", plugin)
        sys.modules[module_name] = plugin

        metadata = {}
        entry_lines = []

        if reg is not None:
            setattr(plugin, "foo", reg)
            entry_lines.append(f"register_goals = {module_name}:foo\n")

        if alias is not None:
            setattr(plugin, "bar", alias)
            entry_lines.append(f"build_file_aliases = {module_name}:bar\n")

        if after is not None:
            setattr(plugin, "baz", after)
            entry_lines.append(f"load_after = {module_name}:baz\n")

        if rules is not None:
            setattr(plugin, "qux", rules)
            entry_lines.append(f"rules = {module_name}:qux\n")

        if target_types is not None:
            setattr(plugin, "tofu", target_types)
            entry_lines.append(f"target_types = {module_name}:tofu\n")

        if entry_lines:
            entry_data = "[pantsbuild.plugin]\n{}\n".format(
                "\n".join(entry_lines))
            metadata = {"entry_points.txt": entry_data}

        return Distribution(project_name=name,
                            version=version,
                            metadata=MockMetadata(metadata))
Ejemplo n.º 22
0
    def get_mock_plugin(self,
                        name,
                        version,
                        reg=None,
                        alias=None,
                        after=None,
                        rules=None):
        """Make a fake Distribution (optionally with entry points)

    Note the entry points do not actually point to code in the returned distribution --
    the distribution does not even have a location and does not contain any code, just metadata.

    A module is synthesized on the fly and installed into sys.modules under a random name.
    If optional entry point callables are provided, those are added as methods to the module and
    their name (foo/bar/baz in fake module) is added as the requested entry point to the mocked
    metadata added to the returned dist.

    :param string name: project_name for distribution (see pkg_resources)
    :param string version: version for distribution (see pkg_resources)
    :param callable reg: Optional callable for goal registration entry point
    :param callable alias: Optional callable for build_file_aliases entry point
    :param callable after: Optional callable for load_after list entry point
    :param callable rules: Optional callable for rules entry point
    """

        plugin_pkg = 'demoplugin{0}'.format(uuid.uuid4().hex)
        if PY2:
            plugin_pkg = plugin_pkg.encode('utf-8')
        pkg = types.ModuleType(plugin_pkg)
        sys.modules[plugin_pkg] = pkg
        module_name = '{0}.{1}'.format(plugin_pkg, 'demo')
        if PY2:
            module_name = module_name.encode('utf-8')
        plugin = types.ModuleType(module_name)
        setattr(pkg, 'demo', plugin)
        sys.modules[module_name] = plugin

        metadata = {}
        entry_lines = []

        if reg is not None:
            setattr(plugin, 'foo', reg)
            entry_lines.append('register_goals = {}:foo\n'.format(module_name))

        if alias is not None:
            setattr(plugin, 'bar', alias)
            entry_lines.append(
                'build_file_aliases = {}:bar\n'.format(module_name))

        if after is not None:
            setattr(plugin, 'baz', after)
            entry_lines.append('load_after = {}:baz\n'.format(module_name))

        if rules is not None:
            setattr(plugin, 'qux', rules)
            entry_lines.append('rules = {}:qux\n'.format(module_name))

        if entry_lines:
            entry_data = '[pantsbuild.plugin]\n{}\n'.format(
                '\n'.join(entry_lines))
            metadata = {'entry_points.txt': entry_data}

        return Distribution(project_name=name,
                            version=version,
                            metadata=MockMetadata(metadata))
Ejemplo n.º 23
0
 def _get_egg_name(self):
     ei_cmd = self.get_finalized_command("egg_info")
     return Distribution(
         None, None, ei_cmd.egg_name, ei_cmd.egg_version, get_python_version(),
         self.distribution.has_ext_modules() and self.plat_name).egg_name()
Ejemplo n.º 24
0
 def distribution(self):
   return Distribution(project_name=self.interpreter, version=self.version_str)
Ejemplo n.º 25
0
 def test_distribution_as_key(self):
     mapping = base.PackageKeyMapping()
     mapping[Distribution(project_name='not_normalized')] = 1
     self.assertEqual(1, mapping['not_normalized'])
     self.assertEqual(1, mapping[safe_name('not_normalized')])
Ejemplo n.º 26
0
 def egg_name(self):
     return Distribution(
         project_name=self.project_name,
         version=self.version,
         platform=(None if self.platform == 'any' else get_platform()),
     ).egg_name() + '.egg'
Ejemplo n.º 27
0
#!/usr/bin/python
# Copyright (C) 2008, Charles Wang <*****@*****.**>
# Author: Charles Wang <*****@*****.**>
# License: BSD

import os.path
import shutil
import sys
from pkg_resources import Distribution
from pypi2pkgsys.package_system import package_system
from pypi2pkgsys.pypi_objects import pypicache

if len(sys.argv) < 4:
    print 'Usage: %s CACHE_ROOT CACHE_URL FILENAME,DISTNAME ...' % sys.argv[0]
    sys.exit(-1)

cacheroot = sys.argv[1]
cacheurl = sys.argv[2]
downloads = os.path.join(cacheroot, 'downloads')
distlist = []
for arg in sys.argv[3:]:
    filename, distname = arg.split(',')
    dlfname = os.path.join(downloads, os.path.basename(filename))
    print 'Copy %s %s ...' % (filename, dlfname)
    shutil.copyfile(filename, dlfname)
    dist = Distribution(dlfname, None, project_name=distname)
    distlist.append(dist)
cache = pypicache(package_system(), cacheroot, cacheurl)
cache.add_packages(distlist)
del (cache)
Ejemplo n.º 28
0
import unittest
from os import path

from pkg_resources import Distribution, EntryPoint

from nichtparasoup.imagecrawler import KnownImageCrawlers

from .testdata_imagecrawler_plugin import (
    BaseLoadableImageCrawlerA,
    LoadableImageCrawlerA,
    LoadableImageCrawlerB,
    StandaloneLoadableImageCrawlerA,
)

_TEST_PLUGIN_DIST = Distribution(
    location=path.abspath('testdata_imagecrawler_plugin'),
    project_name='testdata-imagecrawler-plugin')
_TEST_PLUGIN_CLASS = LoadableImageCrawlerA
_TEST_PLUGIN_ENTRY = EntryPoint('Test',
                                _TEST_PLUGIN_CLASS.__module__,
                                attrs=(_TEST_PLUGIN_CLASS.__name__, ),
                                dist=_TEST_PLUGIN_DIST)


class KnownImageCrawlersLoadTest(unittest.TestCase):
    def test_success(self) -> None:
        # arrange
        entry = _TEST_PLUGIN_ENTRY
        # act
        loaded = KnownImageCrawlers._load(entry)
        # assert
Ejemplo n.º 29
0
    assert_equal(
        parse_editable('.[extras]', 'git'),
        (None, 'file://' + "/some/path", ('extras',))
    )
    normcase_mock.return_value = "/some/path/foo"
    assert_equal(
        parse_editable('foo[bar,baz]', 'git'),
        (None, 'file:///some/path/foo', ('bar', 'baz'))
    )

def test_remote_reqs_parse():
    """
    Test parsing a simple remote requirements file
    """
    # this requirements file just contains a comment
    # previously this has failed in py3 (https://github.com/pypa/pip/issues/760)
    for req in parse_requirements('https://raw.github.com/pypa/pip-test-package/master/tests/req_just_comment.txt'):
        pass

# patch this for travis which has distribute in it's base env for now
@patch('pip.wheel.pkg_resources.get_distribution', lambda x: Distribution(project_name='setuptools', version='0.9'))
def test_req_file_parse_use_wheel():
    """
    Test parsing --use-wheel from a req file
    """
    reqfile = os.path.join(tests_data, 'reqfiles', 'supported_options.txt')
    finder = PackageFinder([], [])
    for req in parse_requirements(reqfile, finder):
        pass
    assert finder.use_wheel
Ejemplo n.º 30
0
# -*- coding: utf-8 -*-
import io

from pkg_resources import Distribution
from pkg_resources import EntryPoint
from pkg_resources import EmptyProvider

from setuptools.command.egg_info import egg_info

_dist = Distribution()
dummy = object()


class WorkingSet(object):

    def __init__(self, items, dist=_dist):
        self.items = items
        self.dist = dist

    def iter_entry_points(self, name):
        items = self.items.get(name, [])
        for item in items:
            entry_point = item if isinstance(
                item, EntryPoint) else EntryPoint.parse(item)
            entry_point.dist = self.dist
            yield entry_point

    def find(self, name):
        # just always return the dist.
        return self.dist