From d80cf0a7913a68db1a8183516ac2aa1040bed066 Mon Sep 17 00:00:00 2001 From: Chris Rose Date: Mon, 17 Apr 2023 19:52:04 -0700 Subject: [PATCH 1/8] Modernize the build: switch to hatchling - generate the version from vcs metadata (tags) - use hatchling as a build system --- .gitignore | 1 + dev-requirements.txt | 8 +---- pyproject.toml | 77 ++++++++++++++++++++++++++++++++++++++++ setup.cfg | 47 ------------------------ setup.py | 4 --- src/github3/__about__.py | 5 +-- tox.ini | 6 ++-- 7 files changed, 82 insertions(+), 66 deletions(-) delete mode 100644 setup.cfg delete mode 100755 setup.py diff --git a/.gitignore b/.gitignore index e4375d82..28cc87d9 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,4 @@ t.py *.pem /.python-version /.tool-versions +src/github3/_version.py diff --git a/dev-requirements.txt b/dev-requirements.txt index c614fcd7..e7ab444a 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,7 +1 @@ -. -pytest>=7.0 -pytest-xdist[psutil] -wheel -betamax>=0.5.1 -betamax_matchers>=0.3.0 -tox>=3.1.3 +.[dev] diff --git a/pyproject.toml b/pyproject.toml index ff87a2a0..2d8a7857 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,79 @@ +[build-system] +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build" + +[project] +name = "github3.py" +description = "Python wrapper for the GitHub API(http://developer.github.com/v3)" +readme = "README.rst" +requires-python = ">= 3.7" +url = "https://github3.readthedocs.io" +authors = [ + { name = "Ian Stapleton Cordasco", email="graffatcolmingov@gmail.com" }, +] +license = "BSD-3-Clause" +license_file = "LICENSE" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved", + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: Implementation :: CPython", +] + +dynamic = ["version"] + +dependencies = [ + "PyJWT[crypto]>=2.3.0", + "python-dateutil>=2.6.0", + "requests>=2.18", + "uritemplate>=3.0.0", +] + +[project.optional-dependencies] +test = [ + "pytest>=7.0", + "pytest-xdist[psutil]", + "betamax>=0.5.1", + "betamax_matchers>=0.3.0", +] + +dev = [ + "github3.py[test]", + "wheel", + "build", + "twine", + "tox>=3.1.3", +] + +[tool.hatch.version] +source = "vcs" + +[tool.hatch.build.hooks.vcs] +version-file = "src/github3/_version.py" +template = """\ +# coding: utf-8 +# file generated by hatch VCS +# don't change, don't track in version control +__version__ = {version!r} # pragma: no mutate +__version_info__ = {version_tuple!r} # pragma: no mutate +""" + +[tool.hatch.build.targets.wheel] +packages = [ + "src/github3", +] + + +[project.urls] +Documentation = "https://github3.readthedocs.io" +Changelog = "https://github3.readthedocs.io/en/latest/release-notes/index.html" +Source = "https://github.com/sigmavirus24/github3.py" +"Released Versions" = "https://github.com/sigmavirus24/github3.py/tags" + [tool.black] line-length = 78 target-version = ['py37'] @@ -15,5 +91,6 @@ exclude = ''' | build | dist )/ + | src/github3/_version.py ) ''' diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 1f422ee8..00000000 --- a/setup.cfg +++ /dev/null @@ -1,47 +0,0 @@ -[metadata] -name = github3.py -version = attr:github3.__about__.__version__ -description = Python wrapper for the GitHub API(http://developer.github.com/v3) -long_description = file: README.rst -long_description_content_type = text/x-rst -url = https://github3.readthedocs.io -author = Ian Stapleton Cordasco -author_email = graffatcolmingov@gmail.com -license = BSD-3-Clause -license_file = LICENSE -classifiers = - Development Status :: 5 - Production/Stable - Intended Audience :: Developers - License :: OSI Approved - License :: OSI Approved :: BSD License - Programming Language :: Python - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: Implementation :: CPython -project_urls = - Documentation = https://github3.readthedocs.io - Changelog = https://github3.readthedocs.io/en/latest/release-notes/index.html - Source = https://github.com/sigmavirus24/github3.py - Released Versions = https://github.com/sigmavirus24/github3.py/tags -requires_dist = - requests>=2.0 - uritemplate>=3.0.0 - python-dateutil>=2.6.0 - PyJWT>=2.3.0 - -[options] -packages = find: -install_requires = - PyJWT[crypto]>=2.3.0 - python-dateutil>=2.6.0 - requests>=2.18 - uritemplate>=3.0.0 -python_requires = >=3.7 -package_dir = - =src - -[options.packages.find] -where = src - -[wheel] -universal = 1 diff --git a/setup.py b/setup.py deleted file mode 100755 index 6d1ca271..00000000 --- a/setup.py +++ /dev/null @@ -1,4 +0,0 @@ -"""Packaging logic.""" -import setuptools - -setuptools.setup() diff --git a/src/github3/__about__.py b/src/github3/__about__.py index 4312e99d..939a3712 100644 --- a/src/github3/__about__.py +++ b/src/github3/__about__.py @@ -5,11 +5,8 @@ __author_email__ = "graffatcolmingov@gmail.com" __license__ = "Modified BSD" __copyright__ = "Copyright 2012-2022 Ian Stapleton Cordasco" -__version__ = "3.2.0" -__version_info__ = tuple( - int(i) for i in __version__.split(".") if i.isdigit() -) __url__ = "https://github3.readthedocs.io" +from ._version import __version__, __version_info__ __all__ = ( "__package_name__", diff --git a/tox.ini b/tox.ini index d0fca657..87234049 100644 --- a/tox.ini +++ b/tox.ini @@ -7,11 +7,8 @@ passenv = GH_* pip_pre = False deps = requests{env:REQUESTS_VERSION:>=2.0} - pytest - pytest-xdist[psutil] - betamax>=0.5.1 - betamax_matchers>=0.3.0 pypy3: unittest2 +extras = test commands = pytest {posargs} [testenv:flake8] @@ -112,3 +109,4 @@ ignore-path-errors = docs/source/release-notes/1.0.0.rst;D001 [flake8] extend-ignore = E203,W503 max-line-length = 80 +exclude = src/github3/_version.py From f30220e891616279faef6b960c05e1d94ca8fac2 Mon Sep 17 00:00:00 2001 From: Chris Rose Date: Mon, 17 Apr 2023 21:07:18 -0700 Subject: [PATCH 2/8] dev: include tags when checking out code hatch-vcs needs this --- .github/workflows/build.yml | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 90af019d..df860861 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,23 +4,29 @@ on: [push, pull_request] jobs: test: - runs-on: ubuntu-latest strategy: matrix: python: - { VERSION: "3.7", TOXENV: "py37", ALLOW_FAILURE: false } - - { VERSION: "3.8", TOXENV: "py38",ALLOW_FAILURE: false } - - { VERSION: "3.9", TOXENV: "py39",ALLOW_FAILURE: false } - - { VERSION: "3.10", TOXENV: "py310",ALLOW_FAILURE: false } - - { VERSION: "3.11", TOXENV: "py311",ALLOW_FAILURE: false } - - { VERSION: "3.10", TOXENV: "flake8,doclint,docs,commitlint", ALLOW_FAILURE: false } - - { VERSION: "3.10", TOXENV: "docstrings", ALLOW_FAILURE: true} + - { VERSION: "3.8", TOXENV: "py38", ALLOW_FAILURE: false } + - { VERSION: "3.9", TOXENV: "py39", ALLOW_FAILURE: false } + - { VERSION: "3.10", TOXENV: "py310", ALLOW_FAILURE: false } + - { VERSION: "3.11", TOXENV: "py311", ALLOW_FAILURE: false } + - { + VERSION: "3.10", + TOXENV: "flake8,doclint,docs,commitlint", + ALLOW_FAILURE: false, + } + - { VERSION: "3.10", TOXENV: "docstrings", ALLOW_FAILURE: true } - { VERSION: "pypy3.9", TOXENV: "pypy", ALLOW_FAILURE: false } steps: - name: Check out the repository uses: actions/checkout@v3 + with: + # We want our tags here + fetch-depth: 0 - name: Setup Python uses: actions/setup-python@v4.2.0 From b0ea8588e63d1338e4920b8e873768f9eaaf3bfb Mon Sep 17 00:00:00 2001 From: Chris Rose Date: Mon, 17 Apr 2023 21:11:18 -0700 Subject: [PATCH 3/8] dev: unpin tox and pip in actions --- .github/workflows/build.yml | 4 ++-- .github/workflows/constraints.txt | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) delete mode 100644 .github/workflows/constraints.txt diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index df860861..4d68d4b4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,12 +35,12 @@ jobs: - name: Upgrade pip run: | - pip install --constraint=.github/workflows/constraints.txt pip + pip install pip pip --version - name: Install Tox run: | - pip install --constraint=.github/workflows/constraints.txt tox + pip install tox tox --version - name: Run Tox diff --git a/.github/workflows/constraints.txt b/.github/workflows/constraints.txt deleted file mode 100644 index ed863a8c..00000000 --- a/.github/workflows/constraints.txt +++ /dev/null @@ -1,2 +0,0 @@ -pip==20.3.3 -tox==3.20.1 From a93f9f50ca424fdae49244c5e3698fcc268881a9 Mon Sep 17 00:00:00 2001 From: Chris Rose Date: Mon, 17 Apr 2023 21:28:09 -0700 Subject: [PATCH 4/8] dev: update tox twine check command --- tox.ini | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 87234049..f937253f 100644 --- a/tox.ini +++ b/tox.ini @@ -94,10 +94,12 @@ deps = -rdocs/source/requirements.txt sphinx_rtd_theme twine >= 3.4.2 + build . commands = sphinx-build -E -W -c docs/source/ -b html docs/source/ docs/build/html - twine check --strict {distdir}/* + python -m build + twine check --strict dist/* [pytest] addopts = -q -nauto From afc4593540b7471041dbe829d1cdd24b77a08bff Mon Sep 17 00:00:00 2001 From: Chris Rose Date: Tue, 18 Apr 2023 07:24:31 -0700 Subject: [PATCH 5/8] Return to manual versioning --- .github/workflows/build.yml | 3 --- .gitignore | 1 - pyproject.toml | 12 +----------- src/github3/__about__.py | 5 ++++- 4 files changed, 5 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4d68d4b4..c5e18aae 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,9 +24,6 @@ jobs: steps: - name: Check out the repository uses: actions/checkout@v3 - with: - # We want our tags here - fetch-depth: 0 - name: Setup Python uses: actions/setup-python@v4.2.0 diff --git a/.gitignore b/.gitignore index 28cc87d9..e4375d82 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,3 @@ t.py *.pem /.python-version /.tool-versions -src/github3/_version.py diff --git a/pyproject.toml b/pyproject.toml index 2d8a7857..b324cb4f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,17 +50,7 @@ dev = [ ] [tool.hatch.version] -source = "vcs" - -[tool.hatch.build.hooks.vcs] -version-file = "src/github3/_version.py" -template = """\ -# coding: utf-8 -# file generated by hatch VCS -# don't change, don't track in version control -__version__ = {version!r} # pragma: no mutate -__version_info__ = {version_tuple!r} # pragma: no mutate -""" +path = "src/github3/__about__.py" [tool.hatch.build.targets.wheel] packages = [ diff --git a/src/github3/__about__.py b/src/github3/__about__.py index 939a3712..4312e99d 100644 --- a/src/github3/__about__.py +++ b/src/github3/__about__.py @@ -5,8 +5,11 @@ __author_email__ = "graffatcolmingov@gmail.com" __license__ = "Modified BSD" __copyright__ = "Copyright 2012-2022 Ian Stapleton Cordasco" +__version__ = "3.2.0" +__version_info__ = tuple( + int(i) for i in __version__.split(".") if i.isdigit() +) __url__ = "https://github3.readthedocs.io" -from ._version import __version__, __version_info__ __all__ = ( "__package_name__", From cc47a0bb28ed37e7c485ae706024997c0e03c919 Mon Sep 17 00:00:00 2001 From: Chris Rose Date: Tue, 18 Apr 2023 07:26:47 -0700 Subject: [PATCH 6/8] Switch the Python used for docs and linting to 3.11 --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c5e18aae..13892dcd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,11 +14,11 @@ jobs: - { VERSION: "3.10", TOXENV: "py310", ALLOW_FAILURE: false } - { VERSION: "3.11", TOXENV: "py311", ALLOW_FAILURE: false } - { - VERSION: "3.10", + VERSION: "3.11", TOXENV: "flake8,doclint,docs,commitlint", ALLOW_FAILURE: false, } - - { VERSION: "3.10", TOXENV: "docstrings", ALLOW_FAILURE: true } + - { VERSION: "3.11", TOXENV: "docstrings", ALLOW_FAILURE: true } - { VERSION: "pypy3.9", TOXENV: "pypy", ALLOW_FAILURE: false } steps: From 935174de342e2146c6c10fcc33096bd762c7ff76 Mon Sep 17 00:00:00 2001 From: Chris Rose Date: Tue, 18 Apr 2023 08:31:16 -0700 Subject: [PATCH 7/8] Update the developer documentation and dependency setup --- AUTHORS.rst | 2 ++ Makefile | 2 +- README.rst | 6 +++--- dev-requirements.txt | 1 - 4 files changed, 6 insertions(+), 5 deletions(-) delete mode 100644 dev-requirements.txt diff --git a/AUTHORS.rst b/AUTHORS.rst index 195675ed..14af8d38 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -220,3 +220,5 @@ Contributors - Peter Küffner (@kuepe-sl) - Andrew MacCormack (@amaccormack-lumira) + +- Chris R (@offbyone) diff --git a/Makefile b/Makefile index e176fd67..4801b410 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ ga: tests: ga test-deps: - pip install -r dev-requirements.txt + pip install -e .[dev] htmlcov: .coverage coverage html --omit=github3/packages/* diff --git a/README.rst b/README.rst index 72b3e0e6..1799ee4a 100644 --- a/README.rst +++ b/README.rst @@ -37,9 +37,9 @@ Please read the `CONTRIBUTING`_ document. Testing ~~~~~~~ -You can run either ``pip install -r dev-requirements.txt`` to install the -following before testing or simply ``make test-deps``. It is suggested you do -this in a virtual environment. These need to be installed for the tests to run. +You can run ``pip install -e .[dev]`` to install the following before testing or +simply ``make test-deps``. It is suggested you do this in a virtual environment. +These need to be installed for the tests to run. - betamax_ - coverage_ by Ned Batchelder diff --git a/dev-requirements.txt b/dev-requirements.txt deleted file mode 100644 index e7ab444a..00000000 --- a/dev-requirements.txt +++ /dev/null @@ -1 +0,0 @@ -.[dev] From 46286be64759c83f9573300d931202f02ae8f82b Mon Sep 17 00:00:00 2001 From: Chris Rose Date: Thu, 20 Apr 2023 00:15:14 -0600 Subject: [PATCH 8/8] Clean up hatch-vcs debris in pyproject.toml --- pyproject.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b324cb4f..57259d73 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["hatchling", "hatch-vcs"] +requires = ["hatchling"] build-backend = "hatchling.build" [project] @@ -81,6 +81,5 @@ exclude = ''' | build | dist )/ - | src/github3/_version.py ) '''