allennlp

Форк
0
/
setup.py 
107 строк · 3.6 Кб
1
from collections import defaultdict
2
from setuptools import find_packages, setup
3

4
# PEP0440 compatible formatted version, see:
5
# https://www.python.org/dev/peps/pep-0440/
6
#
7
# release markers:
8
#   X.Y
9
#   X.Y.Z   # For bugfix releases
10
#
11
# pre-release markers:
12
#   X.YaN   # Alpha release
13
#   X.YbN   # Beta release
14
#   X.YrcN  # Release Candidate
15
#   X.Y     # Final release
16

17

18
def parse_requirements_file(path, allowed_extras: set = None, include_all_extra: bool = True):
19
    requirements = []
20
    extras = defaultdict(list)
21
    with open(path) as requirements_file:
22
        import re
23

24
        def fix_url_dependencies(req: str) -> str:
25
            """Pip and setuptools disagree about how URL dependencies should be handled."""
26
            m = re.match(
27
                r"^(git\+)?(https|ssh)://(git@)?github\.com/([\w-]+)/(?P<name>[\w-]+)\.git", req
28
            )
29
            if m is None:
30
                return req
31
            else:
32
                return f"{m.group('name')} @ {req}"
33

34
        for line in requirements_file:
35
            line = line.strip()
36
            if line.startswith("#") or len(line) <= 0:
37
                continue
38
            req, *needed_by = line.split("# needed by:")
39
            req = fix_url_dependencies(req.strip())
40
            if needed_by:
41
                for extra in needed_by[0].strip().split(","):
42
                    extra = extra.strip()
43
                    if allowed_extras is not None and extra not in allowed_extras:
44
                        raise ValueError(f"invalid extra '{extra}' in {path}")
45
                    extras[extra].append(req)
46
                if include_all_extra and req not in extras["all"]:
47
                    extras["all"].append(req)
48
            else:
49
                requirements.append(req)
50
    return requirements, extras
51

52

53
integrations = {"checklist"}
54

55
# Load requirements.
56
install_requirements, extras = parse_requirements_file(
57
    "requirements.txt", allowed_extras=integrations
58
)
59
dev_requirements, dev_extras = parse_requirements_file(
60
    "dev-requirements.txt", allowed_extras={"examples"}, include_all_extra=False
61
)
62
extras["dev"] = dev_requirements
63
extras.update(dev_extras)
64

65
# version.py defines the VERSION and VERSION_SHORT variables.
66
# We use exec here so we don't import allennlp whilst setting up.
67
VERSION = {}  # type: ignore
68
with open("allennlp/version.py", "r") as version_file:
69
    exec(version_file.read(), VERSION)
70

71
setup(
72
    name="allennlp",
73
    version=VERSION["VERSION"],
74
    description="An open-source NLP research library, built on PyTorch.",
75
    long_description=open("README.md", encoding="utf-8").read(),
76
    long_description_content_type="text/markdown",
77
    classifiers=[
78
        "Intended Audience :: Science/Research",
79
        "Development Status :: 3 - Alpha",
80
        "License :: OSI Approved :: Apache Software License",
81
        "Programming Language :: Python :: 3",
82
        "Topic :: Scientific/Engineering :: Artificial Intelligence",
83
    ],
84
    keywords="allennlp NLP deep learning machine reading",
85
    url="https://github.com/allenai/allennlp",
86
    author="Allen Institute for Artificial Intelligence",
87
    author_email="allennlp@allenai.org",
88
    license="Apache",
89
    packages=find_packages(
90
        exclude=[
91
            "*.tests",
92
            "*.tests.*",
93
            "tests.*",
94
            "tests",
95
            "test_fixtures",
96
            "test_fixtures.*",
97
            "benchmarks",
98
            "benchmarks.*",
99
        ]
100
    ),
101
    install_requires=install_requirements,
102
    extras_require=extras,
103
    entry_points={"console_scripts": ["allennlp=allennlp.__main__:run"]},
104
    include_package_data=True,
105
    python_requires=">=3.7.1",
106
    zip_safe=False,
107
)
108

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.