Skip to main content

A python helper to generate conda environment files from project dependencies.

Project description

pydeps2env

An easy way to create conda environment files from you python project dependencies.
Creates a conda environment.yml file from python package dependencies listed in a pyproject.toml or setup.cfg file.

The project contains

  • GitHub action
  • python package
  • command line script
flowchart LR
    pyproject.toml --> pydeps2env
    setup.cfg --> pydeps2env
    environment.yaml --> pydeps2env
    requirements.txt --> pydeps2env
    pydeps2env --> E2[environment.yaml]
    pydeps2env --> R2[requirements.txt]

basic usage (GitHub action)

By default, the action will parse a pyproject.toml file in your root directory into environment.yml. Here is an example of a simple setup:

steps:
  - uses: CagtayFabry/pydeps2env@v1.0.0
[project]
requires-python = ">=3.8,<3.10"
dependencies = [
    "numpy >=1.20",
    "pandas >=1.0",
    "IPython",
    "boltons",
]
[project.optional-dependencies]
test = ["pytest"]
pip_only = ["bidict"]

The default parameters will output this sorted environment.yml (note that the python dependency will always be the first item on the list):

channels:
  - defaults
dependencies:
  - python>=3.8,<3.10
  - boltons
  - IPython
  - numpy>=1.20
  - pandas>=1.0

A full output with options --build_system include --extras test pip_only --pip bidict

channels:
  - defaults
dependencies:
  - python>=3.8,<3.10
  - boltons
  - IPython
  - numpy>=1.20
  - pandas>=1.0
  - pytest
  - setuptools>=40.9.0
  - setuptools_scm
  - wheel
  - pip:
    - bidict

configuration options

To customize the output the input options are available to the action:

files

Specify the location of the 'setup.cfg' or 'pyproject.toml' files to parse. (defaults to 'pyproject.toml') Multiple files can be listed. This will result in a combined environment file.

output:

Specify the location and name of the conda environment file to generate. (defaults to 'environment.yml')

channels:

List the conda channels to include in the environment file. (defaults to 'conda-forge') Separate a list of multiple channels by spaces (e.g. 'conda-forge defaults').

extras:

Specify one or more optional [extras_require] sections to add to all the environments (e.g. 'test' to include package that you would normally install with pip install pkg[test]). Note that for individual packages, the [extra]` syntax is also possible.

build_system:

If set to 'include' the dependencies listed under [build-system] (or [options:setup_requires] in setup.cfg) will be added to the environment (default is 'omit' so no setup dependencies will be installed).

pip

List of packages to install via pip instead of conda. The dependencies will be listet under the pip: section in the environment file.

example

steps:
  - uses: CagtayFabry/pydeps2env@v1.0.0
    with:
      files: ./test/pyproject.toml[doc] ./test/setup.cfg # comine both files, add [doc] only for pyproject.toml
      output: 'environment_test.yml'
      channels: 'conda-forge defaults'
      extras: 'test'
      build_system: 'include'
      pip: 'bidict'
[project]
requires-python = ">=3.8,<3.10"
dependencies = [
    "numpy >=1.20",
    "pandas >=1.0",
    "IPython",
    "boltons",
]
[project.optional-dependencies]
test = ["pytest"]
pip_only = ["bidict"]
channels:
  - conda-forge
  - defaults
dependencies:
  - python>=3.8,<3.10
  - boltons
  - IPython
  - numpy>=1.20
  - pandas>=1.0
  - pytest
  - setuptools>=40.9.0
  - setuptools_scm
  - sphinx
  - wheel
  - pip:
    - bidict

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

pydeps2env-1.0.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydeps2env-1.0.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file pydeps2env-1.0.0.tar.gz.

File metadata

  • Download URL: pydeps2env-1.0.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.2

File hashes

Hashes for pydeps2env-1.0.0.tar.gz
Algorithm Hash digest
SHA256 70b42951570ef84fde2e4ad70a1f5f62b3a492c73ad06250e3fd8511cf59d8ee
MD5 efc9b3dbcec88d421df1a72496e818db
BLAKE2b-256 6eea7db8429b0bd81bee622e626640e57be2ef0a9490f80252aeddd830dabe6a

See more details on using hashes here.

File details

Details for the file pydeps2env-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pydeps2env-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.2

File hashes

Hashes for pydeps2env-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 12653699c58c981b4d15845f448f180a19035bc0cad9ec42578b73a4efada3bf
MD5 b84228dd139bd067e6ef7708759ce5f4
BLAKE2b-256 534d2ff0538f243b7c2fe05520c2892c42bbcd4572c5848b97010afc3017e2bd

See more details on using hashes here.

Supported by

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