Skip to content

Commit

Permalink
Update template to v0.3.0 (#467)
Browse files Browse the repository at this point in the history
* Update template to v0.3.0

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix merge conflicts

* Pre-commit autoupdate

---------

Co-authored-by: scverse-bot <None>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Gregor Sturm <mail@gregor-sturm.de>
  • Loading branch information
3 people authored Jan 4, 2024
1 parent d862cf3 commit 7dd3377
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 112 deletions.
9 changes: 7 additions & 2 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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"
}
},
Expand Down
39 changes: 19 additions & 20 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 9 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Please consider making a tax-deductible [donation](https://numfocus.org/donate-t
>
</a>
[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
Expand Down Expand Up @@ -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][]:
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions docs/_static/css/custom.css
Original file line number Diff line number Diff line change
@@ -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;
}
16 changes: 1 addition & 15 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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,
)
85 changes: 19 additions & 66 deletions docs/contributing.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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

Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ doc = [
]
test = [
'pytest',
'pytest-cov',
'coverage',
'black',
]
dandelion = [
Expand Down

0 comments on commit 7dd3377

Please sign in to comment.