Installation & Dependencies
Relevant source files
The following files were used as context for generating this wiki page:
Red is a self-hosted, modular Discord bot that requires a specific Python environment to function. The installation process focuses on setting up a virtual environment and installing necessary packages to ensure cross-compatibility across Windows, macOS, and Linux. This documentation covers the core requirements, development environment setup, and dependency management logic defined in the project's configuration files.
System Requirements
Red requires Python 3.8.1 or greater. The project explicitly verifies the Python version during initialization and exits if the environment does not meet the minimum requirement.
Sources: redbot/init.py:23-31, CONTRIBUTING.md:65
Supported Operating Systems
The project officially supports and tests for the following platforms:
- Windows: Microsoft Windows environments.
- macOS: Apple macOS X.
- Linux: Most major POSIX-compliant Linux distributions.
Sources: pyproject.toml:16-18, README.md:120-124
Dependency Architecture
Red manages dependencies through setup.py and pyproject.toml, utilizing setuptools as the build backend. Dependencies are categorized into base requirements for general use and extra requirements for development or specific database support.
The diagram above illustrates how different requirement files and optional features contribute to the final Red-DiscordBot installation.
Sources: setup.py:34-47, pyproject.toml:2-3
Dependency Categories
| Category | Usage | Source File |
|---|---|---|
| Build System | Required to build and package the bot. | pyproject.toml |
| Base | Core packages needed for the bot to run. | requirements/base.txt |
| Extra: Postgres | Optional support for PostgreSQL databases. | setup.py |
| Dev | Tools for testing, linting, and formatting. | tools/dev-requirements.txt |
Sources: setup.py:46-47, pyproject.toml:1-3, CONTRIBUTING.md:88
Development Environment Setup
Red uses a Makefile (or make.bat on Windows) to automate the creation and synchronization of development environments. The workflow centers on using virtual environments to isolate dependencies.
Installation Procedure
- Fork and Clone: Obtain the source code from the repository.
- Initialize Environment: Run
make newenv. This command performs the following:- Creates a virtual environment in the
.venvsubdirectory. - Installs Red in editable mode, allowing code changes to reflect immediately.
- Installs all base and development dependencies.
- Creates a virtual environment in the
- Activate Environment:
- Posix:
source .venv/bin/activate - Windows:
.venv\Scripts\activate
- Posix:
Sources: CONTRIBUTING.md:73-86
Environment Management Commands
| Command | Action |
|---|---|
make newenv | Clears and replaces the .venv directory with a fresh install. |
make syncenv | Updates the existing environment with the latest dependencies from setup.py and development requirements. |
make reformat | Applies the black formatter to the project. |
Sources: CONTRIBUTING.md:105-115
Versioning and Initialization Logic
Red includes internal logic to verify its own version and the environment it is running in. The VersionInfo class handles parsing version strings and metadata from git repositories or package metadata.
The sequence diagram shows the startup validation process where Red checks the Python version and retrieves its own version metadata before proceeding.
Sources: redbot/init.py:24-31, redbot/init.py:177-210
Conclusion
The installation of Red-DiscordBot is strictly governed by Python versioning requirements and virtual environment management. By utilizing setuptools and a structured Makefile workflow, the project ensures that both end-users and developers maintain a consistent set of dependencies across various platforms. Proper environment synchronization is necessary whenever setup.py or development requirement files change to maintain stability.
Sources: CONTRIBUTING.md:118-125