diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index caa0bb2d..a3417533 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -16,7 +16,7 @@ jobs: - run: | python -m pip install --upgrade pip pip install -r requirements.txt - pip install -r requirements-types.txt + pip install -r requirements/types.txt - uses: liskin/gh-problem-matcher-wrap@v2 with: action: add @@ -40,6 +40,6 @@ jobs: with: python-version: "3.8" - - run: pip install -r requirements.txt + - run: pip install -r requirements/docs.txt - run: pip install -e . - run: sphinx-build doc build diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b5d825d3..effcefc5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -74,7 +74,7 @@ def get_protected_branch(self): First you need to install the test dependencies: ```bash -pip install -r test-requirements.txt +pip install -r requirements/test.txt ``` Then you can run the tests through `pytest`. diff --git a/requirements.txt b/requirements.txt index ccffb419..2841d9ca 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,7 @@ -pynacl>=1.4.0 +pynacl >=1.4.0 python-dateutil -requests>=2.14.0 -pyjwt[crypto]>=2.4.0 +requests >=2.14.0 +pyjwt[crypto] >=2.4.0 +typing-extensions >=4.0.0 urllib3 -sphinx<3 -Jinja2<3.1 -sphinx-rtd-theme<1.1 Deprecated diff --git a/requirements/docs.txt b/requirements/docs.txt new file mode 100644 index 00000000..8aa29cb1 --- /dev/null +++ b/requirements/docs.txt @@ -0,0 +1,3 @@ +sphinx <3 +Jinja2 <3.1 +sphinx-rtd-theme <1.1 \ No newline at end of file diff --git a/requirements/test.txt b/requirements/test.txt new file mode 100644 index 00000000..49c8322a --- /dev/null +++ b/requirements/test.txt @@ -0,0 +1,4 @@ +httpretty >=1.0.3 +pytest >=5.3 +pytest-cov >=2.8 +pytest-github-actions-annotate-failures <1.0.0 diff --git a/requirements-types.txt b/requirements/types.txt similarity index 83% rename from requirements-types.txt rename to requirements/types.txt index 39a80e21..2a122e36 100644 --- a/requirements-types.txt +++ b/requirements/types.txt @@ -1,4 +1,4 @@ -mypy +mypy >=1.0.0 types-deprecated types-jwt types-python-dateutil diff --git a/setup.py b/setup.py index e6c4b75c..538658b9 100755 --- a/setup.py +++ b/setup.py @@ -1,5 +1,4 @@ #!/usr/bin/env python - ############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # @@ -40,10 +39,21 @@ # # ################################################################################ +import os import textwrap import setuptools +_PATH_ROOT = os.path.dirname(__file__) +_PATH_REQUIRES = os.path.join(_PATH_ROOT, "requirements") + + +def _load_requirements(path_dir: str = _PATH_ROOT, file_name: str = "requirements.txt") -> "list[str]": + with open(os.path.join(path_dir, file_name)) as fp: + reqs = [ln.strip() for ln in fp.readlines()] + return [r for r in reqs if r and not r.startswith("#")] + + if __name__ == "__main__": setuptools.setup( name="PyGithub", @@ -110,15 +120,8 @@ if __name__ == "__main__": "Topic :: Software Development", ], python_requires=">=3.7", - install_requires=[ - "deprecated", - "pyjwt[crypto]>=2.4.0", - "pynacl>=1.4.0", - "requests>=2.14.0", - "python-dateutil", - "typing-extensions>=4.0.0", - ], + install_requires=_load_requirements(path_dir=_PATH_ROOT, file_name="requirements.txt"), # can be removed, still here to avoid breaking user code extras_require={"integrations": []}, - tests_require=["httpretty>=1.0.3"], + tests_require=_load_requirements(path_dir=_PATH_REQUIRES, file_name="test.txt"), ) diff --git a/test-requirements.txt b/test-requirements.txt deleted file mode 100644 index 47cc7641..00000000 --- a/test-requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -httpretty>=1.0.3 -pytest>=5.3 -pytest-cov>=2.8 -pytest-github-actions-annotate-failures<1.0.0 diff --git a/tox.ini b/tox.ini index 88c1cb55..7afb2363 100644 --- a/tox.ini +++ b/tox.ini @@ -15,14 +15,14 @@ python = 3.11: py311 [testenv] -deps = -rtest-requirements.txt +deps = -rrequirements/test.txt commands = pytest --cov=github --cov-report=xml {posargs} [testenv:lint] basepython = python3.8 skip_install = true deps = - -r requirements-types.txt + -r requirements/types.txt pre-commit commands = pre-commit run --all-files --show-diff-on-failure