conda_poetry_liaison
Make conda and poetry communicate
Installation • Example • Scripts • Development • Deploying • License
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 conda
conda install -c conda-forge conda-poetry-liaison
Example
Create and activate a conda environment.
For this example, we are creating an environment named sunshine.
conda create -y -n sunshine python=3.11 && conda activate sunshine
Install the following required packages.
conda install -y -c conda-forge poetry pre-commit tomli tomli-w conda-poetry-liaison
Install your desired packages; for example, suppose you want numpy, scipy, and matplotlib.
conda install -y -c conda-forge numpy scipy matplotlib
Update the tool.poetry.group.conda.dependencies group in your pyproject.toml with the cpl-deps script.
cpl-deps pyproject.toml --env_name sunshine
Cleanup your conda environment with cpl-clean before switching to using poetry exclusively.
cpl-clean --env_name sunshine
Now you are good to go!
For example, you can run poetry install to install all poetry-managed PyPI packages in pyproject.toml.
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_name [ENV_NAME]] [--env_path [ENV_PATH]]
Clean up the conda environment for use with poetry
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
Development
Clone the GitHub repository.
git clone https://github.com/oasci/conda-poetry-liaison && cd conda-poetry-liaison
Install poetry if you do not have it.
make poetry-download
If you already have poetry installed, ensure you have poetry-dynamic-versioning.
poetry self add "poetry-dynamic-versioning[plugin]"
Run the following command to install all dependencies, this package, and pre-commits.
make refresh
Deploying
A note to maintainers.
We use bump-my-version to release a new version.
This will create a git tag that is used by poetry-dynamic-version to generate version strings and update CHANGELOG.md.
For example, to bump the minor version, you would run the following command.
poetry run bump-my-version bump minor
After releasing a new version, you must push and include all tags.
git push --follow-tags
License
Code contained in this project is released under the MIT License as specified in LICENSE.
This license grants you the freedom to use, modify, and distribute it as long as you include the original copyright notice in LICENSE and the following notice.
Portions of this code were incorporated and adapted with permission from conda-poetry-liaison by OASCI under the MIT License.
Metadata
Release files for conda-poetry-liaison 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| conda_poetry_liaison-0.1.2.tar.gz | 6.7 kB | Without provenance | Details for conda_poetry_liaison-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| conda_poetry_liaison-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for conda_poetry_liaison-0.1.2-py3-none-any.whl |
Total release size: 14.1 kB
Release files / conda_poetry_liaison-0.1.2.tar.gz
| Download URL | conda_poetry_liaison-0.1.2.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
79bdc4b5ad989bcf20cdcd01580cf6d1b9ae8d123ca0dc7ca39707e2b2e6ac46
|
|
BLAKE2b-256 checksum How to use checksums |
7d8046d06f06520351c891da51cd6058127b28cf24f51a3b88e9ed56531a1da8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / conda_poetry_liaison-0.1.2-py3-none-any.whl
| Download URL | conda_poetry_liaison-0.1.2-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b6581a8bc521c96f80e7bc0c8583e908005aab43765a0a58cb56ae4e428f27a5
|
|
BLAKE2b-256 checksum How to use checksums |
d75e8ff197168cc7fbb55aa41b90d3a593e684308051ed8ed4ede95b49a958ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Security for conda-poetry-liaison 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.