Step 2: Initialize a package
Packaging is a crucial first step in plugin development. It's what makes your
plugin installable for other people. Packaging also helps keeping track of the
parsomics-core
versions that your plugin is compatible with.
Explanation
The parsomics
team recommends using poetry for
packaging. It helps in managing dependencies, tracking releases, and publishing
to the Python Package Index (PyPI).
Hands on
-
Enter the plugin directory that you created in the previos section:
cd ./parsomics-plugin-interpro
-
Create a Python virtual environment. The
parsomics
team recommends usingvenv
, but feel free to use what you are most comfortable with. Forvenv
run:python -m venv .venv
-
Enter the virtual environment you just created:
source .venv/bin/activate
-
Install poetry with:
pip install poetry
infoThis is most likely the first and last time you will use
pip
in your plugin's development. From now on, usepoetry
to install Python packages. -
Initialize your plugin's package:
poetry init
Now,
poetry
will prompt you to fill in some of the metadata of your package (e.g. package name, version, author, description, license, etc). For the license, theparsomics
team recommends the OSI-approved GPL-3.0.ImportantDefining dependencies interactively during the poetry init setup is currently broken on some versions of poetry. Skip this step for now if it doesn't work for you.
-
Add runtime dependencies manually.
poetry add pydantic sqlmodel sqlalchemy polars timeit-decorator parsomics-core
-
Add development dependencies manually.
poetry add black isort --group dev
-
Initializing your package will make changes to
pyproject.toml
and create apoetry.lock
file. Stage and commit both of them.