From 4005e52a541327c81f37e425fa4cb5de1a1903c7 Mon Sep 17 00:00:00 2001 From: Andrew Grigorev Date: Thu, 5 Sep 2024 23:15:09 +0300 Subject: [PATCH] Update for year 2024 - Use `pyproject.toml` and Hatchling - Update CI workflow and actions versions - Enable attestations for publishing - Publish releases on Test PyPI and GitHub - Drop Python 3.6 and 3.7 support due to EOL - Add Python 3.12 and 3.13.0-rc.1 to the test matrix --- .github/workflows/release.yml | 112 +++++++++++++++++++++++++--------- .gitignore | 2 + LICENSE | 2 +- pyproject.toml | 43 +++++++++++++ setup.cfg | 5 -- setup.py | 32 ---------- 6 files changed, 130 insertions(+), 66 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7eec733..671b0e0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,43 +5,43 @@ on: pull_request: jobs: + build: - name: Build wheel + name: Build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: "3.10" - - name: Install setuptools and wheel - run: pip install setuptools wheel - - name: Run bdist_wheel - run: python setup.py bdist_wheel --universal + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + - name: Install build + run: pip install build + - name: Build distribution + run: python -m build . + - name: File list + run: tar tf dist/*.tar.gz && unzip -l dist/*.whl - name: Upload artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: wheel - path: dist/*.whl + name: dist + path: dist/ + test: name: Run tests needs: build strategy: matrix: - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] - os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13.0-rc.1"] + os: [ubuntu-latest, macos-13, macos-latest, windows-latest] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - name: Download wheel from artifacts - uses: actions/download-artifact@v3 - with: - name: wheel + - name: Download artifacts + uses: actions/download-artifact@v4 - name: Install wheel shell: bash - run: pip install *.whl + run: pip install dist/*.whl - name: Make it use package from wheel shell: bash run: rm flask_shell_ipython.py @@ -54,19 +54,75 @@ jobs: if: runner.os == 'Windows' shell: bash run: pytest --collect-only -q | grep ^test_ | while read testname; do pytest -q $testname; done - pypi-publish: - name: Upload release to PyPI + + pypi-publish-test: + name: Release on Test PyPI needs: test - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') runs-on: ubuntu-latest - environment: release + environment: + name: Test PyPI + url: "https://test.pypi.org/project/flask-shell-ipython/" permissions: id-token: write steps: - name: Download artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: "https://test.pypi.org/legacy/" + attestations: true + + github-release: + name: Release on GitHub + needs: test + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + environment: + name: GitHub + url: "https://github.com/ei-grad/flask-shell-ipython/releases/" + permissions: + contents: write # IMPORTANT: mandatory for making GitHub Releases + id-token: write # IMPORTANT: mandatory for sigstore + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + - name: Sign the dists with Sigstore + uses: sigstore/gh-action-sigstore-python@v3 with: - name: wheel - path: dist/ + inputs: >- + ./dist/*.tar.gz + ./dist/*.whl + - name: Create GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + run: >- + gh release create + '${{ github.ref_name }}' + --repo '${{ github.repository }}' + --generate-notes + - name: Upload artifact signatures to GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + run: >- + gh release upload + '${{ github.ref_name }}' dist/** + --repo '${{ github.repository }}' + + pypi-publish: + name: Release on PyPI + needs: test + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + environment: + name: PyPI + url: "https://pypi.org/project/flask-shell-ipython/" + permissions: + id-token: write + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 - name: Publish package distributions to PyPI uses: pypa/gh-action-pypi-publish@release/v1 + with: + attestations: true diff --git a/.gitignore b/.gitignore index 72364f9..f6e9f85 100644 --- a/.gitignore +++ b/.gitignore @@ -87,3 +87,5 @@ ENV/ # Rope project settings .ropeproject + +flask_shell_ipython-*/ diff --git a/LICENSE b/LICENSE index 472d077..7784032 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -The MIT License (MIT) +MIT License Copyright (c) 2016 Andrew Grigorev diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..58ff6ab --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,43 @@ +[build-system] +requires = ["hatchling==1.25.0"] +build-backend = "hatchling.build" + +[project] +name = "flask-shell-ipython" +version = "0.5.2" +description = "Replace default `flask shell` command by similar command running IPython." +readme = "README.md" +readme-content-type = "text/markdown" +requires-python = ">=3.8, <4.0" +license = "MIT" +# expect `license-files` field to break on any new version of hatch, because +# PEP-639 is already changed from this structure as of the time of writing +license-files = { paths = ["LICENSE"] } +authors = [ + { name = "Andrew Grigorev", email = "andrew@ei-grad.ru" } +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Framework :: Flask", + "Framework :: IPython", + "Intended Audience :: Developers", + "Programming Language :: Python :: 3", +] + +dependencies = [ + "Flask>=1.0", + "click", + "IPython>=5.0.0" +] + +[project.urls] +Homepage = "https://github.com/ei-grad/flask-shell-ipython" + +[project.entry-points."flask.commands"] +shell = "flask_shell_ipython:shell" + +[tool.hatch.build.targets.sdist] +exclude = [ + ".github", +] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 56a9af2..0000000 --- a/setup.cfg +++ /dev/null @@ -1,5 +0,0 @@ -[metadata] -license_files = LICENSE - -[bdist_wheel] -universal = 1 diff --git a/setup.py b/setup.py deleted file mode 100644 index b82731e..0000000 --- a/setup.py +++ /dev/null @@ -1,32 +0,0 @@ -from setuptools import setup -setup( - name="flask-shell-ipython", - author="Andrew Grigorev", - author_email="andrew@ei-grad.ru", - description="Replace default `flask shell` command by similar command running IPython.", - long_description=open("README.md").read(), - long_description_content_type='text/markdown', - url="http://github.com/ei-grad/flask-shell-ipython", - version="0.5.1", - py_modules=['flask_shell_ipython'], - python_requires=">=3.6, <4", - install_requires=[ - 'Flask>=1.0', - 'click', - 'IPython>=5.0.0', - ], - entry_points={ - 'flask.commands': [ - 'shell=flask_shell_ipython:shell', - ], - }, - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Environment :: Console', - 'Framework :: Flask', - 'Framework :: IPython', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python :: 3', - ] -)