From 7fcf67ae2d86bed3ce8d9fb03662e8656ab6c756 Mon Sep 17 00:00:00 2001 From: Sebastien Jourdain Date: Sun, 29 Dec 2024 16:12:17 -0700 Subject: [PATCH] fix: migrate to pyproject --- .github/FUNDING.yml | 2 +- .github/workflows/docker.yml | 2 +- .github/workflows/test_and_release.yml | 29 +++++--- .github/workflows/website.yaml | 4 +- pyproject.toml | 93 ++++++++++++++++++++++++++ ruff.toml | 11 --- setup.cfg | 35 ---------- setup.py | 3 - 8 files changed, 115 insertions(+), 64 deletions(-) create mode 100644 pyproject.toml delete mode 100644 ruff.toml delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 1f3ff727..b54ee514 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,3 +1,3 @@ # These are supported funding model platforms -custom: 'https://www.kitware.com/contact-us/' \ No newline at end of file +custom: 'https://www.kitware.com/trame/' \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index e30d6a6b..cc3703a3 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -30,7 +30,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/.github/workflows/test_and_release.yml b/.github/workflows/test_and_release.yml index 270656f9..f243c3aa 100644 --- a/.github/workflows/test_and_release.yml +++ b/.github/workflows/test_and_release.yml @@ -10,9 +10,9 @@ jobs: pre-commit: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v5 with: python-version: "3.9" @@ -28,7 +28,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.9] + python-version: ["3.9"] config: - { name: "Linux", @@ -49,16 +49,16 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install and Run Tests run: | - pip install . + pip install ".[dev]" pip install -r tests/requirements.txt # Run the tests with coverage so we get a coverage report too pip install coverage @@ -73,7 +73,7 @@ jobs: runs-on: ubuntu-latest name: Check and Lint steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: fetch-depth: 0 # needed so commitlint can lint the commits @@ -96,16 +96,23 @@ jobs: needs: [pre-commit, pytest, check-and-lint] runs-on: ubuntu-latest if: github.event_name == 'push' + environment: release + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + contents: write # IMPORTANT: mandatory for making GitHub Releases steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Python Semantic Release - uses: relekang/python-semantic-release@v7.34.6 + id: release + uses: python-semantic-release/python-semantic-release@master with: github_token: ${{ secrets.GITHUB_TOKEN }} - repository_username: __token__ - repository_password: ${{ secrets.PYPI_API_TOKEN }} + + - name: Publish package distributions to PyPI + if: steps.release.outputs.released == 'true' + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/website.yaml b/.github/workflows/website.yaml index 6b884eed..dd95ca1a 100644 --- a/.github/workflows/website.yaml +++ b/.github/workflows/website.yaml @@ -27,11 +27,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 # Not needed if lastUpdated is not enabled - name: Setup Node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 18 - name: Setup Pages diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..e46a66d3 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,93 @@ +[project] +name = "trame" +version = "3.7.1" +description = "Trame, a framework to build applications in plain Python" +authors = [ + {name = "Kitware Inc."}, +] +dependencies = [ + "trame-server>=3.2.3,<4", + "trame-client>=3.4,<4", + "wslink>=2.1.3", +] +requires-python = ">=3.9" +readme = "README.rst" +license = {text = "Apache License 2.0"} +keywords = ["Python", "Interactive", "Web", "Application", "Framework"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Web Environment", + "License :: OSI Approved :: Apache License", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3 :: Only", + "Topic :: Software Development :: Libraries :: Application Frameworks", + "Topic :: Software Development :: Libraries :: Python Modules", +] + +[project.optional-dependencies] +app = [ + "pywebview", +] +jupyter = [ + "jupyterlab", +] +dev = [ + "pre-commit", + "ruff", + "pytest", +] + +[build-system] +requires = ['setuptools', 'wheel'] +build-backend = 'setuptools.build_meta' + +[tool.setuptools.packages.find] +where = ["."] + +[tool.setuptools.package-data] + + +[tool.semantic_release] +version_toml = [ + "pyproject.toml:project.version", +] +build_command = """ + python -m venv .venv + source .venv/bin/activate + pip install -U pip build + python -m build . +""" + +[semantic_release.publish] +dist_glob_patterns = ["dist/*"] +upload_to_vcs_release = true + +[tool.ruff] +line-length = 88 +indent-width = 4 +target-version = "py39" + +[tool.ruff.lint] +select = ["E", "W", "F"] +ignore = [] +fixable = ["ALL"] +unfixable = [] + + +[tool.ruff.format] +quote-style = "double" +indent-style = "space" +skip-magic-trailing-comma = false +line-ending = "auto" +docstring-code-format = true + +# This only has an effect when the `docstring-code-format` setting is +# enabled. +docstring-code-line-length = "dynamic" + +[tool.ruff.lint.pycodestyle] +max-line-length = 120 + +[lint.pydocstyle] +convention = "google" diff --git a/ruff.toml b/ruff.toml deleted file mode 100644 index 0bca7939..00000000 --- a/ruff.toml +++ /dev/null @@ -1,11 +0,0 @@ -target-version = "py39" -line-length = 88 - -[lint] -select = ["E", "W", "F"] - -[lint.pycodestyle] -max-line-length = 120 - -[lint.pydocstyle] -convention = "google" \ No newline at end of file diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 50c13bb3..00000000 --- a/setup.cfg +++ /dev/null @@ -1,35 +0,0 @@ -[metadata] -name = trame -version = 3.7.1 -description = Trame, a framework to build applications in plain Python -long_description = file: README.rst -long_description_content_type = text/x-rst -author = Kitware Inc. -license = Apache License 2.0 -classifiers = - Development Status :: 5 - Production/Stable - Environment :: Web Environment - License :: OSI Approved :: Apache Software License - Natural Language :: English - Operating System :: OS Independent - Programming Language :: Python :: 3 :: Only - Topic :: Software Development :: Libraries :: Application Frameworks - Topic :: Software Development :: Libraries :: Python Modules -keywords = - Python - Interactive - Web - Application - Framework - -[options] -packages = find: -include_package_data = True -install_requires = - trame-server>=3.2.3,<4 - trame-client>=3.4,<4 - # generic backend fixed for trame.tools.serve - wslink>=2.1.3 - -[semantic_release] -version_pattern = setup.cfg:version = (\d+\.\d+\.\d+) diff --git a/setup.py b/setup.py deleted file mode 100644 index 60684932..00000000 --- a/setup.py +++ /dev/null @@ -1,3 +0,0 @@ -from setuptools import setup - -setup()