Skip to main content

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

  1. Enter the plugin directory that you created in the previos section:

    cd ./parsomics-plugin-interpro
  2. Create a Python virtual environment. The parsomics team recommends using venv, but feel free to use what you are most comfortable with. For venv run:

    python -m venv .venv
  3. Enter the virtual environment you just created:

    source .venv/bin/activate
  4. Install poetry with:

    pip install poetry
    info

    This is most likely the first and last time you will use pip in your plugin's development. From now on, use poetry to install Python packages.

  5. 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, the parsomics team recommends the OSI-approved GPL-3.0.

    Important

    Defining 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.

  6. Add runtime dependencies manually.

    poetry add pydantic sqlmodel sqlalchemy polars timeit-decorator parsomics-core
  7. Add development dependencies manually.

    poetry add black isort --group dev
  8. Initializing your package will make changes to pyproject.toml and create a poetry.lock file. Stage and commit both of them.