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
parsomicsteam recommends usingvenv, but feel free to use what you are most comfortable with. Forvenvrun:python -m venv .venv -
Enter the virtual environment you just created:
source .venv/bin/activate -
Install poetry with:
pip install poetryinfoThis is most likely the first and last time you will use
pipin your plugin's development. From now on, usepoetryto install Python packages. -
Initialize your plugin's package:
poetry initNow,
poetrywill prompt you to fill in some of the metadata of your package (e.g. package name, version, author, description, license, etc). For the license, theparsomicsteam 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.tomland create apoetry.lockfile. Stage and commit both of them.