diff --git a/.cruft.json b/.cruft.json index 6faa97e7e..99c1947a1 100644 --- a/.cruft.json +++ b/.cruft.json @@ -1,7 +1,7 @@ { "template": "https://github.com/scverse/cookiecutter-scverse", - "commit": "605f95714130c960bce12eab98a4e023e8932249", - "checkout": "v0.2.22", + "commit": "8e96abb5c3e2d5078c44713958da672711cf2a48", + "checkout": "v0.3.0", "context": { "cookiecutter": { "project_name": "scirpy", @@ -16,6 +16,11 @@ ".github/workflows/**.yaml", "docs/_templates/autosummary/**.rst" ], + "_render_devdocs": false, + "_jinja2_env_vars": { + "lstrip_blocks": true, + "trim_blocks": true + }, "_template": "https://github.com/scverse/cookiecutter-scverse" } }, diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 9352d045e..bd82eb55b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,30 +1,29 @@ name: Release on: - push: - tags: - - "*.*.*" + release: + types: [published] +# Use "trusted publishing", see https://docs.pypi.org/trusted-publishers/ jobs: release: - name: Release + name: Upload release to PyPI runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/{{ cookiecutter.package_name }} + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Set up Python 3.10 - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 with: - python-version: "3.10" - - - name: Install hatch - run: pip install hatch - - - name: Build project for distribution - run: hatch build - - - name: Publish a Python distribution to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 + filter: blob:none + fetch-depth: 0 + - uses: actions/setup-python@v4 with: - password: ${{ secrets.PYPI_API_TOKEN }} + python-version: "3.x" + cache: "pip" + - run: pip install build + - run: python -m build + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index edab0b486..0230ee0ac 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -26,10 +26,13 @@ jobs: - os: ubuntu-latest python: "3.9" - os: ubuntu-latest - python: "3.10" + python: "3.11" - os: ubuntu-latest - python: "3.10" + python: "3.11" pip-flags: "--pre" + name: PRE-RELEASE DEPENDENCIES + + name: ${{ matrix.name }} Python ${{ matrix.python }} env: OS: ${{ matrix.os }} @@ -59,6 +62,9 @@ jobs: PLATFORM: ${{ matrix.os }} DISPLAY: :42 run: | - pytest -v --cov --color=yes + coverage run -m pytest -v --color=yes + - name: Report coverage + run: | + coverage report - name: Upload coverage uses: codecov/codecov-action@v3 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7b6f7c958..28566a5d2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,7 @@ default_stages: minimum_pre_commit_version: 2.16.0 repos: - repo: https://github.com/psf/black - rev: "23.10.1" + rev: "23.12.1" hooks: - id: black - repo: https://github.com/asottile/blacken-docs @@ -26,7 +26,7 @@ repos: language_version: "17.9.1" exclude: '^\.conda' - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.4 + rev: v0.1.9 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/README.md b/README.md index 9e1b60f1f..88de01ae9 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Please consider making a tax-deductible [donation](https://numfocus.org/donate-t > -[badge-tests]: https://img.shields.io/github/actions/workflow/status/grst/scirpy/test.yaml?branch=main +[badge-tests]: https://img.shields.io/github/actions/workflow/status/scverse/scirpy/test.yaml?branch=main [link-tests]: https://github.com/scverse/scirpy/actions/workflows/test.yml [badge-docs]: https://img.shields.io/readthedocs/scirpy [badge-pypi]: https://img.shields.io/pypi/v/scirpy?logo=PyPI @@ -69,7 +69,7 @@ There are several alternative options to install scirpy: 3. Install the latest development version: ```bash - pip install git+https://github.com/grst/scirpy.git@main + pip install git+https://github.com/scverse/scirpy.git@main ``` 4. Run it in a container using [Docker][] or [Podman][]: @@ -123,7 +123,7 @@ You can cite the scverse publication as follows: > [10.1038/s41587-023-01733-8](https://doi.org/10.1038/s41587-023-01733-8). [scverse-discourse]: https://discourse.scverse.org/ -[issue-tracker]: https://github.com/grst/scirpy/issues +[issue-tracker]: https://github.com/scverse/scirpy/issues [changelog]: https://scirpy.readthedocs.io/latest/changelog.html [link-docs]: https://scirpy.readthedocs.io [link-api]: https://scirpy.readthedocs.io/latest/api.html diff --git a/docs/_static/css/custom.css b/docs/_static/css/custom.css new file mode 100644 index 000000000..b8c8d47fa --- /dev/null +++ b/docs/_static/css/custom.css @@ -0,0 +1,4 @@ +/* Reduce the font size in data frames - See https://github.com/scverse/cookiecutter-scverse/issues/193 */ +div.cell_output table.dataframe { + font-size: 0.8em; +} diff --git a/docs/conf.py b/docs/conf.py index eea484b22..67b5fd0ae 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -132,6 +132,7 @@ html_static_path = ["_static"] html_title = project_name html_logo = "img/scirpy_logo.png" +html_css_files = ["css/custom.css"] html_theme_options = { @@ -177,18 +178,3 @@ ("py:meth", "mudata.MuData.update"), ("py:class", "awkward.highlevel.Array"), ] - - -def setup(app): - """App setup hook.""" - app.add_config_value( - "recommonmark_config", - { - "auto_toc_tree_section": "Contents", - "enable_auto_toc_tree": True, - "enable_math": True, - "enable_inline_math": False, - "enable_eval_rst": True, - }, - True, - ) diff --git a/docs/contributing.md b/docs/contributing.md index 66a115c3b..a4db9310c 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -1,6 +1,6 @@ # Contributing guide -Scanpy provides extensive [developer documentation][scanpy developer guide], most of which applies to this repo, too. +Scanpy provides extensive [developer documentation][scanpy developer guide], most of which applies to this project, too. This document will not reproduce the entire content from there. Instead, it aims at summarizing the most important information to get you started on contributing. @@ -19,8 +19,8 @@ pip install -e ".[dev,test,doc]" ## Code-style -This template uses [pre-commit][] to enforce consistent code-styles. On every commit, pre-commit checks will either -automatically fix issues with the code, or raise an error message. +This package uses [pre-commit][] to enforce consistent code-styles. +On every commit, pre-commit checks will either automatically fix issues with the code, or raise an error message. To enable pre-commit locally, simply run @@ -42,10 +42,10 @@ git pull --rebase to integrate the changes into yours. While the [pre-commit.ci][] is useful, we strongly encourage installing and running pre-commit locally first to understand its usage. -Finally, most editors have an _autoformat on save_ feature. Consider enabling this option for [black][black-editors] +Finally, most editors have an _autoformat on save_ feature. Consider enabling this option for [ruff][ruff-editors] and [prettier][prettier-editors]. -[black-editors]: https://black.readthedocs.io/en/stable/integrations/editors.html +[ruff-editors]: https://docs.astral.sh/ruff/integrations/ [prettier-editors]: https://prettier.io/docs/en/editors.html ## Writing tests @@ -64,74 +64,26 @@ command line by executing pytest ``` -in the root of the repository. Continuous integration will automatically run the tests on all pull requests. +in the root of the repository. -[scanpy-test-docs]: https://scanpy.readthedocs.io/en/latest/dev/testing.html#writing-tests - -## Publishing a release - -### Updating the version number - -Before making a release, you need to update the version number. Please adhere to [Semantic Versioning][semver], in brief - -> Given a version number MAJOR.MINOR.PATCH, increment the: -> -> 1. MAJOR version when you make incompatible API changes, -> 2. MINOR version when you add functionality in a backwards compatible manner, and -> 3. PATCH version when you make backwards compatible bug fixes. -> -> Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format. - -We use [bump2version][] to automatically update the version number in all places and automatically create a git tag. -Run one of the following commands in the root of the repository - -```bash -bump2version patch -bump2version minor -bump2version major -``` - -Once you are done, run - -``` -git push --tags -``` - -to publish the created tag on GitHub. +### Continuous integration -[bump2version]: https://github.com/c4urself/bump2version +Continuous integration will automatically run the tests on all pull requests and test +against the minimum and maximum supported Python version. -### Building and publishing the package on PyPI +Additionally, there's a CI job that tests against pre-releases of all dependencies +(if there are any). The purpose of this check is to detect incompatibilities +of new package versions early on and gives you time to fix the issue or reach +out to the developers of the dependency before the package is released to a wider audience. -Python packages are not distributed as source code, but as _distributions_. The most common distribution format is the so-called _wheel_. To build a _wheel_, run - -```bash -python -m build -``` - -This command creates a _source archive_ and a _wheel_, which are required for publishing your package to [PyPI][]. These files are created directly in the root of the repository. - -Before uploading them to [PyPI][] you can check that your _distribution_ is valid by running: - -```bash -twine check dist/* -``` - -and finally publishing it with: - -```bash -twine upload dist/* -``` - -Provide your username and password when requested and then go check out your package on [PyPI][]! +[scanpy-test-docs]: https://scanpy.readthedocs.io/en/latest/dev/testing.html#writing-tests -For more information, follow the [Python packaging tutorial][]. +## Publishing a release -It is possible to automate this with GitHub actions, see also [this feature request][pypi-feature-request] -in the cookiecutter-scverse template. +### Updating the version number -[python packaging tutorial]: https://packaging.python.org/en/latest/tutorials/packaging-projects/#generating-distribution-archives -[pypi-feature-request]: https://github.com/scverse/cookiecutter-scverse/issues/88 +Scirpy uses [hatch-vcs](https://github.com/ofek/hatch-vcs) to automaticlly retrieve the version number +from the git tag. To make a new release, navigate to the “Releases” page of this project on GitHub. Specify vX.X.X as a tag name and create a release. For more information, see [managing GitHub releases][]. This will automatically create a git tag and trigger a Github workflow that creates a release on PyPI. ## Writing documentation @@ -195,3 +147,4 @@ open _build/html/index.html [numpydoc]: https://numpydoc.readthedocs.io/en/latest/format.html [sphinx autodoc typehints]: https://github.com/tox-dev/sphinx-autodoc-typehints [pypi]: https://pypi.org/ +[managing GitHub releases]: https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository diff --git a/pyproject.toml b/pyproject.toml index 602990c92..31ee677fb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,7 +74,7 @@ doc = [ ] test = [ 'pytest', - 'pytest-cov', + 'coverage', 'black', ] dandelion = [