Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ on:
- "docker/**"
- "binder/**"
- "**/environment.yml"
- "tutorial/tests/testsuite/**"
- ".github/workflows/docker-build.yml"
tags:
- "v*.*"
Expand All @@ -21,7 +20,6 @@ on:
- "docker/**"
- "binder/**"
- "**/environment.yml"
- "tutorial/tests/testsuite/**"
- ".github/workflows/docker-build.yml"
workflow_dispatch:

Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ target/
# IPython
profile_default/

# uv
uv.lock

# pyenv
.python-version

Expand Down
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,56 @@ You can now use the Jupyter in the Docker container to run the python-tutorial.
> [!NOTE]
>
> If you want to restart the container, you can simply run the command `docker container start python_tutorial`.

## Setup a local dev environment

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.

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.

### Using `uv` (Recommended for speed)

[uv](https://github.com/astral-sh/uv) is a fast, Python package installer and resolver written in Rust.

1. Install uv via `pip` or [any other method](https://docs.astral.sh/uv/getting-started/installation/):
```console
pip install uv
```

2. Create a virtual environment and install dev dependencies:
```console
# Create and activate a virtual environment
uv venv
# On Windows
.venv\Scripts\activate
# On macOS/Linux
source .venv/bin/activate

# Install dev dependencies
uv pip install -e ".[dev]"
```

3. Launch JupyterLab:
```console
jupyter lab
```

### Using `pip`

1. Create a virtual environment and install dev dependencies:
```console
# Create and activate a virtual environment
python -m venv .venv
# On Windows
.venv\Scripts\activate
# On macOS/Linux
source .venv/bin/activate

# Install dev dependencies
pip install -e ".[dev]"
```

2. Launch JupyterLab:
```console
jupyter lab
```
3 changes: 2 additions & 1 deletion docker/ipython_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@

# Automatically import some modules
c.InteractiveShellApp.exec_lines = [
"from typing import Any, Callable, Dict, List, Optional, Tuple, Union"
"from typing import Any, ClassVar",
"from collections.abc import List, Tuple, Callable, Dict",
]
35 changes: 35 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,38 @@
[project]
name = "python-tutorial"
version = "v2025.05"
description = "Jupyter-based Python programming tutorial"
requires-python = ">=3.10"

[project.optional-dependencies]
dev = [
"numpy",
"matplotlib",
"pandas",
"ipywidgets",
"ipynbname",
"jupyterlab",
"pytest",
"pytest-timeout",
"markdown",
"pre-commit",
"geostatspy",
"gstools",
"scikit-learn",
"attrs",
"multiprocess",
"openai",
"tenacity",
"markdown2",
"python-dotenv",
"pillow",
"opencv-python",
"albumentations",
"grad-cam",
"plotly",
"torch==2.7.0", # pinned to last stable version as of 2025-05-14
]

# pytest
[tool.pytest.ini_options]
addopts = "-v --tb=short"
Expand Down Expand Up @@ -58,3 +89,7 @@ select = [
[tool.ruff.format]
quote-style = "double"
indent-style = "space"

# Setuptools: suppress package discovery
[tool.setuptools]
packages = []