Skip to content

Commit dd9f387

Browse files
authored
Merge pull request #48 from aeturrell/uv_update_readme_dockerfile
dockerfile working with uv; instructions update
2 parents 3754e80 + c533ada commit dd9f387

File tree

5 files changed

+160
-30
lines changed

5 files changed

+160
-30
lines changed

.dockerignore

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Git
2+
.git
3+
.gitignore
4+
.gitattributes
5+
6+
7+
# CI
8+
.codeclimate.yml
9+
.travis.yml
10+
.taskcluster.yml
11+
12+
# Docker
13+
docker-compose.yml
14+
Dockerfile
15+
.docker
16+
.dockerignore
17+
18+
# Byte-compiled / optimized / DLL files
19+
**/__pycache__/
20+
**/*.py[cod]
21+
22+
# C extensions
23+
*.so
24+
25+
# Distribution / packaging
26+
.Python
27+
env/
28+
build/
29+
develop-eggs/
30+
dist/
31+
downloads/
32+
eggs/
33+
lib/
34+
lib64/
35+
parts/
36+
sdist/
37+
var/
38+
*.egg-info/
39+
.installed.cfg
40+
*.egg
41+
42+
# PyInstaller
43+
# Usually these files are written by a python script from a template
44+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
45+
*.manifest
46+
*.spec
47+
48+
# Installer logs
49+
pip-log.txt
50+
pip-delete-this-directory.txt
51+
52+
# Unit test / coverage reports
53+
htmlcov/
54+
.tox/
55+
.coverage
56+
.cache
57+
nosetests.xml
58+
coverage.xml
59+
60+
# Translations
61+
*.mo
62+
*.pot
63+
64+
# Django stuff:
65+
*.log
66+
67+
# Sphinx documentation
68+
docs/_build/
69+
70+
# PyBuilder
71+
target/
72+
73+
# Virtual environment
74+
.env
75+
.venv/
76+
venv/
77+
78+
# PyCharm
79+
.idea
80+
81+
# Python mode for VIM
82+
.ropeproject
83+
**/.ropeproject
84+
85+
# Vim swap files
86+
**/*.swp
87+
88+
# VS Code
89+
.vscode/

Dockerfile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ WORKDIR /app
88
# Update Linux package list and install some key libraries, including latex
99
RUN apt-get -y update && apt-get install -y openssl graphviz \
1010
nano texlive graphviz-dev \
11-
bash build-essential git
11+
bash build-essential git curl
1212

1313
# change default shell from ash to bash
1414
RUN sed -i -e "s/bin\/ash/bin\/bash/" /etc/passwd
@@ -18,14 +18,16 @@ COPY uv.lock .
1818
COPY pyproject.toml .
1919

2020
# Install uv
21-
COPY --from=ghcr.io/astral-sh/uv:0.5.14 /uv /bin/uv
21+
COPY --from=ghcr.io/astral-sh/uv:0.5.15 /uv /bin/uv
22+
23+
# Copy the current directory contents into the container at /app
24+
COPY . /app
25+
26+
WORKDIR "/app"
2227

2328
# Install everything at once:
24-
RUN uv sync --frozen
29+
RUN uv sync
2530

2631
RUN uv pip list
2732

28-
# Copy the current directory contents into the container at /app
29-
COPY . /app
30-
3133
RUN echo "Success building the Python4DS container!"

README.md

Lines changed: 61 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,94 @@
11
# Python for Data Science
22

3-
## Admin
3+
[![DOI](https://zenodo.org/badge/496994611.svg)](https://zenodo.org/doi/10.5281/zenodo.10518241) ![GitHub Release](https://img.shields.io/github/v/release/aeturrell/python4DS)
44

5-
### Building the Book
5+
This is the repo for **Python for Data Science**.
66

7-
To build the book using Jupyter books use
7+
This README is for developers and contributors. If you're here to read the book, head over to [https://aeturrell.github.io/python4DS](https://aeturrell.github.io/python4DS).
8+
9+
## Contributing
10+
11+
We are very keen to encourage contributors! You can contribute by raising issues with the book or by creating pull requests directly. If you are creating a pull request you will need to install the development environment locally and check the book builds after you've made your changes.
12+
13+
Note that we aim to closely follow the content of [**R for Data Science (2e)**](https://r4ds.hadley.nz/).
14+
15+
Before making a pull request you should test that the pre-commit checks pass, including that there are no outputs included, and that the book builds. See below for instructions on how to do these locally.
16+
17+
When you make a pull request, pre-commit and build will run automatically, and fail if there are errors. They are in `.github/workflows/tests.yml`.
18+
19+
## Installing the development environment locally
20+
21+
You will need installations of Python 3.10 and [**uv**](https://docs.astral.sh/uv/). **uv** can be used to install certain distributions of Python through the `uv python install 3.10` command but you can use other Python installations.
22+
23+
Clone this repository.
24+
25+
To install the development environment, run `uv sync` from the project root. This should create a `.venv/` directory with the Python4DS environment in it. You can check that the environment has been installed by running `uv run python -V` in the project root directory.
26+
27+
## Building the book
28+
29+
The book is compiled from source markdown and Jupyter notebook files [**jupyter-book**](https://jupyterbook.org/en/stable/) package.
30+
31+
To build the book, run
832

933
```bash
10-
jupyter-book build .
34+
uv run jupyter-book build .
1135
```
1236

13-
Once this command is run, you should be able to look at the HTML files for the book locally on your computer.
37+
Once this command is run, you should be able to look at the HTML files for the book locally on your computer. They will be in `_build`. The project is configured to stop the build if any errors are encountered. This is a frequent occurrence! You'll need to look at the logs to work out what might have gone wrong.
38+
39+
## Uploading the book
40+
41+
### Automatic uploads of the book
1442

15-
Note that, due to package conflicts, several pages may not compile when taking this approach. One work around is to manually run troublesome notebooks and, when jupyter-book encounters a problem when executing them to build the book, it will pick up the notebook at the last point it was successfully manually executed. If you do have this problem, it may be that jupyter-book is not picking up the right jupyter kernel. You can look at installed kernels using `jupyter kernelspec list`.
43+
This repo is configured such that new versions automatically build and upload the book to the website. The GitHub Action that does this is in `.github/workflows/release.yml`.
1644

17-
### Uploading Built Files
45+
### Uploading the built book manually
1846

19-
Only upload built files based on a successful commit or merge to the main branch. See [here](https://jupyterbook.org/publish/gh-pages.html) for how to upload revised HTML files, but the key command is
47+
You shouldn't need to upload the book if you are a regular contributor. There are times when you might need to as an admin, but normally the book will be updated automatically upon release of a new version.
48+
49+
See [here](https://jupyterbook.org/publish/gh-pages.html) for how to upload revised HTML files, but the key command is
2050

2151
```bash
22-
ghp-import -n -p -f _build/html
52+
uv run ghp-import -n -p -f _build/html
2353
```
2454

25-
Typically, only maintainers will need to upload built files.
55+
## Code hygiene
2656

27-
### Pre-commit
57+
This book uses pre-commit to strip output from notebooks, lint, format, and check for large files added by mistake.
2858

2959
To perform the pre-commit checks, use
3060

3161
```bash
32-
pre-commit run --all-files
62+
uv run pre-commit run --all-files
3363
```
3464

3565
on your staged files. Ensure pre-commit reports all tests as having passed before committing.
3666

37-
## Running and Developing in the Docker Container
67+
## Publishing a new version
68+
69+
1. Open a new branch with the version name, eg `v1.0.4`
70+
71+
2. Change the version in `pyproject.toml` (you can run `uv run version_bumper.py`, which has script-level dependencies)
3872

39-
There is a dockerfile associated with this project. Pre-reqs
73+
3. Commit the change with a new version label (eg `v1.0.4`) as the commit message
74+
75+
4. Go to GitHub. Assuming the tests pass, merge into main.
76+
77+
5. The book should automatically build in GitHub actions, and be pushed to the website. A new release will also be created automatically. A new Zenodo entry is also automatically created.
78+
79+
## Running and developing in a Docker container
80+
81+
There is a Dockerfile associated with this project. Pre-reqs
4082
To use it:
4183

42-
1. Pre-reqs: docker installed, VS Code installed, VS Code docker and remote explorer extensions installed.
43-
2. Build the image from the file. Right click on the file in VS Code and select build
44-
3. On the Docker tab of VS Code, right-click on the image and select 'Run Interactive'
45-
4. On the remote explorer tab of VS Code, find the running dev container and select 'attach new window'. This will start up a new VS Code window in the running container
46-
5. Within the new VS Code window, open the folder ("app/")
47-
6. Do any development as required (see the instructions above)
84+
1. Pre-reqs: docker installed, VS Code installed, VS Code docker and Remote Explorer extensions installed.
85+
2. Build the image from the file. Right click on the file in VS Code and select "Build Image".
86+
3. On the Docker tab of VS Code, right-click on the `python4DS:latest` image and select 'Run Interactive'.
87+
4. On the Docker tab again, right-click on the running `python4DS:latest` container and click "Attach Visual Studio Code".
88+
5. Do any development as required (see the instructions above)
4889

4990
If you wish to copy any files (eg the built HTML files) back to your local machine to check them, use
5091

5192
```bash
5293
docker cp CONTAINER:app/_build/html/ temp_dir/
5394
```
54-
55-
Note that seaborn is currently using a pre-release version so this is installed directly in the dockerfile.

_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
title: Python for Data Science
55
author: The Py4DS Community
66
logo: logo.png
7-
exclude_patterns: [_build, Thumbs.db, .DS_Store, "**.ipynb_checkpoints", ".venv"]
7+
exclude_patterns: [_build, Thumbs.db, .DS_Store, "**.ipynb_checkpoints", ".venv", "README.md"]
88
# Force re-execution of notebooks on each build.
99
# See https://jupyterbook.org/content/execute.html
1010
execute:

welcome.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ To begin your data science journey, head to the next page.
1010

1111
## Contributors to Python4DS
1212

13-
Contributing is very much encouraged. If you're looking for content to implement or tweak, we aim to broadly follow the structure and content of **R for Data Science (2e)** and you can find open [issues here](https://github.com/aeturrell/python4DS/issues). For larger contributions of content, it's probably best to check with other contributors first.
13+
Contributing is very much encouraged. If you're looking for content to implement or tweak, we aim to follow the structure and content of **R for Data Science (2e)** and you can find open [issues here](https://github.com/aeturrell/python4DS/issues). For larger contributions of content, it's probably best to check with other contributors first.
1414

1515
We thank the following contributors:
1616

0 commit comments

Comments
 (0)