Principle:MarketSquare Robotframework browser Development Environment Setup
Overview
The robotframework-browser project requires both Python and Node.js toolchains to develop, build, and test. Setting up a reproducible development environment is the first step for any contributor. The project provides a bootstrap script that automates virtual environment creation and dependency installation, ensuring every developer works with a consistent set of tools and versions.
Core Concept
A reproducible development environment means that every developer, regardless of their system-level Python or Node.js installation, works within an isolated and consistent set of dependencies. The key mechanisms are:
- Python virtual environment (
venv) -- Isolates Python packages from the system installation, preventing version conflicts - uv -- A fast Python package installer (written in Rust) that replaces
pip installfor speed, used to install both development and project dependencies - npm -- The Node.js package manager, used separately (via
inv deps) for Node.js dependencies
Bootstrap Process
The bootstrap script performs these steps in sequence:
- Check for existing virtual environment -- If
.venv/already exists, skip creation - Create virtual environment -- Uses Python's built-in
venv.EnvBuilderwith pip enabled - Install uv -- Upgrades pip and installs the
uvpackage installer into the virtual environment - Install development dependencies -- Uses
uv pip installwithBrowser/dev-requirements.txt - Install project dependencies -- Uses
uv pip installwithpyproject.toml - Print activation instructions -- Displays the OS-appropriate command to activate the virtual environment
Dependency Categories
The project has two distinct sets of Python dependencies:
| Category | Source File | Contents |
|---|---|---|
| Development dependencies | Browser/dev-requirements.txt |
Testing tools (pytest, robotstatuschecker, pabot), linting (ruff, mypy), build tools (invoke, build, twine), and other development utilities |
| Project dependencies | pyproject.toml |
Runtime dependencies of the Browser library itself (robotframework, grpcio, etc.) |
Node.js dependencies are defined in package.json and package-lock.json and are installed separately via the inv deps task.
Platform Awareness
The bootstrap script is platform-aware:
- On Unix/macOS: The virtual environment Python is at
.venv/bin/pythonand activation issource .venv/bin/activate - On Windows: The virtual environment Python is at
.venv/Scripts/python.exeand activation is.venv\Scripts\activate.bat
Why uv Instead of pip
The project uses uv for dependency installation because:
- It is significantly faster than pip for resolving and installing packages
- It supports the same requirements file formats and pyproject.toml
- It provides the
--systemflag for CI environments where virtual environments are not used - It is installed as a pip package itself, so it can be bootstrapped from any Python environment
Domains
- Development_Tooling -- The bootstrap script is a developer productivity tool
- Environment_Management -- Virtual environments provide dependency isolation
Implemented By
Related Topics
- MarketSquare_Robotframework_browser_Bootstrap_Script -- Implementation details of the bootstrap script
- MarketSquare_Robotframework_browser_Project_Build_Pipeline -- The next step after environment setup
- MarketSquare_Robotframework_browser_Inv_Build -- The build tasks that depend on the development environment