Skip to main content

Unified Conda and Pip requirements management.

Project description

:rocket: conda-join - Unified Conda and Pip Requirements Management :rocket:

PyPI Build Status CodeCov

conda_join is a Python package designed to streamline the management and combination of multiple (or single) requirements.yaml files into a single Conda environment.yaml, whilest also being able to import the requirements.yaml file in setup.py where it will add the Python PyPI dependencies to requires. This tool is ideal for projects with multiple subcomponents, each having its own dependencies, where some are only available on conda and some on PyPI (pip), simplifying the process of creating a unified Conda environment, while being pip installable with the Python only dependencies. 🖥️🔥

:books: Table of Contents

:page_facing_up: Requirements File Structure

The requirements.yaml files that conda_join processes should follow a specific structure for the tool to correctly interpret and combine them. Here's an overview of the expected format:

Basic Structure

Each requirements.yaml file should contain the following key elements:

  • name: (Optional) A name for the environment. This is not used in the combined output but can be helpful for documentation purposes.
  • channels: A list of channels from which packages will be sourced. Commonly includes channels like conda-forge.
  • dependencies: A list of package dependencies. This can include both Conda and Pip packages.

Example

Here is an example of a typical requirements.yaml file:

name: example_environment
channels:
  - conda-forge
dependencies:
  - numpy  # same name on conda and pip
  - pandas  # same name on conda and pip
  - conda: scipy  # different name on conda and pip
    pip: scipy-package
  - pip: package3  # only available on pip
  - conda: mumps  # only available on conda

Explanation

  • Dependencies listed as simple strings (e.g., - numpy) are assumed to be Conda packages.
  • If a package is available through both Conda and Pip but with different names, you can specify both using the conda: <conda_package> and pip: <pip_package> format.
  • Packages only available through Pip should be listed with the pip: prefix.

conda_join will combine these dependencies into a single environment.yaml file, structured as follows:

name: some_name
channels:
  - conda-forge
dependencies:
  - numpy
  - pandas
  - scipy
  pip:
    - scipy-package
    - package3

:package: Installation

To install conda_join, run the following command:

pip install -U conda_join

Or just copy the script to your computer:

wget https://raw.githubusercontent.com/basnijholt/requirements.yaml/main/conda_join.py

:memo: Usage with pyproject.toml or setup.py

To use conda_join in your project, you can configure it in pyproject.toml. This setup works alongside a requirements.yaml file located in the same directory. The behavior depends on your project's setup:

  • When using only pyproject.toml: The dependencies field in pyproject.toml will be automatically populated based on the contents of requirements.yaml.
  • When using setup.py: The install_requires field in setup.py will be automatically populated, reflecting the dependencies defined in requirements.yaml.

Here's an example pyproject.toml configuration:

[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools", "wheel", "conda_join"]

In this configuration, conda_join is included as a build requirement, allowing it to process the Python dependencies in the requirements.yaml file and update the project's dependencies accordingly.

:memo: Usage as a CLI

After installation, you can use conda_join to scan directories for requirements.yaml file(s) and combine them into an environment.yaml file. Basic usage is as follows (check conda_join -h):

usage: conda-join [-h] [-d DIRECTORY] [-o OUTPUT] [-n NAME] [--depth DEPTH]
                  [--stdout] [-v]

Unified Conda and Pip requirements management.

options:
  -h, --help            show this help message and exit
  -d DIRECTORY, --directory DIRECTORY
                        Base directory to scan for requirements.yaml files, by
                        default `.`
  -o OUTPUT, --output OUTPUT
                        Output file for the conda environment, by default
                        `environment.yaml`
  -n NAME, --name NAME  Name of the conda environment, by default `myenv`
  --depth DEPTH         Depth to scan for requirements.yaml files, by default
                        1
  --stdout              Output to stdout instead of a file
  -v, --verbose         Print verbose output

:warning: Limitations

  • The current version of conda_join does not support conflict resolution between different versions of the same package in multiple requirements.yaml files.
  • Designed primarily for use with Conda environments; may not fully support other package management systems.

Try conda_join today for a streamlined approach to managing your Conda environment dependencies across multiple projects! 🎉👏

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-join-0.6.0.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

conda_join-0.6.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file conda-join-0.6.0.tar.gz.

File metadata

  • Download URL: conda-join-0.6.0.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for conda-join-0.6.0.tar.gz
Algorithm Hash digest
SHA256 4361c6f72d3cb48de5f2b609b97c03e6596be8b25a4989dab7b055ddc1744467
MD5 043bca54386d98896c27b8602bb766da
BLAKE2b-256 236f2549d19eb9401af65363b55e8a7e68bfbf6f087bc6fb69aba585d37236ff

See more details on using hashes here.

File details

Details for the file conda_join-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: conda_join-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for conda_join-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 34da4ca1f86bc3bf853697d780b11fe06342683415d41f567e30e6f5b5fbe43c
MD5 cdb0a042c70deab6279165683c301eed
BLAKE2b-256 851a2f141546fb35d7b53bfdd0c636e38fdbff5281c9d4735f2782ff9924e138

See more details on using hashes here.

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