Skip to main content

ms_env

Environments for MolSuite apps: find an external tool that already works, or install it, on this machine or on a host reached over ssh. Standard library only.

A recipe says how to tell that a tool works and how to install it. A host says where. ms_env applies one to the other.

from ms_env import READY, Host, ToolSpec, ensure, locate

spec = ToolSpec.load("openbabel.toml")

recipe = spec.recipe("/home/me/.myapp/tools")      # bound to this machine
state, executable = locate(recipe)                  # (READY, ".../bin/obabel") or (MISSING, "")
if state != READY:
    install = ensure(recipe)                        # returns at once: a daemon thread installs
    install.future.result()                         # wait; `install.lines` is the live log

cluster = Host("me@login.hpc")                    # as `ssh` knows it
ensure(spec.recipe("/home/me/.myapp/tools"), cluster).future.result()

A recipe

One TOML file per tool, shipped by the app:

[tool]
name = "openbabel"
label = "OpenBabel"
version = "3.1.1"                         # pinned here; never a user option
prefix = "{tools_home}/{name}/{version}"  # the default

[locate]
paths = ["{bin}/obabel"]                  # where the install puts it; +".exe" on Windows
commands = ["obabel"]                     # looked up on PATH
check = ["{exe}", "-V"]                   # {exe} = the candidate; none: being there is enough

[env]                                     # a conda prefix at {prefix}
conda = ["openbabel={version}"]
pip = []

[[install]]                               # plain steps, after [env]
name = "fetch the weights"
argv = ["{python}", "-m", "tool.fetch", "{prefix}/weights"]
timeout = 1800

[[install]]                               # a download, checked, per platform
name = "download the binary"
to = "{prefix}/tool"                      # an archive is unpacked into `to`; a file keeps ".exe"
download.linux-64 = { url = "https://.../tool_linux", sha256 = "..." }
download.win-64 = { url = "https://.../tool.exe", sha256 = "..." }
# the same file everywhere: download = { url = "...", sha256 = "..." }

{bin} and {python} are where a conda environment keeps them: {prefix}/bin and {prefix}/bin/python, or {prefix}/Library/bin and {prefix}/python.exe on Windows. Platforms are named as conda names them (linux-64, linux-aarch64, osx-64, osx-arm64, win-64; Host.platform() says the host's). A download needs its sha256. On a platform none of its downloads names, the tool has no build: recipe.unsupported says so and ensure fails with it. A remote host gets a download made and checked here, then sent over ssh: it needs no curl.

Lookup on a host, first candidate whose check exits 0 wins: the paths the user registered, the managed install under tools_home, then PATH. [env] is created with micromamba: the one on the host's PATH, or one downloaded into tools_home. Another conda-type program is used only when the app names it (manager=).

Whose an environment is

ensure stamps the prefix it installs. The stamp decides what may happen to it:

At the prefix ensure remove
Nothing Creates it Nothing to delete
A stamp of this recipe Nothing Deletes it
A stamp of another recipe (the TOML changed) Creates it again: the update Deletes it
Something without a stamp: the user's own environment Verifies it, never changes it Leaves it
from ms_env import remove, verify

mine = spec.recipe("/home/me/.myapp/tools", prefix="/home/me/envs/babel")   # an environment I already have
verify(mine)    # [] when it meets the recipe, else what it lacks:
                # ["conda: openbabel=3.1.1 is asked for and is not there"]
remove(recipe)  # True: ms_env had installed it and it is gone

verify looks up every pinned conda package, every pinned pip package and the recipe's check, and only reads. An executable registered on its own (extra_paths=) is not an environment: it only has to pass the check.

ensure(recipe, host, busy=why) asks why() before it changes an install of its own: a reason ("2 jobs are running from it") makes the install fail and leaves the prefix as it is.

A host

Host() is this machine. Host("me@login.hpc") runs every command through the system's ssh with BatchMode=yes: users, keys and jumps come from ~/.ssh/config, the key logs in or the command fails at once, no credential is handled and nothing is left listening on the other side. Outside Windows the commands to one host share one connection (a socket in ~/.ssh, closed a minute after the last command). A remote host is a POSIX machine: every command there runs through sh. This machine needs no sh: what ms_env does here it does in Python, Windows included.

The environment of an app

app_recipe makes the recipe that gives a host the environment an app runs in here: the same Python, the same versions, and the code of a source checkout as it is now.

from ms_env import app_recipe

home = cluster.home()
recipe = app_recipe("myapp", ["myapp"], ["myapp"], prefix=f"{home}/.myapp/env",
                    tools_home=f"{home}/.myapp/tools", cache="/home/me/.myapp/cache/wheels")
ensure(recipe, cluster).future.result()

Install

pip install ms_env

Documentation: https://molsuite.github.io/ms_env/

Metadata

Release files for ms-env 0.4.0

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

Source distribution (sdist)

Source distribution for ms-env 0.4.0
File Size Uploaded Provenance Actions
ms_env-0.4.0.tar.gz 38.4 kB With provenance Details for ms_env-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ms-env 0.4.0
File Interpreter ABI Platform Actions
ms_env-0.4.0-py3-none-any.whl Python 3 none any Details for ms_env-0.4.0-py3-none-any.whl

Total release size: 64.3 kB

Release files / ms_env-0.4.0.tar.gz

Download URL ms_env-0.4.0.tar.gz
Size 38.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ed6ab67c1d000f3ce62034d191ffff9ad67bba22af714abcc4eb145192461891
BLAKE2b-256 checksum
How to use checksums
095a37078591e7e8ef42a7bb637313e002a1b8e5bbfc6b752ea44554da8d6f84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / ms_env-0.4.0-py3-none-any.whl

Download URL ms_env-0.4.0-py3-none-any.whl
Size 25.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f82f1c76cf57864d84cb29f50b59c4ec243b7c281d0fb14ccdc3ac14c5c401c8
BLAKE2b-256 checksum
How to use checksums
5d0367da967a06583ad827fc0462f4eefbebcc8a7dbdf75e4c9b5adf159ced4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Security for ms-env 0.4.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ms_env-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

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.

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