Skip to content

Development

Version Python versions Pull requests welcome

Python application{: target=” blank”} Publish{: target=” blank”} cffconvert{: target=”_blank”}

📥 Install for development

Clone the repository and go in the project folder:

git clone https://github.com/Nanopublication/nanopub-py
cd nanopub

To install the project for development you can use poetry.

If you don’t have it installed, first install it following the official installation guide.

Once poetry is installed, you can install all the project dependencies by running:

poetry install

Optionally, install pre-commit to enable automated formatting and linting of the code at each commit:

pre-commit install

🧑‍💻 Development workflow

Try to sign a nanopublication with the code defined in scripts/dev.py to test your changes:

./scripts/dev.sh

The code will be automatically formatted when you commit your changes using pre-commit. But you can also run the script to format the code yourself:

./scripts/format.sh

Check the code for errors, and if it is in accordance with the PEP8 style guide, by running flake8 and mypy:

./scripts/lint.sh

✅ Run the tests

Python application{: target=”_blank”}

Tests are automatically run by a GitHub Actions workflow when new code is pushed to the GitHub repository.

The tests use the nanopub-java tool for validating the signing process implemented in python produces similar nanopublications. This is automatically installed by the library, just make sure java is available where you run the tests.

Run the tests locally:

./scripts/test.sh

You can also run only a specific test:

./scripts/test.sh tests/test_nanopub.py::test_nanopub_sign_uri

Run the tests locally:

poetry run pytest

You can also run only a specific test:

poetry run pytest tests/test_nanopub.py::test_nanopub_sign_uri

📖 Generate docs

Publish docs{: target=”_blank”}

The documentation (this website) is automatically generated from the markdown files in the docs folder and python docstring comments, and published by a GitHub Actions workflow.

Serve the docs on http://localhost:8008

./scripts/docs.sh
poetry run mkdocs serve

🏷️ Publish a new release

Publish to PyPI{: target=”_blank”}

The release are automatically triggered using the semantic-release plugin together with conventional commits.