Skip to main content

run_in_env

Run python functions inside another environment with the returns brought back into your own python process.

The typical use case is comparing computation across environments, for example to compare the results from two different version of a software from a single analysis notebook.

Install

pip install run_in_env

Requirements: a mamba or conda executable: mamba is preferred when found, conda otherwise. Any conda-compatible executable can also be passed explicitly:

env = CondaEnv(..., conda="conda")

Usage

from run_in_env import CondaEnv

env = CondaEnv(
    "finesse-3.0.2",
    conda_deps=["finesse=3.0.2"],
    pip_deps=["matplotlib-inline"],
)
env.create()                                # idempotent - skipped if env exists
out = env.run(my_function, arg, kw=value)   # host function, env result
proc = env.run("finesse --version")         # a str runs as a command

How it works

CondaEnv.run() serializes the function and its arguments with cloudpickle, executes them inside the environment with conda run, and returns the deserialized result. A function defined in a notebook cell can be sent to the environment as is. Passing a str instead executes it as a command inside the environment (split with shlex, no shell) and returns the subprocess.CompletedProcess.

Environments

Environments are created with the python version of the calling process to prevent any serialisation/deserialisation problem.

Licence

run_in_env is distributed under the terms of the GNU Affero General Public License v3.0 (AGPL-3.0-only). See LICENSE for the full text.

Metadata

Release files for run-in-env 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for run-in-env 1.0.1
File Size Uploaded Provenance Actions
run_in_env-1.0.1.tar.gz 21.5 kB Without provenance Details for run_in_env-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for run-in-env 1.0.1
File Interpreter ABI Platform Actions
run_in_env-1.0.1-py3-none-any.whl Python 3 none any Details for run_in_env-1.0.1-py3-none-any.whl

Total release size: 39.6 kB

Release files / run_in_env-1.0.1.tar.gz

Download URL run_in_env-1.0.1.tar.gz
Size 21.5 kB
Tags Source
SHA-256 checksum
How to use checksums
1011d7010dea44996be924141ae29b443fac7f8486ab8e03143a8506def08a63
BLAKE2b-256 checksum
How to use checksums
60f58d0a738b3ac06ef9866f9102577b86ec2b0e27854baa6f8e2e4c2bdaac0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / run_in_env-1.0.1-py3-none-any.whl

Download URL run_in_env-1.0.1-py3-none-any.whl
Size 18.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ef617588e3826be41e735a50df5465fcc26c19b7fa6b15ec24ec986aa079ba97
BLAKE2b-256 checksum
How to use checksums
e4f7a1175ee51507d7823e748e1ea868745100c3f48111c4371c194725308c2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.18

Security for run-in-env 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page