Skip to content

Commit 0f8f78c

Browse files
committed
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.
1 parent 5ca8d8d commit 0f8f78c

3 files changed

Lines changed: 121 additions & 23 deletions

File tree

.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: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,62 @@ 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+
### Using `uv` (Recommended for speed)
136+
137+
[uv](https://github.com/astral-sh/uv) is a fast, Python package installer and resolver written in Rust.
138+
139+
1. Install uv via `pip` or any other method:
140+
```console
141+
pip install uv
142+
```
143+
144+
2. Create a virtual environment and install dev dependencies:
145+
```console
146+
# Clone the repository if you haven't already
147+
git clone https://github.com/empa-scientific-it/python-tutorial
148+
cd python-tutorial
149+
150+
# Create and activate a virtual environment
151+
uv venv
152+
# On Windows
153+
.venv\Scripts\activate
154+
# On macOS/Linux
155+
source .venv/bin/activate
156+
157+
# Install dev dependencies
158+
uv pip install -e ".[dev]"
159+
```
160+
161+
3. Launch JupyterLab:
162+
```console
163+
jupyter lab
164+
```
165+
166+
### Using `pip`
167+
168+
1. Create a virtual environment and install dev dependencies:
169+
```console
170+
# Clone the repository if you haven't already
171+
git clone https://github.com/empa-scientific-it/python-tutorial
172+
cd python-tutorial
173+
174+
# Create and activate a virtual environment
175+
python -m venv .venv
176+
# On Windows
177+
.venv\Scripts\activate
178+
# On macOS/Linux
179+
source .venv/bin/activate
180+
181+
# Install dev dependencies
182+
pip install -e ".[dev]"
183+
```
184+
185+
2. Launch JupyterLab:
186+
```console
187+
jupyter lab
188+
```

pyproject.toml

Lines changed: 59 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,57 @@
1+
[project]
2+
name = "python-tutorial"
3+
version = "v2025.05"
4+
description = "Jupyter-based Python programming tutorial"
5+
requires-python = ">=3.10"
6+
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+
36+
# pytest
37+
[tool.pytest.ini_options]
38+
addopts = "-v --tb=short"
39+
40+
# Ruff
141
[tool.ruff]
242
# Line length (Black default)
343
line-length = 88
4-
544
# Python target version
6-
target-version = "py38"
45+
target-version = "py310"
746

847
# Ignored rules for the entire project
948
[tool.ruff.lint]
1049
ignore = [
11-
"E501", # Line too long
12-
"E203", # Whitespace before ':'
13-
# "TRY301", # Raise within try block (this is actually a good practice)
14-
# "W503" # Line break before binary operator (not PEP8 enforced, so not implemented in Ruff)
50+
"E501", # Line too long
51+
"E203", # Whitespace before ':'
52+
# "TRY301", # Raise within try block (this is actually a good practice)
53+
# "W503" # Line break before binary operator (not PEP8 enforced, so not implemented in Ruff)
1554
]
16-
1755
# flake8 plugins to enable:
1856
# - flake8-bugbear B
1957
# - flake8-builtins A
@@ -24,31 +62,29 @@ ignore = [
2462
# - pyflakes F
2563
# - tryceratops TRY
2664
select = [
27-
"A", # flake8-builtins
28-
"B", # flake8-bugbear
29-
"C4", # flake8-comprehensions
30-
"T10", # flake8-debugger
31-
"G", # flake8-logging-format
32-
"N", # pep8-naming
33-
"F", # pyflakes
34-
"TRY", # tryceratops
35-
"I", # isort
36-
"E", # pycodestyle errors
37-
"UP", # pyupgrade
65+
"A", # flake8-builtins
66+
"B", # flake8-bugbear
67+
"C4", # flake8-comprehensions
68+
"T10", # flake8-debugger
69+
"G", # flake8-logging-format
70+
"N", # pep8-naming
71+
"F", # pyflakes
72+
"TRY", # tryceratops
73+
"I", # isort
74+
"E", # pycodestyle errors
75+
"UP", # pyupgrade
3876
]
3977

4078
# Per-file rule ignores
4179
[tool.ruff.lint.per-file-ignores]
4280
# Trailing whitespace in comment
4381
"binder/ipython_config.py" = ["E266"]
44-
4582
# suppress `raise ... from err`
4683
# Why we ignore B904 from the object-oriented tests?
4784
# We do want to raise an assertion error if the check on the solution function attributes fails,
4885
# but Python by default will raise a TypeError via vars(solution_result)
4986
# if the result is not a class and therefore doesn't have a __dict__ attribute.
5087
"tutorial/tests/test_object_oriented_programming.py" = ["B904"]
51-
5288
# Ignore invalid names like `import torch.nn.functional as F`
5389
"25_library_pytorch_language_modeling.ipynb" = ["N812"]
5490

@@ -57,6 +93,6 @@ select = [
5793
quote-style = "double"
5894
indent-style = "space"
5995

60-
# pytest
61-
[tool.pytest.ini_options]
62-
addopts = "-v --tb=short"
96+
# Setuptools: suppress package discovery
97+
[tool.setuptools]
98+
packages = []

0 commit comments

Comments
 (0)