Name | conda-subprocess JSON |
Version |
0.0.9
JSON |
| download |
home_page | None |
Summary | Run a subprocess in a different conda environment. |
upload_time | 2025-08-13 06:26:36 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | BSD 3-Clause License
Copyright (c) 2023, Jan Janssen
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
[](https://github.com/pyiron/conda_subprocess/actions/workflows/pipeline.yml)
[](https://codecov.io/gh/pyiron/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
```
### Subprocess Interface
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)
```
### Decorator
In analogy to the subprocess interface the `conda_subprocess` also introduces the `@conda` decorator to
execute python functions in a separate conda environment:
```python
from conda_subprocess.decorator import conda
@conda(prefix_name="py312")
def add_function(parameter_1, parameter_2):
return parameter_1 + parameter_2
add_function(parameter_1=1, parameter_2=2)
>>> 3
```
## 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": null,
"name": "conda-subprocess",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "conda, subprocess",
"author": null,
"author_email": "Jan Janssen <janssen@mpie.de>",
"download_url": "https://files.pythonhosted.org/packages/b4/93/27ecdbed56a5cc5a42dcc72797998290844f823041883428c5744cf5302e/conda_subprocess-0.0.9.tar.gz",
"platform": null,
"description": "# conda subprocess\n[](https://github.com/pyiron/conda_subprocess/actions/workflows/pipeline.yml)\n[](https://codecov.io/gh/pyiron/conda_subprocess)\n\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\n### Subprocess Interface\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### Decorator \nIn analogy to the subprocess interface the `conda_subprocess` also introduces the `@conda` decorator to \nexecute python functions in a separate conda environment:\n```python\nfrom conda_subprocess.decorator import conda\n\n@conda(prefix_name=\"py312\")\ndef add_function(parameter_1, parameter_2):\n return parameter_1 + parameter_2\n\nadd_function(parameter_1=1, parameter_2=2)\n>>> 3\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\n \n Copyright (c) 2023, Jan Janssen\n All rights reserved.\n \n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are met:\n \n * Redistributions of source code must retain the above copyright notice, this\n list of conditions and the following disclaimer.\n \n * Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimer in the documentation\n and/or other materials provided with the distribution.\n \n * Neither the name of the copyright holder nor the names of its\n contributors may be used to endorse or promote products derived from\n this software without specific prior written permission.\n \n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.",
"summary": "Run a subprocess in a different conda environment.",
"version": "0.0.9",
"project_urls": {
"Repository": "https://github.com/pyiron/conda_subprocess"
},
"split_keywords": [
"conda",
" subprocess"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "8053e5ac6f419b131b4887e4ce73bc717174c8344bb448fb3670e60e676ad24a",
"md5": "263712a55166db8b2a1c309d267a1028",
"sha256": "392db09fe89b0ec41c7634fd762e0b865d3e7b6d872b658424b80c4f615940b2"
},
"downloads": -1,
"filename": "conda_subprocess-0.0.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "263712a55166db8b2a1c309d267a1028",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 9548,
"upload_time": "2025-08-13T06:26:35",
"upload_time_iso_8601": "2025-08-13T06:26:35.646519Z",
"url": "https://files.pythonhosted.org/packages/80/53/e5ac6f419b131b4887e4ce73bc717174c8344bb448fb3670e60e676ad24a/conda_subprocess-0.0.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "b49327ecdbed56a5cc5a42dcc72797998290844f823041883428c5744cf5302e",
"md5": "571c68f193ae0a9bbe30f62b8fedb07d",
"sha256": "8275632d6f1e9d1adf8486f25ced52bfe8675443f7339568bad946ae056074d5"
},
"downloads": -1,
"filename": "conda_subprocess-0.0.9.tar.gz",
"has_sig": false,
"md5_digest": "571c68f193ae0a9bbe30f62b8fedb07d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 7532,
"upload_time": "2025-08-13T06:26:36",
"upload_time_iso_8601": "2025-08-13T06:26:36.701496Z",
"url": "https://files.pythonhosted.org/packages/b4/93/27ecdbed56a5cc5a42dcc72797998290844f823041883428c5744cf5302e/conda_subprocess-0.0.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-13 06:26:36",
"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"
}