xref: /aosp_15_r20/external/pigweed/pw_build/python_dist/README.md (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1*61c4878aSAndroid Build Coastguard Worker# Python Distributables
2*61c4878aSAndroid Build Coastguard WorkerSetup and usage instructions for Pigweed Python distributables.
3*61c4878aSAndroid Build Coastguard Worker
4*61c4878aSAndroid Build Coastguard Worker## Prerequisites
5*61c4878aSAndroid Build Coastguard WorkerPython distributables require Python 3.10 or later.
6*61c4878aSAndroid Build Coastguard Worker
7*61c4878aSAndroid Build Coastguard Worker## Setup
8*61c4878aSAndroid Build Coastguard WorkerRun the included setup script found inside the unzipped directory. The setup
9*61c4878aSAndroid Build Coastguard Workerscript will create a virtual environment called `python-venv`.
10*61c4878aSAndroid Build Coastguard Worker
11*61c4878aSAndroid Build Coastguard Worker##### Linux / MacOS
12*61c4878aSAndroid Build Coastguard Worker```bash
13*61c4878aSAndroid Build Coastguard Workersetup.sh
14*61c4878aSAndroid Build Coastguard Worker```
15*61c4878aSAndroid Build Coastguard Worker
16*61c4878aSAndroid Build Coastguard WorkerAlternatively, the Linux/MacOS version of the setup script also allows
17*61c4878aSAndroid Build Coastguard Workerinstallation over an existing venv:
18*61c4878aSAndroid Build Coastguard Worker
19*61c4878aSAndroid Build Coastguard Worker```bash
20*61c4878aSAndroid Build Coastguard Workersetup.sh <PATH_TO_EXISTING_VENV>
21*61c4878aSAndroid Build Coastguard Worker```
22*61c4878aSAndroid Build Coastguard Worker
23*61c4878aSAndroid Build Coastguard Worker##### Windows
24*61c4878aSAndroid Build Coastguard Worker```
25*61c4878aSAndroid Build Coastguard Workersetup.bat
26*61c4878aSAndroid Build Coastguard Worker```
27*61c4878aSAndroid Build Coastguard Worker
28*61c4878aSAndroid Build Coastguard Worker##### Constraints File
29*61c4878aSAndroid Build Coastguard WorkerBoth the Linux/MacOS and Windows versions of the setup script support the use
30*61c4878aSAndroid Build Coastguard Workerof a constraints file. If a file named `constraints.txt` is present in the same
31*61c4878aSAndroid Build Coastguard Workerdirectory as the setup script, it will automatically be used during setup to
32*61c4878aSAndroid Build Coastguard Workerconstrain the versions of any Python packages that get installed (see the
33*61c4878aSAndroid Build Coastguard Workerofficial
34*61c4878aSAndroid Build Coastguard Worker[pip documentation](https://pip.pypa.io/en/stable/user_guide/#constraints-files)
35*61c4878aSAndroid Build Coastguard Workerfor details).
36*61c4878aSAndroid Build Coastguard Worker
37*61c4878aSAndroid Build Coastguard Worker
38*61c4878aSAndroid Build Coastguard Worker## Usage
39*61c4878aSAndroid Build Coastguard WorkerOnce setup is complete, the Python tools can be invoked as runnable modules:
40*61c4878aSAndroid Build Coastguard Worker
41*61c4878aSAndroid Build Coastguard WorkerLinux/MacOS:
42*61c4878aSAndroid Build Coastguard Worker```bash
43*61c4878aSAndroid Build Coastguard Workerpython-venv/bin/python -m <MODULE_NAME> [OPTIONS]
44*61c4878aSAndroid Build Coastguard Worker```
45*61c4878aSAndroid Build Coastguard Worker
46*61c4878aSAndroid Build Coastguard WorkerWindows:
47*61c4878aSAndroid Build Coastguard Worker```
48*61c4878aSAndroid Build Coastguard Workerpython-venv\Scripts\python -m <MODULE_NAME> [OPTIONS]
49*61c4878aSAndroid Build Coastguard Worker```
50