Skip to main content

iso-env - Run apps in an isolated environment using uv

Lint

MacOS_Tests Ubuntu_Tests Win_Tests

image

About

Got an AI app? Are you in dependency hell because of pytorch? Well, so was I...

Once upon a time I wanted to release an AI tool called transcribe-anything to tie a bunch of AI tools together to do translations across Windows/Mac/Linux without any complicated setup. To do this, I made isolated-environment, a package built ontop of venv. It was extremely messy but got the job done, and transcribe-anything surged in popularity. Fast forward a year later and uv comes out. uv-iso-env is a remake of isolated-environment but built on top of uv, the way god intended it.

Simple Example

import unittest
from pathlib import Path

from iso_env import IsoEnv, IsoEnvArgs, Requirements

REQUIREMENTS_TXT = """
static-ffmpeg
"""


class MainTester(unittest.TestCase):
    """Main tester class."""

    def test_iso_env(self) -> None:
        """Test command line interface (CLI)."""
        args = IsoEnvArgs(
            venv_path=Path(".env_ffmpeg"),
            build_info=Requirements(REQUIREMENTS_TXT, python_version="==3.10.*"),
        )
        iso = IsoEnv(args)
        cp = iso.run(["static_ffmpeg", "-version"])
        print(cp)

        cp = iso.run(["pwd"])
        print(cp)
        print()


if __name__ == "__main__":
    unittest.main()

Complex Example

"""
Unit test file.
"""

import unittest
from pathlib import Path

from iso_env.api import IsoEnv, IsoEnvArgs, PyProjectToml

PY_PROJECT_TOML = PyProjectToml(
    """
[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.10.0"
dependencies = [
    "torch==2.1.2",
]

[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[tool.uv.sources]
torch = [
  { index = "pytorch-cu121", marker = "platform_system == 'Windows'" },
]

[[tool.uv.index]]
name = "pytorch-cu121"
url = "https://download.pytorch.org/whl/cu121"
explicit = true
"""
)


class ComplexInstallTester(unittest.TestCase):
    """Main tester class."""

    @unittest.skip("Skip this test - it takes a long time")
    def test_iso_env(self) -> None:
        """Test command line interface (CLI)."""
        args = IsoEnvArgs(
            venv_path=Path(".env_torch"),
            build_info=PY_PROJECT_TOML,
        )
        iso = IsoEnv(args)
        cp = iso.run(['python', '-c', "import torch; print(torch.__version__)"], check=True)
        print(cp)


if __name__ == "__main__":
    unittest.main()

To develop software, run . ./activate

Windows

This environment requires you to use git-bash.

Linting

Run ./lint to find linting errors.

Footguns

Please don't use shell=True when you run python unless you absolutely need to. Why? Because on Linux, if you are running a script and you have any errors, instead of bombing out immediately, python will drop you into a command terminal. This only happens on Linux (and maybe mac). It's a very nasty bug when you try and run your scripts on linux, causing your scripts to hang. The workaround is to use shutil.which(progname_str) to get the location of the exectuable and pass the resulting full path into iso.run([progname_str, ...], shell=False)

Metadata

Release files for uv-iso-env 1.0.44

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

Built distribution (wheel)

Table of built distributions (wheels) for uv-iso-env 1.0.44
File Interpreter ABI Platform
uv_iso_env-1.0.44-py3-none-any.whl Python 3 none any Details

Release files / uv_iso_env-1.0.44-py3-none-any.whl

Download URL uv_iso_env-1.0.44-py3-none-any.whl
Size 9.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0f902b477d96280aec72ef8de00bcf2226feb8d686a473ed911d6a8be6f915eb
BLAKE2b-256 checksum
How to use checksums
7503e4746d0751e9c89ad6fe68a8cb4fef2d90d8b3067bc2ae98746118dba7ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.1

Release history Release notifications | RSS feed

This release

1.0.44 This release

1 release file

1.0.43

1 release file

1.0.42

1 release file

1.0.41

1 release file

1.0.40

1 release file

1.0.39

1 release file

1.0.37

2 release files

1.0.34

2 release files

1.0.33

2 release files

1.0.32

2 release files

1.0.31

2 release files

1.0.30

2 release files

1.0.29

2 release files

1.0.28

2 release files

1.0.27

2 release files

1.0.26

2 release files

1.0.25

2 release files

1.0.24

2 release files

1.0.23

2 release files

1.0.22

2 release files

1.0.21

2 release files

1.0.20

2 release files

1.0.19

2 release files

1.0.18

2 release files

1.0.17

2 release files

1.0.16

2 release files

1.0.15

2 release files

1.0.14

2 release files

1.0.13

2 release files

1.0.12

2 release files

1.0.11

2 release files

1.0.10

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

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