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.2

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.2
File Size Uploaded Provenance Actions
run_in_env-1.0.2.tar.gz 22.5 kB Without provenance Details for run_in_env-1.0.2.tar.gz

Built distribution (wheel)

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

Total release size: 41.0 kB

Release files / run_in_env-1.0.2.tar.gz

Download URL run_in_env-1.0.2.tar.gz
Size 22.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9e5cd94ca43b6fee5d6e2e49e6c1e54d78f9f2a08d24a8d212b3afbe5de2dbe6
BLAKE2b-256 checksum
How to use checksums
b67da612b4c4518e24d0e8ff8f1600ffaccc44c7f4afc7a5920c6b54b87ec9c8
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.2-py3-none-any.whl

Download URL run_in_env-1.0.2-py3-none-any.whl
Size 18.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6481c45f9c66c73ff8810b541f3549e4f5963a3562603b944af36f060156934e
BLAKE2b-256 checksum
How to use checksums
5fcd9fb5e9bfa11d25703da4ee1cb8428fdc782fa035b7544a54d8d312a906db
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.2

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.2 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