https://github.com/stefanhoelzl/scriptenv
lightweight virtual env for python scripts
https://github.com/stefanhoelzl/scriptenv
python virtualenv
Last synced: about 1 year ago
JSON representation
lightweight virtual env for python scripts
- Host: GitHub
- URL: https://github.com/stefanhoelzl/scriptenv
- Owner: stefanhoelzl
- License: mit
- Created: 2021-06-10T08:37:49.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-12-22T16:41:56.000Z (over 4 years ago)
- Last Synced: 2025-04-18T09:46:11.937Z (about 1 year ago)
- Topics: python, virtualenv
- Language: Python
- Homepage: https://stefanhoelzl.github.io/scriptenv/
- Size: 541 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# scriptenv
[](https://github.com/stefanhoelzl/scriptenv/actions)
[](https://stefanhoelzl.github.io/scriptenv/coverage)
[](https://pypi.org/project/scriptenv/)
[](https://pypistats.org/packages/scriptenv)
[](LICENSE)
Define requirements inside your python code and `scriptenv` makes them ready to import.
## Getting Started
Install `scriptenv`
```bash
$ pip install scriptenv
```
use any package you want in your REPL or short-lived scripts
```python
import scriptenv
scriptenv.requires('rsa==4.8')
import rsa
assert rsa.__version__ == "4.8"
rsa.newkeys(32)
```
use a binary/entry point defined in any package
```bash
$ scriptenv run -r black==21.5b2 -- black --version
black, version 21.5b2
```
## Why Another Venv/Package Manager Project
The goal of this project is to provide a way to define your dependencies in your script you want to run
and requires no extra setup steps for a virtual env.
The scope is for small scripts you want to share or you only want to run from time to time.
For sharing scripts it is also not necessary anymore to also share a `requirements.txt` file.
It works also within your REPL.
## How It Works
`scriptenv` installs every dependency it ever sees in a seperate folder
and prepends the folders for the defined dependencies in a script to `sys.path`.
## Development
### Getting Started
Open in [gitpod.io](https://gitpod.io#github.com/stefanhoelzl/scriptenv)
Get the code
```bash
$ git clone https://github.com/stefanhoelzl/scriptenv.git
$ cd scriptenv
```
Optionally create a [venv](https://docs.python.org/3.8/library/venv.html)
```bash
$ python -m venv venv
$ source venv/bin/activate
```
Install required python packages
```bash
$ pip install -r requirements.txt
```
Install scriptenv from repository
```bash
$ pip install -e .
```
Run tests and file checks
```bash
$ pytest
```
Trigger a new release build
```bash
$ python tools/release.py release-candidate
```
Update all requirements
```
$ python tools/requirements.py update
```