Chapter 01
Project Setup
⏱ 10 minutes · You will clone the repo, install everything in an isolated environment, and run the tests once.
What you need
| Tool | Version | Used for |
|---|---|---|
| Git | any recent | cloning the repository |
| uv | 0.5 or newer | Python, virtual environment and dependencies, in one tool |
| Docker | 24 or newer | chapters 09 and 10 |
uv downloads the right Python for you. Prefer pip? Every step has a pip alternative below.
1. Clone the repository
git clone https://github.com/jars-demo/pyarmor-demo.git
cd pyarmor-demoWhat it does: downloads the repository and moves into it.
Why: every command in this workshop runs from the repository root unless it says otherwise.
Expected: a pyarmor-demo/ folder with app/, scripts/, tests/ and workshop/ inside.
2. Create the environment and install dependencies
uv syncWhat it does: installs Python 3.12 if needed, creates .venv/, and installs the exact
versions locked in uv.lock: FastAPI and uvicorn for the app, pytest and ruff for development,
and PyArmor 9.2.7 for protection.
Why: an isolated environment keeps PyArmor and the app's dependencies away from the rest of
your machine, and the lockfile means everyone in the workshop runs the same versions.
Expected: Installed NN packages and a new .venv/ folder.
Without uv:
python -m venv .venv
source .venv/bin/activate # Windows PowerShell: .venv\Scripts\Activate.ps1
pip install --require-hashes -r requirements.txt
pip install pytest==9.1.1 httpx==0.28.1 ruff==0.16.10 pyarmor==9.2.7(requirements.txt pins every runtime package with a hash, so it is installed on its own.)
With an activated environment, drop the uv run prefix from every command in this workshop.
3. Configure (optional)
cp .env.example .envWhat it does: copies the example settings: host, port (8300), log level and environment name.
Why: every value has a sensible default, so this step is optional. It is here so you know
where configuration lives: in the environment, never in the code.
Expected: a .env file, which Git ignores.
4. Run the tests
uv run pytestWhat it does: runs the test suite against the original source. Why: this is your baseline. Later you run the very same tests against the protected build. If both pass, obfuscation did not change behaviour. Expected:
38 passed in 0.15s5. Start the API
uv run python -m appWhat it does: starts the FastAPI app with uvicorn on http://127.0.0.1:8300.
Why: to check the app runs before you change anything.
Expected: Uvicorn running on http://127.0.0.1:8300. Open http://127.0.0.1:8300/docs for
the interactive API docs, then stop the server with Ctrl+C.