diff --git a/.cruft.json b/.cruft.json index ca5da3cf..c714b739 100644 --- a/.cruft.json +++ b/.cruft.json @@ -1,6 +1,6 @@ { "template": "https://github.com/cthoyt/cookiecutter-snekpack", - "commit": "12edfcfa5f519467b5d834f0d4e706fb7cf4f065", + "commit": "b3664aa2dd1d01910b33ca36d9bc3493a61fa71c", "checkout": null, "context": { "cookiecutter": { diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..439db4c0 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/displaying-a-sponsor-button-in-your-repository +github: + - cthoyt diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..4dd950ea --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,17 @@ + + +## Summary + + diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6d8a4e7b..4867f6c4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,6 +4,10 @@ name: Tests +# by default, give the GITHUB_TOKEN no permissions +# See https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/controlling-permissions-for-github_token +permissions: { } + on: push: branches: [ main ] @@ -13,11 +17,16 @@ on: jobs: lint: name: Code Quality + permissions: + # give only read-only access to the contents of the repository + # this is the only permission this job requires, so keep it to the least privilege + # i.e., not to issues, discussions, actions, etc. + contents: read runs-on: ubuntu-latest strategy: matrix: - python-version: [ "3.12", "3.10" ] - tox-command: ["manifest", "lint", "pyroma", "mypy"] + python-version: [ "3.13", "3.10" ] + tox-command: [ "lint", "pyroma", "mypy" ] steps: - uses: actions/checkout@v4 - name: "Install uv" @@ -31,13 +40,15 @@ jobs: docs: name: Documentation + permissions: + contents: read runs-on: ubuntu-latest strategy: matrix: # We only test documentation on the latest version # sphinx 8.0 / sphinx-rtd-theme 3.0 discontinued Python 3.9 support # a year early, which prompted re-thinking about this. - python-version: [ "3.12" ] + python-version: [ "3.13" ] steps: - uses: actions/checkout@v4 - name: "Install uv" @@ -56,11 +67,13 @@ jobs: run: uvx -p ${{ matrix.python-version }} --with tox-uv tox -e docs-test tests: name: Tests + permissions: + contents: read runs-on: ${{ matrix.os }} strategy: matrix: os: [ ubuntu-latest ] - python-version: [ "3.12", "3.10" ] + python-version: [ "3.13", "3.10" ] steps: - uses: actions/checkout@v4 - name: "Install uv" diff --git a/.readthedocs.yml b/.readthedocs.yml index 5212949a..79bf96fc 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -12,9 +12,12 @@ build: tools: python: "3.12" -python: - install: - - method: pip - path: . - extra_requirements: - - docs + # adapted from uv recipe at https://docs.readthedocs.io/en/stable/build-customization.html#install-dependencies-with-uv + # and comment at https://github.com/readthedocs/readthedocs.org/issues/11289#issuecomment-2103832834 + commands: + - asdf plugin add uv + - asdf install uv latest + - asdf global uv latest + - uv venv $READTHEDOCS_VIRTUALENV_PATH + - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH UV_PREVIEW=1 uv pip install .[docs] + - python -m sphinx -T -b html -d docs/_build/doctrees -D language=en docs/source $READTHEDOCS_OUTPUT/html diff --git a/README.md b/README.md index 268f412a..0e3b85ad 100644 --- a/README.md +++ b/README.md @@ -481,9 +481,16 @@ The final section of the README is for if you want to get involved by making a c To install in development mode, use the following: ```console -git clone git+https://github.com/biopragmatics/pyobo.git -cd pyobo -python3 -m pip install -e . +$ git clone git+https://github.com/biopragmatics/pyobo.git +$ cd pyobo +$ uv --preview pip install -e . +``` + +Alternatively, install using legacy pip with `UV_PREVIEW` mode enabled +until the uv build backend becomes a stable feature: + +```console +$ UV_PREVIEW=1 python3 -m pip install -e . ``` ### Updating Package Boilerplate @@ -578,7 +585,7 @@ You only have to do the following steps once. #### Configuring your machine's connection to PyPI -You have to do the following steps once per machine. +You have to do the following steps once per machine. ```console $ uv tool install keyring diff --git a/docs/source/conf.py b/docs/source/conf.py index 8f84320f..95924b91 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -256,3 +256,6 @@ todo_include_todos = True todo_emit_warnings = True + +# Output SVG inheritance diagrams +graphviz_output_format = "svg" diff --git a/docs/source/installation.rst b/docs/source/installation.rst index b89dab96..b2a01cc2 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -5,13 +5,13 @@ The most recent release can be installed from .. code-block:: shell - pip install pyobo + python3 -m pip install pyobo The most recent code and data can be installed directly from GitHub with: .. code-block:: shell - pip install git+https://github.com/biopragmatics/pyobo.git + python3 -m pip install git+https://github.com/biopragmatics/pyobo.git To install in development mode, use the following: @@ -19,4 +19,7 @@ To install in development mode, use the following: git clone git+https://github.com/biopragmatics/pyobo.git cd pyobo - pip install -e . + UV_PREVIEW=1 python3 -m pip install -e . + +Note that the ``UV_PREVIEW`` environment variable is required to be +set until the uv build backend becomes a stable feature. diff --git a/pyproject.toml b/pyproject.toml index a23d4c0b..7491fb91 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,8 @@ -# See https://setuptools.readthedocs.io/en/latest/build_meta.html [build-system] -requires = ["setuptools", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["uv>=0.5.13,<0.6.0"] +# The uv backend entered preview mode in https://github.com/astral-sh/uv/pull/8886/files +# with the 0.5.0 release. See also https://github.com/astral-sh/uv/issues/3957 for tracking. +build-backend = "uv" [project] name = "pyobo" @@ -26,11 +27,14 @@ classifiers = [ "Framework :: Pytest", "Framework :: tox", "Framework :: Sphinx", + "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3 :: Only", + "Typing :: Typed", "Topic :: Scientific/Engineering :: Bio-Informatics", "Topic :: Scientific/Engineering :: Chemistry", ] @@ -47,10 +51,11 @@ keywords = [ "OBO", ] -# License Information. This can be any valid SPDX identifiers that can be resolved -# with URLs like https://spdx.org/licenses/MIT -# See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license -license = { file = "LICENSE" } +# License Information. +# See PEP-639 at https://peps.python.org/pep-0639/#add-license-files-key +license-files = [ + "LICENSE", +] requires-python = ">=3.10" dependencies = [ @@ -86,7 +91,7 @@ dependencies = [ [project.optional-dependencies] tests = [ "pytest", - "coverage", + "coverage[toml]", ] docs = [ "sphinx>=8", @@ -96,22 +101,13 @@ docs = [ ] # See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#urls +# and also https://packaging.python.org/en/latest/specifications/well-known-project-urls/ [project.urls] "Bug Tracker" = "https://github.com/biopragmatics/pyobo/issues" Homepage = "https://github.com/biopragmatics/pyobo" Repository = "https://github.com/biopragmatics/pyobo.git" Documentation = "https://pyobo.readthedocs.io" - -[tool.setuptools] -package-dir = { "" = "src" } - -[tool.setuptools.packages.find] -# this implicitly sets `packages = ":find"` -where = ["src"] # list of folders that contain the packages (["."] by default) - -# See https://setuptools.pypa.io/en/latest/userguide/datafiles.html -[tool.setuptools.package-data] -"*" = ["*.*"] +Funding = "https://github.com/sponsors/cthoyt" [project.scripts] pyobo = "pyobo.cli:main" diff --git a/tox.ini b/tox.ini index e02773dc..ca73de51 100644 --- a/tox.ini +++ b/tox.ini @@ -16,7 +16,6 @@ envlist = format # format-docs # Code quality assessment - manifest pyroma lint mypy @@ -28,7 +27,12 @@ envlist = py doctests # always keep coverage-report last - # coverage-report + coverage-report + +[testenv:.pkg] +# this special environment configures the build that tox does itself +set_env = + UV_PREVIEW=1 [testenv] description = Run unit and integration tests. @@ -41,6 +45,10 @@ commands = extras = # See the [project.optional-dependencies] entry in pyproject.toml for "tests" tests +set_env = + # this setting gets inherited into all environments, meaning + # that things that call uv commands don't require a --preview + UV_PREVIEW=1 [testenv:coverage-clean] description = Remove testing coverage artifacts. @@ -85,12 +93,6 @@ skip_install = true commands = rstfmt docs/source/ -[testenv:manifest] -deps = check-manifest -skip_install = true -commands = check-manifest -description = Check that the MANIFEST.in is written properly and give feedback on how to fix it. - [testenv:lint] description = Check code quality using ruff and other tools. @@ -168,11 +170,9 @@ allowlist_externals = mkdir [testenv:coverage-report] -# TODO this is broken -deps = coverage +deps = coverage[toml] skip_install = true commands = - coverage combine coverage report #################### @@ -199,7 +199,6 @@ deps = skip_install = true deps = uv - setuptools commands = uv build --sdist --wheel --no-build-isolation @@ -219,7 +218,7 @@ commands = # 7. Add your token to keyring with `keyring set https://upload.pypi.org/legacy/ __token__` [testenv:release] -description = Release the code to PyPI so users can pip install it +description = Release the code to PyPI so users can pip install it, using credentials from keyring skip_install = true deps = {[testenv:build]deps} @@ -229,6 +228,19 @@ commands = {[testenv:build]commands} uv publish --username __token__ --keyring-provider subprocess --publish-url https://upload.pypi.org/legacy/ +[testenv:release-via-env] +description = Release the code to PyPI so users can pip install it, using credentials from the environment. +skip_install = true +deps = + {[testenv:build]deps} + uv +commands = + {[testenv:build]commands} + uv publish --publish-url https://upload.pypi.org/legacy/ +passenv = + UV_PUBLISH_USERNAME + UV_PUBLISH_PASSWORD + [testenv:finish] description = Run a workflow that removes -dev from the version, creates a tagged release on GitHub,