Skip to main content

yen

The last Python environment manager you'll ever need.

Credits: xkcd.com/1987

We're finally putting an end to this XKCD.

So what can yen do?

  • Get any Python version running instantly with just 1 command:

    $ python
    'python': command not found
    
    $ yen exec --python 3.12
    Downloading 3.12.3 ━━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 17.4/17.4 MB • 29.1 MB/s
    Python 3.12.3 (main, Apr 15 2024, 17:43:11) [Clang 17.0.6 ] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> exit()
    
    $ yen exec --python 3.12  # Cached for subsequent uses:
    Python 3.12.3 (main, Apr 15 2024, 17:43:11) [Clang 17.0.6 ] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    

    Works on Windows, MacOS and Linux (libc and musl), on Intel and ARM chips.

  • Instant venv creation: Thanks to microvenv, yen can create virtual environments much faster than the builtin venv module:

    $ yen create venv -p 3.9
    Created venv with Python 3.9.18 ✨
    
    $ source venv/bin/activate
    
    (venv) $ python --version
    Python 3.9.18
    

    NOTE: It's not that fast right now as I found a bug. Working on it.

  • Zero dependencies: No need to have Python installed, no need to look into apt, homebrew etc., just run one shell command to get yen set up locally.

  • Python script management: Never run pip install to get a tool like ruff, awscli etc. in the global Python environment ever again.

Essentially, yen lets you replace various Python environment management tools such as pyenv, pipx and virtualenv, with a single static binary.

Running Python code on any machine has never been this easy.

Installation

Get yen by running the following command:

  • MacOS / Linux:

    curl -L yen.tushar.lol/install.sh | sh
    
  • Windows:

    Using cmd:

    curl -L yen.tushar.lol/install.bat -o yen-install.bat
    yen-install.bat
    

    or using Powershell:

    curl yen.tushar.lol/install.ps1 | Invoke-Expression
    

or if you prefer, get it via pip:

pip install yen

or pipx:

pipx run yen

Yeah, if you already have yen, you can do yen run yen and that works. But don't do that.

You can also grab the binary from GitHub releases.

Usage

$ yen list
Available Pythons:
3.12.3
3.11.9
3.10.14
3.9.19
3.8.19

$ yen create venv -p 3.12
Downloading 3.12.3 ━━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 17.4/17.4 MB • 12.4 MB/s
Created venv with Python 3.12.3 ✨

$ yen install meowsay
Installed package meowsay with Python 3.12.3 ✨

$ meowsay hello!
 ________
< hello! >
 --------
        \      |\---/|
         \     | ,_, |
                \_`_/-..----.
             ___/ `   ' ,\"\"+ \  sk
            (__...'   __\    |`.___.';
              (_,...'(_,.`__)/'.....+

$ yen run --python 3.9 wttr
Weather report: Milano, Italy

     \  /       Partly cloudy
   _ /"".-.     20 °C
     \_(   ).   ↑ 4 km/h
     /(___(__)  10 km
                0.0 mm

$ wttr paris
Weather report: paris

      \   /     Sunny
       .-.      +22(25) °C
    ― (   ) ―   ↓ 7 km/h
       `-’      10 km
      /   \     0.0 mm

By default the Pythons will be downloaded in ~/.yen_pythons. You can change this location by setting the YEN_PYTHONS_PATH environment variable.

Local Development / Testing

  • Run yen create venv and venv/bin/activate

  • Run pip install -r requirements-dev.txt to do an editable install

  • Verify that you're now pointing at the correct yen:

    $ which yen
    /home/your_name/code/yen/venv/bin/yen
    
  • Run pytest to run tests

To run Rust tests:

  • Compile the rust project: cd yen-rs && cargo build
  • Run export YEN_RUST_PATH=./yen-rs/target/debug/yen-rs
  • Run pytest, and ensure that number of tests ran has doubled.

microvenv.py and userpath.pyz

These two files are used by yen and downloaded by the yen install script.

Type Checking

Run mypy .

Create and upload a package to PyPI

Make sure to bump the version in setup.cfg.

Then run the following commands:

pip install setuptools wheel twine
rm -rf build dist
python setup.py sdist bdist_wheel

Then upload it to PyPI using twine:

twine upload dist/*

Metadata

Release files for yen 0.6.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 yen 0.6.1
File Size Uploaded Provenance Actions
yen-0.6.1.tar.gz 18.6 kB Without provenance Details for yen-0.6.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for yen 0.6.1
File Interpreter ABI Platform Actions
yen-0.6.1-py3-none-any.whl Python 3 none any Details for yen-0.6.1-py3-none-any.whl

Total release size: 35.5 kB

Release files / yen-0.6.1.tar.gz

Download URL yen-0.6.1.tar.gz
Size 18.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9ecff428998b6ba7ca2ae4d8ef3350ac8d2031b60a66c38d7863bbad4ba9ef37
BLAKE2b-256 checksum
How to use checksums
60eac27081137f5dce3e5dd4ac8553900213588e7694df4ee0d6777d50489e94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.3

Release files / yen-0.6.1-py3-none-any.whl

Download URL yen-0.6.1-py3-none-any.whl
Size 16.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a8f5d10d7aac4cd651b7fce2c81e36109b5437d03d65dded7c834f06a1c4cce0
BLAKE2b-256 checksum
How to use checksums
342d43c642f55c1c2dfa416f00d1ae7319e8c5f083a8e2ed26b2f269ed95a235
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.3

Security for yen 0.6.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.

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