conda-subprocess


Nameconda-subprocess JSON
Version 0.0.1 PyPI version JSON
download
home_page
SummaryRun a subprocess in a different conda environment.
upload_time2024-01-20 19:48:39
maintainer
docs_urlNone
author
requires_python>=3.9
licenseBSD 3-Clause License Copyright (c) 2023, pyiron All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
keywords conda subprocess
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # conda subprocess
Run a subprocess in a different conda environment. 

## Example 
Create a new conda environment - in this example a conda environment for Python 3.12:
```commandline
conda create -n py312 python=3.12 
```

Open a python shell in your base environment where `conda_subprocess` is installed and execute `python --version` in the
`py312` environment:
```python
from conda_subprocess import check_output
check_output("python --version", prefix_name="py312")
>>> b'Python 3.12.1\n'
```

Alternatively, the environment can be specified with the absolute path:
```python
from conda_subprocess import check_output
check_output("python --version", prefix_path="/Users/janssen/mambaforge/envs/py312")
>>> b'Python 3.12.1\n'
```

As expected the process for the arguments for the subprocess call can also be defined as list:
```python
from conda_subprocess import check_output
check_output(["python", "--version"], prefix_path="/Users/janssen/mambaforge/envs/py312")
>>> b'Python 3.12.1\n'
```

In addition to the `check_output()` function also the `check_call()` function is implemented:
```python
from conda_subprocess import check_call
check_call("python --version", prefix_name="py312")
>>> Python 3.12.1
>>> 0
```

As well as the `call()` function:
```python
from conda_subprocess import call
call("python --version", prefix_name="py312")
>>> Python 3.12.1
>>> 0
```

And the `run()` function:
```python
from conda_subprocess import run
run("python --version", prefix_name="py312")
>>> Python 3.12.1
>>> CompletedProcess(args=['/bin/bash', '/var/folders/9p/rztyv06d0xv4h26cyv8nrw3m0000gq/T/tmpm8b8i0r3'], returncode=0)
```
As the `CompletedProcess` arguments illustrate `conda_subprocess` is internally writing the commands to a temporary file
for execution, to guarantee the conda environment is correctly activated.

For interactive communication `conda_subprocess` implements the `Popen` interface:
```python
from subprocess import PIPE
from conda_subprocess import Popen
process = Popen(["python", "--version"], stdout=PIPE, prefix_name="py312")
process.communicate()
>>> (b'Python 3.12.1\n', None)
```

## Remarks
* The `shell` parameter and the `env` parameter are not supported in `Popen()` and all derived methods. 
* The `pipesize` parameter and the `process_group` parameter were removed for compatibility with python 3.9. 

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "conda-subprocess",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "",
    "keywords": "conda,subprocess",
    "author": "",
    "author_email": "Jan Janssen <janssen@mpie.de>",
    "download_url": "https://files.pythonhosted.org/packages/2e/6b/4dd68c4d4159ffee54d2fa098ebe7e22b699bb72644d8e0bee6cea2c8819/conda_subprocess-0.0.1.tar.gz",
    "platform": null,
    "description": "# conda subprocess\nRun a subprocess in a different conda environment. \n\n## Example \nCreate a new conda environment - in this example a conda environment for Python 3.12:\n```commandline\nconda create -n py312 python=3.12 \n```\n\nOpen a python shell in your base environment where `conda_subprocess` is installed and execute `python --version` in the\n`py312` environment:\n```python\nfrom conda_subprocess import check_output\ncheck_output(\"python --version\", prefix_name=\"py312\")\n>>> b'Python 3.12.1\\n'\n```\n\nAlternatively, the environment can be specified with the absolute path:\n```python\nfrom conda_subprocess import check_output\ncheck_output(\"python --version\", prefix_path=\"/Users/janssen/mambaforge/envs/py312\")\n>>> b'Python 3.12.1\\n'\n```\n\nAs expected the process for the arguments for the subprocess call can also be defined as list:\n```python\nfrom conda_subprocess import check_output\ncheck_output([\"python\", \"--version\"], prefix_path=\"/Users/janssen/mambaforge/envs/py312\")\n>>> b'Python 3.12.1\\n'\n```\n\nIn addition to the `check_output()` function also the `check_call()` function is implemented:\n```python\nfrom conda_subprocess import check_call\ncheck_call(\"python --version\", prefix_name=\"py312\")\n>>> Python 3.12.1\n>>> 0\n```\n\nAs well as the `call()` function:\n```python\nfrom conda_subprocess import call\ncall(\"python --version\", prefix_name=\"py312\")\n>>> Python 3.12.1\n>>> 0\n```\n\nAnd the `run()` function:\n```python\nfrom conda_subprocess import run\nrun(\"python --version\", prefix_name=\"py312\")\n>>> Python 3.12.1\n>>> CompletedProcess(args=['/bin/bash', '/var/folders/9p/rztyv06d0xv4h26cyv8nrw3m0000gq/T/tmpm8b8i0r3'], returncode=0)\n```\nAs the `CompletedProcess` arguments illustrate `conda_subprocess` is internally writing the commands to a temporary file\nfor execution, to guarantee the conda environment is correctly activated.\n\nFor interactive communication `conda_subprocess` implements the `Popen` interface:\n```python\nfrom subprocess import PIPE\nfrom conda_subprocess import Popen\nprocess = Popen([\"python\", \"--version\"], stdout=PIPE, prefix_name=\"py312\")\nprocess.communicate()\n>>> (b'Python 3.12.1\\n', None)\n```\n\n## Remarks\n* The `shell` parameter and the `env` parameter are not supported in `Popen()` and all derived methods. \n* The `pipesize` parameter and the `process_group` parameter were removed for compatibility with python 3.9. \n",
    "bugtrack_url": null,
    "license": "BSD 3-Clause License  Copyright (c) 2023, pyiron All rights reserved.  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:  * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.  * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.",
    "summary": "Run a subprocess in a different conda environment.",
    "version": "0.0.1",
    "project_urls": {
        "Repository": "https://github.com/pyiron/conda_subprocess"
    },
    "split_keywords": [
        "conda",
        "subprocess"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b3c496ad5fee1feddac9d4c0c2834f6ef8fb9d14d532f09640afd10754975c3d",
                "md5": "f00dc1ae6a65ea4e9adb7e8e93671d27",
                "sha256": "7f2a5c2d8e7aaef4e9dc8ba8389bba7acc8da3fff78cf476bb00f37f095d7d8c"
            },
            "downloads": -1,
            "filename": "conda_subprocess-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f00dc1ae6a65ea4e9adb7e8e93671d27",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 14316,
            "upload_time": "2024-01-20T19:48:38",
            "upload_time_iso_8601": "2024-01-20T19:48:38.199997Z",
            "url": "https://files.pythonhosted.org/packages/b3/c4/96ad5fee1feddac9d4c0c2834f6ef8fb9d14d532f09640afd10754975c3d/conda_subprocess-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2e6b4dd68c4d4159ffee54d2fa098ebe7e22b699bb72644d8e0bee6cea2c8819",
                "md5": "a527803797c5f97ee3b4c67e68ace84a",
                "sha256": "f8a3a811f45b13aecfea054ca6c11c4c8e4a751be44bcc823537889c749a8ec9"
            },
            "downloads": -1,
            "filename": "conda_subprocess-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "a527803797c5f97ee3b4c67e68ace84a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 7198,
            "upload_time": "2024-01-20T19:48:39",
            "upload_time_iso_8601": "2024-01-20T19:48:39.724954Z",
            "url": "https://files.pythonhosted.org/packages/2e/6b/4dd68c4d4159ffee54d2fa098ebe7e22b699bb72644d8e0bee6cea2c8819/conda_subprocess-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-20 19:48:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pyiron",
    "github_project": "conda_subprocess",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "conda-subprocess"
}
        
Elapsed time: 0.17689s