Ejemplo n.º 1
0
def test_format_python_constraint_single_version():
    constraint = parse_constraint("3.6")

    result = format_python_constraint(constraint)

    assert result == ">=3.6,<3.7"

    constraint = parse_constraint("3")

    result = format_python_constraint(constraint)

    assert result == ">=3.0,<4.0"
Ejemplo n.º 2
0
def test_format_python_constraint():
    parser = VersionParser()
    constraint = parser.parse_constraints('~2.7 || ^3.6')

    result = format_python_constraint(constraint)

    assert result == '>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*'
Ejemplo n.º 3
0
    def from_package(cls, package):  # type: (...) -> Metadata
        meta = cls()

        meta.name = canonicalize_name(package.name)
        meta.version = normalize_version(package.version.text)
        meta.summary = package.description
        if package.readme:
            with package.readme.open(encoding="utf-8") as f:
                meta.description = f.read()

        meta.keywords = ",".join(package.keywords)
        meta.home_page = package.homepage or package.repository_url
        meta.author = package.author_name
        meta.author_email = package.author_email

        if package.license:
            meta.license = package.license.id

        meta.classifiers = package.all_classifiers

        # Version 1.2
        meta.maintainer = meta.author
        meta.maintainer_email = meta.author_email

        # Requires python
        if package.python_versions != "*":
            meta.requires_python = format_python_constraint(
                package.python_constraint)

        meta.requires_dist = [d.to_pep_508() for d in package.requires]

        # Version 2.1
        if package.readme:
            if package.readme.suffix == ".rst":
                meta.description_content_type = "text/x-rst"
            elif package.readme.suffix in [".md", ".markdown"]:
                meta.description_content_type = "text/markdown"
            else:
                meta.description_content_type = "text/plain"

        meta.provides_extra = [e for e in package.extras]

        if package.urls:
            for name, url in package.urls.items():
                if name == "Homepage" and meta.home_page == url:
                    continue

                meta.project_urls += ("{}, {}".format(name, url), )

        return meta
Ejemplo n.º 4
0
    def from_package(cls, package):  # type: (...) -> Metadata
        meta = cls()

        meta.name = canonicalize_name(package.name)
        meta.version = package.version
        meta.summary = package.description
        if package.readme:
            with package.readme.open() as f:
                meta.description = f.read()

        meta.keywords = ','.join(package.keywords)
        meta.home_page = package.homepage or package.repository_url
        meta.author = package.author_name
        meta.author_email = package.author_email

        if package.license:
            meta.license = package.license.id

        meta.classifiers = package.all_classifiers

        # Version 1.2
        meta.maintainer = meta.author
        meta.maintainer_email = meta.author_email
        meta.requires_python = package.python_constraint

        meta.requires_dist = [d.to_pep_508() for d in package.requires]

        # Requires python
        meta.requires_python = format_python_constraint(
            package.python_constraint)

        # Version 2.1
        if package.readme:
            if package.readme.suffix == '.rst':
                meta.description_content_type = 'text/x-rst'
            elif package.readme.suffix in ['.md', '.markdown']:
                meta.description_content_type = 'text/markdown'
            else:
                meta.description_content_type = 'text/plain'

        meta.provides_extra = [e for e in package.extras]

        return meta
Ejemplo n.º 5
0
    def from_package(cls, package):  # type: (...) -> Metadata
        meta = cls()

        meta.name = canonicalize_name(package.name)
        meta.version = normalize_version(package.version.text)
        meta.summary = package.description
        if package.readme:
            with package.readme.open() as f:
                meta.description = f.read()

        meta.keywords = ",".join(package.keywords)
        meta.home_page = package.homepage or package.repository_url
        meta.author = package.author_name
        meta.author_email = package.author_email

        if package.license:
            meta.license = package.license.id

        meta.classifiers = package.all_classifiers

        # Version 1.2
        meta.maintainer = meta.author
        meta.maintainer_email = meta.author_email

        # Requires python
        if not package.python_constraint.is_any():
            meta.requires_python = format_python_constraint(package.python_constraint)

        meta.requires_dist = [d.to_pep_508() for d in package.requires]

        # Version 2.1
        if package.readme:
            if package.readme.suffix == ".rst":
                meta.description_content_type = "text/x-rst"
            elif package.readme.suffix in [".md", ".markdown"]:
                meta.description_content_type = "text/markdown"
            else:
                meta.description_content_type = "text/plain"

        meta.provides_extra = [e for e in package.extras]

        return meta
Ejemplo n.º 6
0
def test_format_python_constraint():
    constraint = parse_constraint("~2.7 || ^3.6")

    result = format_python_constraint(constraint)

    assert result == ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*"