forked from enviPath/enviPy
## Summary This PR improves the local development setup experience by adding Docker Compose and Makefile for streamlined setup. ## Changes - **Added `docker-compose.yml`**: for one-command PostgreSQL database setup - **Added `Makefile`**: Convenient shortcuts for common dev tasks (\`make setup\`, \`make dev\`, etc.) - **Updated `README.md`**: Quick development setup instructions using Make - - **Added**: RDkit installation pain point documentation - **Fixed**: Made Java feature properly dependent ## Why these changes? The application uses PostgreSQL-specific features (\`ArrayField\`) and requires an anonymous user created by the bootstrap command. This PR makes the setup process trivial for new developers: ```bash cp .env.local.example .env make setup # Starts DB, runs migrations, bootstraps data make dev # Starts development server ``` Java fix: Moved global Java import to inline to avoid everyone having to configure the Java path. Numerous changes to view and settings. - Applied ruff-formatting ## Testing Verified complete setup from scratch works with: - PostgreSQL running in Docker - All migrations applied - Bootstrap data loaded successfully - Anonymous user created - The development server starts correctly. Co-authored-by: Tobias O <tobias.olenyi@tum.de> Co-authored-by: Tobias O <tobias.olenyi@envipath.com> Co-authored-by: Liam <62733830+limmooo@users.noreply.github.com> Reviewed-on: enviPath/enviPy#143 Reviewed-by: jebus <lorsbach@envipath.com> Reviewed-by: liambrydon <lbry121@aucklanduni.ac.nz> Co-authored-by: t03i <mail+envipath@t03i.net> Co-committed-by: t03i <mail+envipath@t03i.net>
92 lines
3.5 KiB
Markdown
92 lines
3.5 KiB
Markdown
# enviPy
|
|
|
|
## Local Development Setup
|
|
|
|
These instructions will guide you through setting up the project for local development.
|
|
|
|
### Prerequisites
|
|
|
|
- Python 3.11 or later
|
|
- [uv](https://github.com/astral-sh/uv) - A fast Python package installer and resolver.
|
|
- **Docker and Docker Compose** - Required for running the PostgreSQL database.
|
|
- Git
|
|
|
|
> **Note:** This application requires PostgreSQL, which uses `ArrayField`. Docker is the recommended way to run PostgreSQL locally.
|
|
|
|
### 1. Install Dependencies
|
|
|
|
This project uses `uv` to manage dependencies and `poe-the-poet` for task running. First, [install `uv` if you don't have it yet](https://docs.astral.sh/uv/guides/install-python/).
|
|
|
|
Then, sync the project dependencies. This will create a virtual environment in `.venv` and install all necessary packages, including `poe-the-poet`.
|
|
|
|
```bash
|
|
uv sync --dev
|
|
```
|
|
|
|
> **Note on RDkit:** If you have a different version of rdkit installed globally, the dependency installation may fail. If this happens, please uninstall the global version and run `uv sync` again.
|
|
|
|
### 2. Set Up Environment File
|
|
|
|
Copy the example environment file for local setup:
|
|
|
|
```bash
|
|
cp .env.local.example .env
|
|
```
|
|
|
|
This file contains the necessary environment variables for local development.
|
|
|
|
### 3. Quick Setup with Poe
|
|
|
|
The easiest way to set up the development environment is by using the `poe` task runner, which is executed via `uv run`.
|
|
|
|
```bash
|
|
uv run poe setup
|
|
```
|
|
|
|
This single command will:
|
|
1. Start the PostgreSQL database using Docker Compose.
|
|
2. Run database migrations.
|
|
3. Bootstrap initial data (anonymous user, default packages, models).
|
|
|
|
After setup, start the development server:
|
|
|
|
```bash
|
|
uv run poe dev
|
|
```
|
|
|
|
The application will be available at `http://localhost:8000`.
|
|
|
|
#### Other useful Poe commands:
|
|
|
|
You can list all available commands by running `uv run poe --help`.
|
|
|
|
```bash
|
|
uv run poe db-up # Start PostgreSQL only
|
|
uv run poe db-down # Stop PostgreSQL
|
|
uv run poe migrate # Run migrations only
|
|
uv run poe bootstrap # Bootstrap data only
|
|
uv run poe shell # Open the Django shell
|
|
uv run poe clean # Remove database volumes (WARNING: destroys all data)
|
|
```
|
|
|
|
### Troubleshooting
|
|
|
|
* **Docker Connection Error:** If you see an error like `open //./pipe/dockerDesktopLinuxEngine: The system cannot find the file specified` (on Windows), it likely means your Docker Desktop application is not running. Please start Docker Desktop and try the command again.
|
|
|
|
* **SSH Keys for Git Dependencies:** Some dependencies are installed from private git repositories and require SSH authentication. Ensure your SSH keys are configured correctly for Git.
|
|
* For a general guide, see [GitHub's official documentation](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent).
|
|
* **Windows Users:** If `uv sync` hangs while fetching git dependencies, you may need to explicitly configure Git to use the Windows OpenSSH client and use the `ssh-agent` to manage your key's passphrase.
|
|
|
|
1. **Point Git to the correct SSH executable:**
|
|
```powershell
|
|
git config --global core.sshCommand "C:/Windows/System32/OpenSSH/ssh.exe"
|
|
```
|
|
2. **Enable and use the SSH agent:**
|
|
```powershell
|
|
# Run these commands in an administrator PowerShell
|
|
Get-Service ssh-agent | Set-Service -StartupType Automatic -PassThru | Start-Service
|
|
|
|
# Add your key to the agent. It will prompt for the passphrase once.
|
|
ssh-add
|
|
```
|