Skip to content

Commit

Permalink
Update cruft
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt committed Nov 5, 2024
1 parent b4a1851 commit da685f5
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/cthoyt/cookiecutter-snekpack",
"commit": "640faa5f1e39285d9f8103a3f5877db999abebc7",
"commit": "12edfcfa5f519467b5d834f0d4e706fb7cf4f065",
"checkout": null,
"context": {
"cookiecutter": {
Expand Down
4 changes: 4 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# see https://docs.codecov.com/v4.6/docs/codecov-yaml
ignore:
- "src/pyobo/__main__.py"
- "src/pyobo/cli.py"
66 changes: 27 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
<img src="https://codecov.io/gh/biopragmatics/pyobo/branch/main/graph/badge.svg" alt="Codecov status" /></a>
<a href="https://github.com/cthoyt/cookiecutter-python-package">
<img alt="Cookiecutter template from @cthoyt" src="https://img.shields.io/badge/Cookiecutter-snekpack-blue" /></a>
<a href='https://github.com/psf/black'>
<img src='https://img.shields.io/badge/code%20style-black-000000.svg' alt='Code style: black' /></a>
<a href="https://github.com/astral-sh/ruff">
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff" style="max-width:100%;"></a>
<a href="https://github.com/biopragmatics/pyobo/blob/main/.github/CODE_OF_CONDUCT.md">
<img src="https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg" alt="Contributor Covenant"/></a>
<a href="https://doi.org/10.5281/zenodo.3381961">
<img src="https://zenodo.org/badge/DOI/10.5281/zenodo.3381961.svg" alt="DOI"></a>
</p>

Tools for biological identifiers, names, synonyms, xrefs, hierarchies, relations, and properties through the
Expand Down Expand Up @@ -414,14 +416,14 @@ and make update to the `url` entry for that namespace in the Bioregistry.
The most recent release can be installed from
[PyPI](https://pypi.org/project/pyobo/) with:

```shell
pip install pyobo
```console
python3 -m pip install pyobo
```

The most recent code and data can be installed directly from GitHub with:

```shell
pip install git+https://github.com/biopragmatics/pyobo.git
```console
python3 -m pip install git+https://github.com/biopragmatics/pyobo.git
```

## 👐 Contributing
Expand Down Expand Up @@ -478,10 +480,10 @@ 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:

```bash
```console
git clone git+https://github.com/biopragmatics/pyobo.git
cd pyobo
pip install -e .
python3 -m pip install -e .
```

### Updating Package Boilerplate
Expand All @@ -490,8 +492,8 @@ This project uses `cruft` to keep boilerplate (i.e., configuration, contribution
configuration)
up-to-date with the upstream cookiecutter package. Update with the following:

```shell
pip install cruft
```console
python3 -m pip install cruft
cruft update
```

Expand All @@ -500,10 +502,11 @@ available [here](https://github.com/cruft/cruft?tab=readme-ov-file#updating-a-pr

### 🥼 Testing

After cloning the repository and installing `tox` with `pip install tox tox-uv`,
After cloning the repository and installing `tox` with
`python3 -m pip install tox tox-uv`,
the unit tests in the `tests/` folder can be run reproducibly with:

```shell
```console
tox -e py
```

Expand All @@ -514,12 +517,12 @@ Additionally, these tests are automatically re-run with each commit in a

The documentation can be built locally using the following:

```shell
```console
git clone git+https://github.com/biopragmatics/pyobo.git
cd pyobo
tox -e docs
open docs/build/html/index.html
```
```

The documentation automatically installs the package as well as the `docs`
extra specified in the [`pyproject.toml`](../../Desktop/pyobo/pyproject.toml). `sphinx` plugins
Expand Down Expand Up @@ -575,38 +578,23 @@ 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. Create a file in your home directory called
`.pypirc` and include the following:

```ini
[distutils]
index-servers =
pypi
testpypi

[pypi]
username = __token__
password = <the API token you just got>
You have to do the following steps once per machine.

# This block is optional in case you want to be able to make test releases to the Test PyPI server
[testpypi]
repository = https://test.pypi.org/legacy/
username = __token__
password = <an API token from test PyPI>
```console
$ uv tool install keyring
$ keyring set https://upload.pypi.org/legacy/ __token__
$ keyring set https://test.pypi.org/legacy/ __token__
```

Note that since PyPI is requiring token-based authentication, we use `__token__` as the user, verbatim.
If you already have a `.pypirc` file with a `[distutils]` section, just make sure that there is an `index-servers`
key and that `pypi` is in its associated list. More information on configuring the `.pypirc` file can
be found [here](https://packaging.python.org/en/latest/specifications/pypirc).
Note that this deprecates previous workflows using `.pypirc`.

#### Uploading to PyPI

After installing the package in development mode and installing
`tox` with `pip install tox tox-uv`,
run the following from the shell:
`tox` with `python3 -m pip install tox tox-uv`,
run the following from the console:

```shell
```console
tox -e finish
```

Expand All @@ -617,7 +605,7 @@ This script does the following:
and [`docs/source/conf.py`](../../Desktop/pyobo/docs/source/conf.py) to not have the `-dev` suffix
2. Packages the code in both a tar archive and a wheel using
[`uv build`](https://docs.astral.sh/uv/guides/publish/#building-your-package)
3. Uploads to PyPI using [`twine`](https://github.com/pypa/twine).
3. Uploads to PyPI using [`uv publish`](https://docs.astral.sh/uv/guides/publish/#publishing-your-package).
4. Push to GitHub. You'll need to make a release going with the commit where the version was bumped.
5. Bump the version to the next patch. If you made big changes and want to bump the version by minor, you can
use `tox -e bumpversion -- minor` after.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
version = parsed_version.expand(r"\g<major>.\g<minor>.\g<patch>")

if parsed_version.group("release"):
tags.add("prerelease") # noqa: F821
tags.add("prerelease") # noqa:F821

# See https://about.readthedocs.com/blog/2024/07/addons-by-default/
# Define the canonical URL if you are using a custom domain on Read the Docs
Expand Down
53 changes: 10 additions & 43 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -212,33 +212,19 @@ commands =
# 3. Get account recovery codes
# 4. Set up 2-Factor Authentication
# 5. Get an API token from https://pypi.org/manage/account/token/
# 6. Create a file called .pypirc in the home directory if it does not already exist.
# 7. Add the following content to the .pypirc file
#
# [distutils]
# index-servers=
# pypi
# testpypi
#
# [pypi]
# username = __token__
# password = <the API token you just got>
#
# If there's already an `index-servers =` list, just make sure you add `pypi` to it.
# More information about .pypirc can be found at https://packaging.python.org/en/latest/specifications/pypirc/
# 6. Install keyring with `uv tool install keyring`
# 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
skip_install = true
passenv =
TWINE_USERNAME
TWINE_PASSWORD
deps =
{[testenv:build]deps}
twine >= 1.5.0
uv
keyring
commands =
{[testenv:build]commands}
twine upload --skip-existing dist/*
uv publish --username __token__ --keyring-provider subprocess --publish-url https://upload.pypi.org/legacy/

[testenv:finish]
description =
Expand All @@ -247,8 +233,6 @@ description =
skip_install = true
passenv =
HOME
TWINE_USERNAME
TWINE_PASSWORD
deps =
{[testenv:release]deps}
bump-my-version
Expand All @@ -273,34 +257,19 @@ allowlist_externals =
# 3. Get account recovery codes
# 4. Set up 2-Factor Authentication
# 5. Get an API token from https://test.pypi.org/manage/account/token/
# 6. Create a file called .pypirc in the home directory if it does not already exist.
# 7. Add the following content to the .pypirc file
#
# [distutils]
# index-servers=
# pypi
# testpypi
#
# [testpypi]
# repository = https://test.pypi.org/legacy/
# username = __token__
# password = <the API token you just got>
#
# If there's already an `index-servers =` list, just make sure you add `testpypi` to it.
# More information about .pypirc can be found at https://packaging.python.org/en/latest/specifications/pypirc/
# 6. Install keyring with `uv tool install keyring`
# 7. Add your token to keyring with `keyring set https://test.pypi.org/legacy/ __token__`

[testenv:testrelease]
description = Release the code to the test PyPI site
skip_install = true
passenv =
TWINE_USERNAME
TWINE_PASSWORD
deps =
{[testenv:build]deps}
twine >= 1.5.0
uv
keyring
commands =
{[testenv:build]commands}
twine upload --skip-existing --repository testpypi dist/*
uv publish --username __token__ --keyring-provider subprocess --publish-url https://test.pypi.org/legacy/

[testenv:testfinish]
description =
Expand All @@ -309,8 +278,6 @@ description =
skip_install = true
passenv =
HOME
TWINE_USERNAME
TWINE_PASSWORD
deps =
{[testenv:testrelease]deps}
bump-my-version
Expand Down

0 comments on commit da685f5

Please sign in to comment.