How To Set Up Environment

First, you may want to check out our get started with tapyr blog post.

Tip

There are many ways to set up the development environment for tapyr. Our order of recommendation is:

  1. Devcontainer: The most consistent and recommended way to set up the environment.
  2. Locally with uv: The recommended way when you can’t use docker.
  3. 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.

  1. 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.

  2. Activate the virtual environment:

    source .venv/bin/activate 
  3. Run the application:

    shiny run app.py --reload
  4. 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:

  1. Install uv: Follow the installation guide.

  2. Clone the repository and navigate to it.

  3. 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:

  1. Clone the repository and navigate to it.

  2. Create a virtual environment:

    python -m venv .venv
    source .venv/bin/activate
  3. Install package with dependencies:

    pip install -e ."[dev]"
    playwright install --with-deps
  4. Run the application:

    shiny run app.py --reload
Caution

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!

Tip

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!