|
1 | 1 | Installation |
2 | 2 | ============ |
3 | 3 |
|
4 | | -You will need Python 3.8 or higher to use StagPy. StagPy is available on |
5 | | -the Python Package Index, via `pip`. |
| 4 | +StagPy is available on the [Python Package |
| 5 | +Index](https://pypi.org/project/stagpy/). |
6 | 6 |
|
7 | | -If you don't have sufficient permissions to install or update Python, you can |
8 | | -use [pyenv to manage Python](https://github.com/pyenv/pyenv). |
| 7 | +You can use [uv to manage Python environments](https://docs.astral.sh/uv/). |
9 | 8 |
|
10 | | -Installation using `pip` |
| 9 | +Installation as a CLI tool |
11 | 10 | -------------------------- |
12 | 11 |
|
13 | | -In most cases, installing StagPy with `pip` should be as simple as: |
| 12 | +If you are interested in using the `stagpy` command line interface, |
| 13 | +you can install it as a tool with uv: |
14 | 14 |
|
15 | 15 | ```sh title="shell" |
16 | | -python3 -m pip install stagpy |
| 16 | +uv tool install stagpy |
17 | 17 | ``` |
18 | 18 |
|
19 | | -It might be preferable or even necessary to install StagPy in a virtual |
20 | | -environment to isolate it from other packages that could conflict with it: |
| 19 | +This installs `stagpy` in its own environment, isolated from other packages to |
| 20 | +avoid conflicts. |
| 21 | + |
| 22 | +You can then update StagPy with the following command: |
21 | 23 |
|
22 | 24 | ```sh title="shell" |
23 | | -python3 -m venv stagpyenv |
24 | | -source stagpyenv/bin/activate |
25 | | -python3 -m pip install stagpy |
| 25 | +uv tool upgrade stagpy |
26 | 26 | ``` |
27 | 27 |
|
28 | | -You can then update StagPy with the following command: |
| 28 | +[More information about uv tools](https://docs.astral.sh/uv/concepts/tools/). |
| 29 | + |
| 30 | +Installation in a uv managed environment |
| 31 | +---------------------------------------- |
| 32 | + |
| 33 | +A convenient way to use StagPy in script is by leveraging uv environments. |
| 34 | + |
| 35 | +With the following (setting versions as desired for your project): |
| 36 | + |
| 37 | +```toml title="pyproject.toml" |
| 38 | +[project] |
| 39 | +name = "my-project" |
| 40 | +version = "0.1.0" |
| 41 | +requires-python = ">=3.10" |
| 42 | +dependencies = [ |
| 43 | + "stagpy~=0.19.0", |
| 44 | +] |
| 45 | +``` |
| 46 | + |
| 47 | +You can then run a script using `stagpy`, for example: |
| 48 | + |
| 49 | +```py title="my_script.py" |
| 50 | +import stagpy |
| 51 | + |
| 52 | +print(stagpy.__version__) |
| 53 | +``` |
| 54 | + |
| 55 | +with the following command |
| 56 | + |
| 57 | +```sh title="shell" |
| 58 | +uv run my_script.py |
| 59 | +``` |
| 60 | + |
| 61 | +You can run any arbitrary command via uv, including `stagpy` |
| 62 | +itself: |
29 | 63 |
|
30 | 64 | ```sh title="shell" |
31 | | -python3 -m pip install -U stagpy |
| 65 | +uv run -- stagpy version |
32 | 66 | ``` |
33 | 67 |
|
34 | | -See the [official |
35 | | -documentation](https://packaging.python.org/en/latest/tutorials/installing-packages/) |
36 | | -for more information about installing Python packages. |
37 | 68 |
|
38 | 69 | Some setup |
39 | 70 | ---------- |
|
0 commit comments