uv-iso-env


Nameuv-iso-env JSON
Version 1.0.36 PyPI version JSON
download
home_pagehttps://github.com/zackees/iso-env
Summaryisolated environment2, re-written using uv
upload_time2025-02-01 04:30:15
maintainerZachary Vorhies
docs_urlNone
authorNone
requires_python>=3.10
licenseBSD 3-Clause License
keywords template-python-cmd
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # iso-env - Run apps in an isolated environment using uv

[![Lint](https://github.com/zackees/iso-env/actions/workflows/lint.yml/badge.svg)](https://github.com/zackees/iso-env/actions/workflows/lint.yml)

[![MacOS_Tests](https://github.com/zackees/iso-env/actions/workflows/test_macos.yml/badge.svg)](https://github.com/zackees/iso-env/actions/workflows/test_macos.yml)
[![Ubuntu_Tests](https://github.com/zackees/iso-env/actions/workflows/test_ubuntu.yml/badge.svg)](https://github.com/zackees/iso-env/actions/workflows/test_ubuntu.yml)
[![Win_Tests](https://github.com/zackees/iso-env/actions/workflows/test_win.yml/badge.svg)](https://github.com/zackees/iso-env/actions/workflows/test_win.yml)

![image](https://github.com/user-attachments/assets/b7adcbac-0400-4f72-a0cd-3a4f2bea3b4c)

# 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


```python

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

```python
"""
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)` and pass the resulting full path into `iso.run([progname_str, ...], shell=False)`



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/zackees/iso-env",
    "name": "uv-iso-env",
    "maintainer": "Zachary Vorhies",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "template-python-cmd",
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/2d/05/463cd773bcd5a820347b02343521d24fe23cf5e63b371499aafdbde65f85/uv_iso_env-1.0.36.tar.gz",
    "platform": null,
    "description": "# iso-env - Run apps in an isolated environment using uv\r\n\r\n[![Lint](https://github.com/zackees/iso-env/actions/workflows/lint.yml/badge.svg)](https://github.com/zackees/iso-env/actions/workflows/lint.yml)\r\n\r\n[![MacOS_Tests](https://github.com/zackees/iso-env/actions/workflows/test_macos.yml/badge.svg)](https://github.com/zackees/iso-env/actions/workflows/test_macos.yml)\r\n[![Ubuntu_Tests](https://github.com/zackees/iso-env/actions/workflows/test_ubuntu.yml/badge.svg)](https://github.com/zackees/iso-env/actions/workflows/test_ubuntu.yml)\r\n[![Win_Tests](https://github.com/zackees/iso-env/actions/workflows/test_win.yml/badge.svg)](https://github.com/zackees/iso-env/actions/workflows/test_win.yml)\r\n\r\n![image](https://github.com/user-attachments/assets/b7adcbac-0400-4f72-a0cd-3a4f2bea3b4c)\r\n\r\n# About\r\n\r\nGot an AI app? Are you in dependency hell because of `pytorch`? Well, so was I...\r\n\r\nOnce 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.\r\n\r\n# Simple Example\r\n\r\n\r\n```python\r\n\r\nimport unittest\r\nfrom pathlib import Path\r\n\r\nfrom iso_env import IsoEnv, IsoEnvArgs, Requirements\r\n\r\nREQUIREMENTS_TXT = \"\"\"\r\nstatic-ffmpeg\r\n\"\"\"\r\n\r\n\r\nclass MainTester(unittest.TestCase):\r\n    \"\"\"Main tester class.\"\"\"\r\n\r\n    def test_iso_env(self) -> None:\r\n        \"\"\"Test command line interface (CLI).\"\"\"\r\n        args = IsoEnvArgs(\r\n            venv_path=Path(\".env_ffmpeg\"),\r\n            build_info=Requirements(REQUIREMENTS_TXT, python_version=\"==3.10.*\"),\r\n        )\r\n        iso = IsoEnv(args)\r\n        cp = iso.run([\"static_ffmpeg\", \"-version\"])\r\n        print(cp)\r\n\r\n        cp = iso.run([\"pwd\"])\r\n        print(cp)\r\n        print()\r\n\r\n\r\nif __name__ == \"__main__\":\r\n    unittest.main()\r\n```\r\n\r\n# Complex Example\r\n\r\n```python\r\n\"\"\"\r\nUnit test file.\r\n\"\"\"\r\n\r\nimport unittest\r\nfrom pathlib import Path\r\n\r\nfrom iso_env.api import IsoEnv, IsoEnvArgs, PyProjectToml\r\n\r\nPY_PROJECT_TOML = PyProjectToml(\r\n    \"\"\"\r\n[project]\r\nname = \"project\"\r\nversion = \"0.1.0\"\r\nrequires-python = \">=3.10.0\"\r\ndependencies = [\r\n    \"torch==2.1.2\",\r\n]\r\n\r\n[build-system]\r\nrequires = [\"setuptools\", \"wheel\"]\r\nbuild-backend = \"setuptools.build_meta\"\r\n\r\n[tool.uv.sources]\r\ntorch = [\r\n  { index = \"pytorch-cu121\", marker = \"platform_system == 'Windows'\" },\r\n]\r\n\r\n[[tool.uv.index]]\r\nname = \"pytorch-cu121\"\r\nurl = \"https://download.pytorch.org/whl/cu121\"\r\nexplicit = true\r\n\"\"\"\r\n)\r\n\r\n\r\nclass ComplexInstallTester(unittest.TestCase):\r\n    \"\"\"Main tester class.\"\"\"\r\n\r\n    @unittest.skip(\"Skip this test - it takes a long time\")\r\n    def test_iso_env(self) -> None:\r\n        \"\"\"Test command line interface (CLI).\"\"\"\r\n        args = IsoEnvArgs(\r\n            venv_path=Path(\".env_torch\"),\r\n            build_info=PY_PROJECT_TOML,\r\n        )\r\n        iso = IsoEnv(args)\r\n        cp = iso.run(['python', '-c', \"import torch; print(torch.__version__)\"], check=True)\r\n        print(cp)\r\n\r\n\r\nif __name__ == \"__main__\":\r\n    unittest.main()\r\n```\r\n\r\n\r\n\r\nTo develop software, run `. ./activate`\r\n\r\n# Windows\r\n\r\nThis environment requires you to use `git-bash`.\r\n\r\n# Linting\r\n\r\nRun `./lint` to find linting errors.\r\n\r\n# Footguns\r\n\r\nPlease 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)` and pass the resulting full path into `iso.run([progname_str, ...], shell=False)`\r\n\r\n\r\n",
    "bugtrack_url": null,
    "license": "BSD 3-Clause License",
    "summary": "isolated environment2, re-written using uv",
    "version": "1.0.36",
    "project_urls": {
        "Homepage": "https://github.com/zackees/iso-env"
    },
    "split_keywords": [
        "template-python-cmd"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e0b666814543772eb6f3e117e521badc5659c0212ead25e46de68dc8a08f11c1",
                "md5": "747270bfdfc4f0d73b1c96320516a0cc",
                "sha256": "f48e7b99959f991ff123098df314f742ad886caad2af32a618278fb06ad61449"
            },
            "downloads": -1,
            "filename": "uv_iso_env-1.0.36-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "747270bfdfc4f0d73b1c96320516a0cc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 8262,
            "upload_time": "2025-02-01T04:30:13",
            "upload_time_iso_8601": "2025-02-01T04:30:13.462513Z",
            "url": "https://files.pythonhosted.org/packages/e0/b6/66814543772eb6f3e117e521badc5659c0212ead25e46de68dc8a08f11c1/uv_iso_env-1.0.36-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2d05463cd773bcd5a820347b02343521d24fe23cf5e63b371499aafdbde65f85",
                "md5": "0310ee4f4162c7fbe4ebfd5760618572",
                "sha256": "18d7cec0c9b29d10877f46eaf0291db0ced6e39cc51850c35e8259574b0c2d3a"
            },
            "downloads": -1,
            "filename": "uv_iso_env-1.0.36.tar.gz",
            "has_sig": false,
            "md5_digest": "0310ee4f4162c7fbe4ebfd5760618572",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 14582,
            "upload_time": "2025-02-01T04:30:15",
            "upload_time_iso_8601": "2025-02-01T04:30:15.150440Z",
            "url": "https://files.pythonhosted.org/packages/2d/05/463cd773bcd5a820347b02343521d24fe23cf5e63b371499aafdbde65f85/uv_iso_env-1.0.36.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-01 04:30:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "zackees",
    "github_project": "iso-env",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "uv-iso-env"
}
        
Elapsed time: 1.59779s