How to use the setupmeta.pkg_req function in setupmeta

To help you get started, we’ve selected a few setupmeta examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zsimic / setupmeta / tests / test_commands.py View on Github external
def from_string(self, specs):
        result = []
        for spec in specs.split():
            name, _, req = spec.partition(":")
            if req:
                req = [setupmeta.pkg_req(r) for r in req.split("+")]
            else:
                req = []
            result.append(FakeDist(name, req))
        return result
github zsimic / setupmeta / tests / test_model.py View on Github external
def test_requirements():
    assert setupmeta.pkg_req(None) is None
    assert setupmeta.pkg_req("#foo") is None

    assert setupmeta.requirements_from_file("/dev/null/foo") is None

    sample = conftest.resouce("scenarios/disabled/requirements.txt")
    f = setupmeta.RequirementsFile.from_file(sample)
    assert len(f.reqs) == 8
    assert str(f.reqs[0]) == "wheel from tests/scenarios/disabled/requirements.txt:2, abstracted by default"
    assert str(f.reqs[4]) == "-e git+git://example.com/p1.git#egg=flake8#egg=flake8 from tests/scenarios/disabled/requirements.txt:12"
    assert f.filled_requirements == ["wheel", "click; python_version >= '3.6'", "setuptools", "flake8", "pytest-cov"]
    assert f.dependency_links == [
        "git+git://example.com/p1.git#egg=flake8",
        "https://example.com/a.git@u/pp",
        "file:///tmp/bar1",
        "file:///tmp/bar2",
    ]
github zsimic / setupmeta / tests / test_commands.py View on Github external
def __init__(self, spec, requires):
        req = setupmeta.pkg_req(spec)
        self.key = req.key
        self.version = req.specs[0][1] if req.specs else "1.0"
        self._requires = requires
github zsimic / setupmeta / tests / test_model.py View on Github external
def test_requirements():
    assert setupmeta.pkg_req(None) is None
    assert setupmeta.pkg_req("#foo") is None

    assert setupmeta.requirements_from_file("/dev/null/foo") is None

    sample = conftest.resouce("scenarios/disabled/requirements.txt")
    f = setupmeta.RequirementsFile.from_file(sample)
    assert len(f.reqs) == 8
    assert str(f.reqs[0]) == "wheel from tests/scenarios/disabled/requirements.txt:2, abstracted by default"
    assert str(f.reqs[4]) == "-e git+git://example.com/p1.git#egg=flake8#egg=flake8 from tests/scenarios/disabled/requirements.txt:12"
    assert f.filled_requirements == ["wheel", "click; python_version >= '3.6'", "setuptools", "flake8", "pytest-cov"]
    assert f.dependency_links == [
        "git+git://example.com/p1.git#egg=flake8",
        "https://example.com/a.git@u/pp",
        "file:///tmp/bar1",
        "file:///tmp/bar2",
    ]
    assert len(f.abstracted) == 2
github zsimic / setupmeta / setupmeta / commands.py View on Github external
def get_packages(self, dependencies):
        result = []
        for dep in dependencies:
            p = self.get_package(setupmeta.pkg_req(dep))
            if p:
                result.append(p)

        return result
github zsimic / setupmeta / setupmeta / commands.py View on Github external
def __init__(self, obj, package):
        """
        :param pkg_resources.Requirement obj:
        :param PipPackage package: Associated package
        """
        self._obj = obj
        self.package = package
        self.key = obj.key
        self.version = package.version
        self.version_spec = ",".join(["".join(sp) for sp in sorted(obj.specs, reverse=True)])
        self.version_rec = setupmeta.pkg_req("%s%s" % (self.key, self.version_spec or ""))
        self.is_conflicting = not self.package.version or self.package.version not in self.version_rec