How To Set Up Environment
First, you may want to check out our get started with tapyr
blog post.
There are many ways to set up the development environment for tapyr
. Our order of recommendation is:
- Devcontainer: The most consistent and recommended way to set up the environment.
- Locally with
uv
: The recommended way when you can’t use docker. - Locally with
pip
: The least recommended way, but still possible. The most error-prone.
Using Devcontainer
To ensure a consistent development experience across all environments, we recommend using the devcontainer configuration with Visual Studio Code or DevPod for container-based development.
Start the Devcontainer: Open the project in VS Code and select “Reopen in Container” when prompted, or use the Command Palette (
Ctrl+Shift+P
) and choose “Remote-Containers: Reopen in Container”. Alternatively, use DevPod following their instructions.Activate the virtual environment:
source .venv/bin/activate
Run the application:
shiny run app.py --reload
Execute tests:
pytest
Note: The Devcontainer might limit some playwright
features, such as codegen
. For full functionality, consider a local setup.
Setting Up Locally with uv
For developers preferring a local setup without Devcontainer:
Install
uv
: Follow the installation guide.Clone the repository and navigate to it.
Install dependencies:
uv sync uv run playwright install --with-deps
Attention: Follow any additional steps prompted by playwright install
.
Setting Up Locally with pip
Although not recommended, you can set up the project using pip
:
Clone the repository and navigate to it.
Create a virtual environment:
python -m venv .venv source .venv/bin/activate
Install package with dependencies:
pip install -e ."[dev]" playwright install --with-deps
Run the application:
shiny run app.py --reload
With pip you have to carefully manage the dependencies yourself, in pyproject.toml
or requirements.txt
. Use pip
only if you can’t use uv
or poetry
.
Running the Application
You’re ready to run the application with
uv run shiny run app.py --reload
Congratulations!
Some prefer to activate the virtual environment instead of using uv
directly. To activate the environment and run shiny app this way, use:
source .venv/bin/activate
shiny run app.py --reload
Using uv run
may look more verbose, but it works as a safeguard for the environment consistency. E.g., if you modify the pyproject.toml
file, and run uv run main.py
, uv
will first update the environment and run the script with the up-to-date environment!