Skip to main content

Make conda and poetry communicate

Project description

conda_poetry_liaison

Make conda and poetry communicate

PyPI - Python Version PyPI - Version License GitHub repo size Black style

Do not use another package manager in a conda environment.

Many are given this advice, but we do this anyway. We want our conda-only packages with the awesome features of poetry. conda_poetry_liaison is a small collection of scripts to make this as painless and reproducible as possible.

Installation

You can install conda_poetry_liaison with pip.

pip install conda_poetry_liaison

Scripts

cpl-deps

The primary issue of using other package managers like pip and poetry inside a conda environment is that they will not communicate. If you install a package with conda, then install a different one in pip, conda will have no idea what has changed. So once you start using pip or poetry, you cannot use conda to install a package in that same environment.

This script will add all Python packages installed in the conda environment into the pyproject.toml file. Now, poetry will be aware of these packages during dependency solving.

usage: cpl-deps [-h] [--env_name [ENV_NAME]] [--env_path [ENV_PATH]] [--group_name [GROUP_NAME]] [toml_path]

Notify poetry of conda Python packages

positional arguments:
  toml_path             Path to TOML file

options:
  -h, --help            show this help message and exit
  --env_name [ENV_NAME]
                        Name of conda environment to probe
  --env_path [ENV_PATH]
                        Path of conda environment to probe
  --group_name [GROUP_NAME]
                        Name of poetry dependency group

cpl-clean

There seems to be a remnant of direct_url.json files from conda package installations that break poetry (as discussed here). One workaround is to delete these files in the conda environment directory before using poetry.

usage: cpl-clean [-h] [env_path]

Notify poetry of conda Python packages

positional arguments:
  env_path    Path of conda environment to clean

options:
  -h, --help  show this help message and exit

Development

Install poetry if you do not have it.

make poetry-download

If you already have poetry installed, make sure you have poetry-dynamic-versioning.

poetry self add "poetry-dynamic-versioning[plugin]"

Install the package.

make install

Install all pre-commits.

make pre-commit-install

Deploying

A note to maintainers.

We use bump2version to release a new major, minor, or patch version. This will update the tracked version in .bumpversion.cfg, modify the CHANGELOG, and create a new tag.

For example, to bump the minor version you would run the following command.

poetry run bump2version minor

After releasing a new version, you need to push and include all tags.

git push --follow-tags

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

conda_poetry_liaison-0.0.2.tar.gz (5.1 kB view hashes)

Uploaded Source

Built Distribution

conda_poetry_liaison-0.0.2-py3-none-any.whl (6.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page