Skip to content

Commit 926a17e

Browse files
Add local dev environment setup (#331)
* Add local dev environment setup options Add support for uv and pip installation methods as alternatives to Conda/Docker. Update pyproject.toml with proper project metadata and structured development dependencies. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update README.md * Ignore UP038 rule in Ruff linter configuration The rule is deprecated, but somewhat enforced in Python >=3.10 * Remove tutorial tests from docker build triggers * Remove unneeded per-file ignore * Update IPython auto-imports for modern typing practices --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent a04aa30 commit 926a17e

File tree

5 files changed

+93
-3
lines changed

5 files changed

+93
-3
lines changed

.github/workflows/docker-build.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ on:
1010
- "docker/**"
1111
- "binder/**"
1212
- "**/environment.yml"
13-
- "tutorial/tests/testsuite/**"
1413
- ".github/workflows/docker-build.yml"
1514
tags:
1615
- "v*.*"
@@ -21,7 +20,6 @@ on:
2120
- "docker/**"
2221
- "binder/**"
2322
- "**/environment.yml"
24-
- "tutorial/tests/testsuite/**"
2523
- ".github/workflows/docker-build.yml"
2624
workflow_dispatch:
2725

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ target/
8080
# IPython
8181
profile_default/
8282

83+
# uv
84+
uv.lock
85+
8386
# pyenv
8487
.python-version
8588

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,56 @@ You can now use the Jupyter in the Docker container to run the python-tutorial.
127127
> [!NOTE]
128128
>
129129
> If you want to restart the container, you can simply run the command `docker container start python_tutorial`.
130+
131+
## Setup a local dev environment
132+
133+
If you prefer not to use Conda and/or Docker, you can set up a *lightweight* development environment using either "uv" (a faster alternative to pip) or traditional "pip". Both methods will install the development dependencies specified in the `pyproject.toml` file.
134+
135+
Both setups assume that you have already cloned the repository with `git clone https://github.com/empa-scientific-it/python-tutorial`. The commands below should be run from inside the tutorial directory.
136+
137+
### Using `uv` (Recommended for speed)
138+
139+
[uv](https://github.com/astral-sh/uv) is a fast, Python package installer and resolver written in Rust.
140+
141+
1. Install uv via `pip` or [any other method](https://docs.astral.sh/uv/getting-started/installation/):
142+
```console
143+
pip install uv
144+
```
145+
146+
2. Create a virtual environment and install dev dependencies:
147+
```console
148+
# Create and activate a virtual environment
149+
uv venv
150+
# On Windows
151+
.venv\Scripts\activate
152+
# On macOS/Linux
153+
source .venv/bin/activate
154+
155+
# Install dev dependencies
156+
uv pip install -e ".[dev]"
157+
```
158+
159+
3. Launch JupyterLab:
160+
```console
161+
jupyter lab
162+
```
163+
164+
### Using `pip`
165+
166+
1. Create a virtual environment and install dev dependencies:
167+
```console
168+
# Create and activate a virtual environment
169+
python -m venv .venv
170+
# On Windows
171+
.venv\Scripts\activate
172+
# On macOS/Linux
173+
source .venv/bin/activate
174+
175+
# Install dev dependencies
176+
pip install -e ".[dev]"
177+
```
178+
179+
2. Launch JupyterLab:
180+
```console
181+
jupyter lab
182+
```

docker/ipython_config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66

77
# Automatically import some modules
88
c.InteractiveShellApp.exec_lines = [
9-
"from typing import Any, Callable, Dict, List, Optional, Tuple, Union"
9+
"from typing import Any, ClassVar",
10+
"from collections.abc import List, Tuple, Callable, Dict",
1011
]

pyproject.toml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,38 @@
11
[project]
22
name = "python-tutorial"
3+
version = "v2025.05"
4+
description = "Jupyter-based Python programming tutorial"
35
requires-python = ">=3.10"
46

7+
[project.optional-dependencies]
8+
dev = [
9+
"numpy",
10+
"matplotlib",
11+
"pandas",
12+
"ipywidgets",
13+
"ipynbname",
14+
"jupyterlab",
15+
"pytest",
16+
"pytest-timeout",
17+
"markdown",
18+
"pre-commit",
19+
"geostatspy",
20+
"gstools",
21+
"scikit-learn",
22+
"attrs",
23+
"multiprocess",
24+
"openai",
25+
"tenacity",
26+
"markdown2",
27+
"python-dotenv",
28+
"pillow",
29+
"opencv-python",
30+
"albumentations",
31+
"grad-cam",
32+
"plotly",
33+
"torch==2.7.0", # pinned to last stable version as of 2025-05-14
34+
]
35+
536
# pytest
637
[tool.pytest.ini_options]
738
addopts = "-v --tb=short"
@@ -58,3 +89,7 @@ select = [
5889
[tool.ruff.format]
5990
quote-style = "double"
6091
indent-style = "space"
92+
93+
# Setuptools: suppress package discovery
94+
[tool.setuptools]
95+
packages = []

0 commit comments

Comments
 (0)