conda-pip-minimal


Nameconda-pip-minimal JSON
Version 0.2.1 PyPI version JSON
download
home_pageNone
SummaryConda+Pip minimal env exports
upload_time2023-05-09 06:46:53
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords conda environment.yaml packaging pip
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # conda cpm

Simple tool to generate minimal versions of Conda environments, also including
`pip` dependencies, for cross-platform sharing.

Built on top of [`conda tree`](https://github.com/conda-incubator/conda-tree) and [`pipdeptree`](https://github.com/tox-dev/pipdeptree). Inspired by [`conda minify`](https://github.com/jamespreed/conda-minify).

## Why use `conda cpm`?

-   Conda (especially with mamba) is a great tool to manage Python virtual
    environments, especially if you need to install some non-Python dependencies,
    or use compiled dependencies like CUDA. See
    <https://aseifert.com/p/python-environments/> for more on this.

-   I use Conda preferentially to install any packages available through it; and
    provide my virtualenv&rsquo;s Python version through Conda.

-   Some packages are not easily accessible on Conda, and I use `pip` or `poetry`
    (or `hatch` or your other tool of choice) to pull those packages in.

-   This approach works remarkably well, but when it is time to share my
    environment with others, there are several ways to do it, and they are subtly
    different in capabilities and issues.

    e.g

    -   `conda env export`, `conda env export --from-history`, `conda list --export`

    -   For pip-installed packages, `pip freeze`, `pip list --freeze`, or whatever
        your favorite Python package manager provides.

    -   conda-lock, pipenv, and other lock file generating tools

-   If the exported file is too specific, specifying every dependency and build
    identifier, it often cannot be reproduced on a different platform because
    these are not portable.

-   If you use both `conda` and `pip`, these tools will typically be unaware of
    each other, generating overlapping requirements files.

## How does `conda cpm` solve this?

-   `conda cpm` constructs a minimal `environment.yml` file, with only the
    "leaves" of the dependency tree, both for `pip` and `conda`.

-   It retains information about which packages came from Conda and which came
    from Pip, but does not include dependencies in the export.

-   It specifies exact versions by default, but it can optionally relax the
    version requirements to being flexible at the patch level or minor level
    (semver).

-   It can optionally include info about which Conda channel a package came from,
    the Python version, or any manually specified packages.

-   It does not include system-specific information like the Conda environment
    prefix.

## Installation

### via pip

```console
pip install conda-pip-minimal
```

### via pipx

```console
pipx install conda-pip-minimal
```

### Run without installing

```console
pipx run conda-pip-minimal --help
```

## Usage

The script for this package is named `conda-cpm`; so it can be run like `conda cpm`

```console
$ conda cpm [OPTIONS]
```

### Options:

  * `-p, --prefix PATH`: Conda env prefix
  * `-n, --name TEXT`: Conda env name
  * `--pip / --no-pip`: Include pip dependencies  [default: True]
  * `--relax [none|major|minor|full]`: [default: full]
  * `--include TEXT`: Packages to always include  [default: python, pip]
  * `--exclude TEXT`: Packages to always exclude  [default: ]
  * `--channel / --no-channel`: Add channel to conda dependencies  [default: False]
  * `--debug / --no-debug`: [default: False]
  * `--help`: Show this message and exit.

## Examples

Here are a few example runs for this package:

### From within the conda environment:

``` shell
❯ conda cpm
dependencies:
- python=3.8.13
- pip=22.2.2
- pip:
  - conda-pip-minimal==0.1.0
  - ipython==8.5.0
  - snoop==0.4.2
  - trio-typing==0.7.0
name: /home/venky/dev/conda-pip-minimal/.venv
```

### Specifying the conda environment

``` shell
❯ conda cpm --prefix ~/dev/conda-pip-minimal/.venv
dependencies:
- pip=22.2.2
- python=3.8.13
- pip:
  - conda-pip-minimal==0.1.0
  - ipython==8.5.0
  - snoop==0.4.2
  - trio-typing==0.7.0
name: /home/venky/dev/conda-pip-minimal/.venv
```

### Exclude packages

``` shell
❯ conda cpm --prefix ~/dev/conda-pip-minimal/.venv --exclude snoop --exclude trio-typing
dependencies:
- python=3.8.13
- pip=22.2.2
- pip:
  - conda-pip-minimal==0.1.0
  - ipython==8.5.0
name: /home/venky/dev/conda-pip-minimal/.venv
```

### Include a normally-excluded dependency

``` shell
❯ conda cpm --prefix ~/dev/conda-pip-minimal/.venv --include trio
dependencies:
- trio=0.22.0
- pip:
  - conda-pip-minimal==0.1.0
  - ipython==8.5.0
  - snoop==0.4.2
  - trio-typing==0.7.0
name: /home/venky/dev/conda-pip-minimal/.venv
```

### Specify conda channels

``` shell
❯ conda cpm --prefix ~/dev/conda-pip-minimal/.venv --channel
dependencies:
- conda-forge::python=3.8.13
- conda-forge::pip=22.2.2
- pip:
  - conda-pip-minimal==0.1.0
  - ipython==8.5.0
  - snoop==0.4.2
  - trio-typing==0.7.0
name: /home/venky/dev/conda-pip-minimal/.venv
```

### Relax versions

``` shell
❯ conda cpm --prefix ~/dev/conda-pip-minimal/.venv --relax minor
dependencies:
- python=3.8.*
- pip=22.2.*
- pip:
  - conda-pip-minimal==0.1.*
  - ipython==8.5.*
  - snoop==0.4.*
  - trio-typing==0.7.*
name: /home/venky/dev/conda-pip-minimal/.venv
```

### Skip pip dependencies

Why would you want to do this, though?

``` shell
❯ conda cpm --prefix ~/dev/conda-pip-minimal/.venv --no-pip
dependencies:
- pip=22.2.2
- python=3.8.13
name: /home/venky/dev/conda-pip-minimal/.venv
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "conda-pip-minimal",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "conda,environment.yaml,packaging,pip",
    "author": null,
    "author_email": "Venky Iyer <indigoviolet@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/da/83/b05cf7419bc64d1b199bec5d4e9de0ed6379e5abcaeab3571cebae84ee8d/conda_pip_minimal-0.2.1.tar.gz",
    "platform": null,
    "description": "# conda cpm\n\nSimple tool to generate minimal versions of Conda environments, also including\n`pip` dependencies, for cross-platform sharing.\n\nBuilt on top of [`conda tree`](https://github.com/conda-incubator/conda-tree) and [`pipdeptree`](https://github.com/tox-dev/pipdeptree). Inspired by [`conda minify`](https://github.com/jamespreed/conda-minify).\n\n## Why use `conda cpm`?\n\n-   Conda (especially with mamba) is a great tool to manage Python virtual\n    environments, especially if you need to install some non-Python dependencies,\n    or use compiled dependencies like CUDA. See\n    <https://aseifert.com/p/python-environments/> for more on this.\n\n-   I use Conda preferentially to install any packages available through it; and\n    provide my virtualenv&rsquo;s Python version through Conda.\n\n-   Some packages are not easily accessible on Conda, and I use `pip` or `poetry`\n    (or `hatch` or your other tool of choice) to pull those packages in.\n\n-   This approach works remarkably well, but when it is time to share my\n    environment with others, there are several ways to do it, and they are subtly\n    different in capabilities and issues.\n\n    e.g\n\n    -   `conda env export`, `conda env export --from-history`, `conda list --export`\n\n    -   For pip-installed packages, `pip freeze`, `pip list --freeze`, or whatever\n        your favorite Python package manager provides.\n\n    -   conda-lock, pipenv, and other lock file generating tools\n\n-   If the exported file is too specific, specifying every dependency and build\n    identifier, it often cannot be reproduced on a different platform because\n    these are not portable.\n\n-   If you use both `conda` and `pip`, these tools will typically be unaware of\n    each other, generating overlapping requirements files.\n\n## How does `conda cpm` solve this?\n\n-   `conda cpm` constructs a minimal `environment.yml` file, with only the\n    \"leaves\" of the dependency tree, both for `pip` and `conda`.\n\n-   It retains information about which packages came from Conda and which came\n    from Pip, but does not include dependencies in the export.\n\n-   It specifies exact versions by default, but it can optionally relax the\n    version requirements to being flexible at the patch level or minor level\n    (semver).\n\n-   It can optionally include info about which Conda channel a package came from,\n    the Python version, or any manually specified packages.\n\n-   It does not include system-specific information like the Conda environment\n    prefix.\n\n## Installation\n\n### via pip\n\n```console\npip install conda-pip-minimal\n```\n\n### via pipx\n\n```console\npipx install conda-pip-minimal\n```\n\n### Run without installing\n\n```console\npipx run conda-pip-minimal --help\n```\n\n## Usage\n\nThe script for this package is named `conda-cpm`; so it can be run like `conda cpm`\n\n```console\n$ conda cpm [OPTIONS]\n```\n\n### Options:\n\n  * `-p, --prefix PATH`: Conda env prefix\n  * `-n, --name TEXT`: Conda env name\n  * `--pip / --no-pip`: Include pip dependencies  [default: True]\n  * `--relax [none|major|minor|full]`: [default: full]\n  * `--include TEXT`: Packages to always include  [default: python, pip]\n  * `--exclude TEXT`: Packages to always exclude  [default: ]\n  * `--channel / --no-channel`: Add channel to conda dependencies  [default: False]\n  * `--debug / --no-debug`: [default: False]\n  * `--help`: Show this message and exit.\n\n## Examples\n\nHere are a few example runs for this package:\n\n### From within the conda environment:\n\n``` shell\n\u276f conda cpm\ndependencies:\n- python=3.8.13\n- pip=22.2.2\n- pip:\n  - conda-pip-minimal==0.1.0\n  - ipython==8.5.0\n  - snoop==0.4.2\n  - trio-typing==0.7.0\nname: /home/venky/dev/conda-pip-minimal/.venv\n```\n\n### Specifying the conda environment\n\n``` shell\n\u276f conda cpm --prefix ~/dev/conda-pip-minimal/.venv\ndependencies:\n- pip=22.2.2\n- python=3.8.13\n- pip:\n  - conda-pip-minimal==0.1.0\n  - ipython==8.5.0\n  - snoop==0.4.2\n  - trio-typing==0.7.0\nname: /home/venky/dev/conda-pip-minimal/.venv\n```\n\n### Exclude packages\n\n``` shell\n\u276f conda cpm --prefix ~/dev/conda-pip-minimal/.venv --exclude snoop --exclude trio-typing\ndependencies:\n- python=3.8.13\n- pip=22.2.2\n- pip:\n  - conda-pip-minimal==0.1.0\n  - ipython==8.5.0\nname: /home/venky/dev/conda-pip-minimal/.venv\n```\n\n### Include a normally-excluded dependency\n\n``` shell\n\u276f conda cpm --prefix ~/dev/conda-pip-minimal/.venv --include trio\ndependencies:\n- trio=0.22.0\n- pip:\n  - conda-pip-minimal==0.1.0\n  - ipython==8.5.0\n  - snoop==0.4.2\n  - trio-typing==0.7.0\nname: /home/venky/dev/conda-pip-minimal/.venv\n```\n\n### Specify conda channels\n\n``` shell\n\u276f conda cpm --prefix ~/dev/conda-pip-minimal/.venv --channel\ndependencies:\n- conda-forge::python=3.8.13\n- conda-forge::pip=22.2.2\n- pip:\n  - conda-pip-minimal==0.1.0\n  - ipython==8.5.0\n  - snoop==0.4.2\n  - trio-typing==0.7.0\nname: /home/venky/dev/conda-pip-minimal/.venv\n```\n\n### Relax versions\n\n``` shell\n\u276f conda cpm --prefix ~/dev/conda-pip-minimal/.venv --relax minor\ndependencies:\n- python=3.8.*\n- pip=22.2.*\n- pip:\n  - conda-pip-minimal==0.1.*\n  - ipython==8.5.*\n  - snoop==0.4.*\n  - trio-typing==0.7.*\nname: /home/venky/dev/conda-pip-minimal/.venv\n```\n\n### Skip pip dependencies\n\nWhy would you want to do this, though?\n\n``` shell\n\u276f conda cpm --prefix ~/dev/conda-pip-minimal/.venv --no-pip\ndependencies:\n- pip=22.2.2\n- python=3.8.13\nname: /home/venky/dev/conda-pip-minimal/.venv\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Conda+Pip minimal env exports",
    "version": "0.2.1",
    "project_urls": {
        "Homepage": "https://github.com/indigoviolet/conda-pip-minimal"
    },
    "split_keywords": [
        "conda",
        "environment.yaml",
        "packaging",
        "pip"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "349c59f06654055541398d467f195c5479ba4b130a9399a10026a5bd2c0819f9",
                "md5": "332f6a5480ef104292453afa30013f94",
                "sha256": "618cdfddfcab2f021090e78f7883aba0a2ceeb34561f8288e7a30df38812fe04"
            },
            "downloads": -1,
            "filename": "conda_pip_minimal-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "332f6a5480ef104292453afa30013f94",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 11940,
            "upload_time": "2023-05-09T06:46:56",
            "upload_time_iso_8601": "2023-05-09T06:46:56.646259Z",
            "url": "https://files.pythonhosted.org/packages/34/9c/59f06654055541398d467f195c5479ba4b130a9399a10026a5bd2c0819f9/conda_pip_minimal-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "da83b05cf7419bc64d1b199bec5d4e9de0ed6379e5abcaeab3571cebae84ee8d",
                "md5": "e50a59d92ba846edba5257ee6a7dd1ae",
                "sha256": "b27138eb96ffa1c57c7d1c2a423b373baaa22e70ce1086fe8538dbe276566867"
            },
            "downloads": -1,
            "filename": "conda_pip_minimal-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "e50a59d92ba846edba5257ee6a7dd1ae",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 8280,
            "upload_time": "2023-05-09T06:46:53",
            "upload_time_iso_8601": "2023-05-09T06:46:53.389266Z",
            "url": "https://files.pythonhosted.org/packages/da/83/b05cf7419bc64d1b199bec5d4e9de0ed6379e5abcaeab3571cebae84ee8d/conda_pip_minimal-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-09 06:46:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "indigoviolet",
    "github_project": "conda-pip-minimal",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "conda-pip-minimal"
}
        
Elapsed time: 0.06949s