Skip to content

Commit

Permalink
Merge pull request #82 from ANNUBS/update_readmedev_gcroci2
Browse files Browse the repository at this point in the history
docs: update README.dev.md
  • Loading branch information
gcroci2 committed May 1, 2024
2 parents 5e5517b + 672cc23 commit 1a7817a
Showing 1 changed file with 29 additions and 79 deletions.
108 changes: 29 additions & 79 deletions README.dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,33 @@ coverage report

`coverage` can also generate output in HTML and other formats; see `coverage help` for more information.

## Running linters locally
## Linting and formatting

For linting and sorting imports we will use [ruff](https://beta.ruff.rs/docs/). Running the linters requires an
activated virtual environment with the development tools installed.
We use [ruff](https://docs.astral.sh/ruff/) for linting, sorting imports and formatting of python (notebook) files. The configurations of `ruff` are set in [ruff.toml](ruff.toml) file.

```shell
# linter
ruff .
If you are using VS code, please install and activate the [Ruff extension](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff) to automatically format and check linting.

# linter with automatic fixing
ruff . --fix
```
Otherwise, please ensure check both linting (`ruff check .`) and formatting (`ruff format .`) before requesting a review. Running the linters and formatters requires an activated virtual environment with the development tools installed.

To fix readability of your code style you can use [yapf](https://github.com/google/yapf).
## Static typing

You can enable automatic linting with `ruff` on commit by enabling the git hook from `.githooks/pre-commit`, like so:
We use [Mypy](http://mypy-lang.org/) as static type checker:

```shell
git config --local core.hooksPath .githooks
```
# install mypy
pip install mypy
# run mypy
mypy path-to-source-code
```

Mypy configurations are set in [pyproject.toml](pyproject.toml) file.

For more info about static typing and mypy, see:

- [Static typing with Python](https://typing.readthedocs.io/en/latest/index.html#)
- [Mypy doc](https://mypy.readthedocs.io/en/stable/)

## Docs

We use [MkDocs](https://www.mkdocs.org/) and its theme [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/)
Expand Down Expand Up @@ -128,85 +134,29 @@ instead of `mike serve` to check them.

## Versioning

Bumping the version across all files is done with [bumpversion](https://github.com/c4urself/bump2version), e.g.

```shell
bumpversion major
bumpversion minor
bumpversion patch
```
Bumping the version across all files is done before creating a new package release, running `bump2version [part]` from command line after having installed [bump2version](https://pypi.org/project/bump2version/) on your local environment. Instead of `[part]`, type the part of the version to increase, e.g. minor. The settings in `.bumpversion.cfg` will take care of updating all the files containing version strings.

## Making a release

This section describes how to make a release in 3 parts:

1. preparation
1. making a release on PyPI
1. making a release on GitHub
2. making a release on GitHub
3. making a release on PyPI

### (1/3) Preparation

1. Update the <CHANGELOG.md> (don't forget to update links at bottom of page)
2. Verify that the information in `CITATION.cff` is correct, and that `.zenodo.json` contains equivalent data
3. Make sure the [version has been updated](#versioning).
4. Run the unit tests with `pytest -v`

### (2/3) PyPI

In a new terminal:
1. Verify that the information in `CITATION.cff` is correct, and that `.zenodo.json` contains equivalent data
2. [Bump the version](https://github.com/DeepRank/deeprank2/blob/dev/README.dev.md#versioning).
3. Run the unit tests with `pytest -v`

```shell
# OPTIONAL: prepare a new directory with fresh git clone to ensure the release
# has the state of origin/main branch
cd $(mktemp -d annubes.XXXXXX)
git clone git@github.com:ANNUBS/annubes .

# make sure to have a recent version of pip and the publishing dependencies
python -m pip install --upgrade pip
python -m pip install .[publishing]
### (2/3) GitHub

# create the source distribution and the wheel
python -m build

# upload to test pypi instance (requires credentials)
python -m twine upload --repository testpypi dist/*
```

Visit
[https://test.pypi.org/project/annubes](https://test.pypi.org/project/annubes)
and verify that your package was uploaded successfully. Keep the terminal open, we'll need it later.

In a new terminal, without an activated virtual environment or an env directory:

```shell
cd $(mktemp -d annubes-test.XXXXXX)

# prepare a clean virtual environment and activate it
python -m venv env
source env/bin/activate

# make sure to have a recent version of pip and setuptools
python -m pip install --upgrade pip

# install from test pypi instance:
python -m pip -v install --no-cache-dir \
--index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple annubes
```

Check that the package works as it should when installed from pypitest.

Then upload to pypi.org with:

```shell
# Back to the first terminal,
# FINAL STEP: upload to PyPI (requires credentials)
python -m twine upload dist/*
```
Make a [release on GitHub](https://github.com/ANNUBS/annubes/releases/new).

### (3/3) GitHub
### (3/3) PyPI

Don't forget to also make a [release on GitHub](https://github.com/ANNUBS/annubes/releases/new). If your repository uses the GitHub-Zenodo integration this will also trigger Zenodo into making a snapshot of your repository and sticking a DOI on it.
The GitHub release will trigger [a GitHub action](https://github.com/DeepRank/deeprank2/actions/workflows/release.yml) that will take care of publishing the package on PyPi.

## Development conventions

Expand Down

0 comments on commit 1a7817a

Please sign in to comment.