Crates.io | spyn |
lib.rs | spyn |
version | 0.7.0 |
source | src |
created_at | 2024-03-15 11:47:41.912762 |
updated_at | 2024-06-17 13:02:05.398374 |
description | A tool for creating on-demand Python virtual environments |
homepage | https://github.com/vmalloc/spyn |
repository | https://github.com/vmalloc/spyn |
max_upload_size | |
id | 1174661 |
size | 51,480 |
Spyn is a tool for creating on-demand, ad-hoc virtual environments for running Python applications.
Spyn was heavily inspired by fades, but tries to improve upon the same concept:
uv
for creating and managing virtual environments. This allows it to create virtuelenvs in fractions of seconds and be less prone to pip
breakages and hiccups. It also supports running in offline mode, meaning it only uses its cache and avoids accessing the network thanks to uv
.spyn
needs uv
in order to operate correctly. Make sure you install it as described in the official docs.
The most convenient way is to use homebrew
if you're on macOS, or run the following command:
$ curl -LsSf https://astral.sh/uv/install.sh | sh
You can use cargo install
to install spyn
:
$ cargo install spyn
You can use spyn
to run a Python script, specifying the dependencies it needs:
$ spyn -d requests ./my_script.py
You can also mark dependencies in the script itself which are to be installed by spyn:
$ cat my_script.py
import os
import requests # spyn
print("Hello, World!")
$ spyn ./my_script.py
spyn
even accepts lines marked with fades
to provide backwards compatibility with fades!
If you want an interactive session with custom dependencies, spyn
supports the --ipython
flag, dropping you into an IPython shell with the dependencies you specify:
$ spyn --ipython -d requests
Using Python 3.11.2 interpreter at: /Users/rotemy/src/oss/spyn/.venv/bin/python3
Creating virtualenv at: /var/folders/bs/wqjbrbn948j78gb4303rjdcc0000gn/T/spyn.FDlEhIQvFyXR
Activate with: source /var/folders/bs/wqjbrbn948j78gb4303rjdcc0000gn/T/spyn.FDlEhIQvFyXR/bin/activate
Resolved 21 packages in 451ms
Installed 21 packages in 82ms
...
In [1]: import requests
In [2]: