Skip to content

Commit 10904d2

Browse files
authored
Merge pull request #57 from aeturrell/quarto-uv
Switch to quarto; panache for quarto formatting
2 parents 35ad2d6 + 57a2721 commit 10904d2

49 files changed

Lines changed: 1528 additions & 2528 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/release.yml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,19 @@ jobs:
1919
with:
2020
fetch-depth: 2
2121

22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v4
24+
2225
- name: Set up Python
23-
uses: actions/setup-python@v5.3.0
24-
with:
25-
python-version: "3.10"
26+
run: uv python install
2627

27-
- name: Install uv
28-
uses: astral-sh/setup-uv@v5
28+
- name: Install dependencies
29+
run: uv sync --all-extras --dev
30+
31+
- name: Install Quarto
32+
uses: quarto-dev/quarto-actions/setup@v2
2933
with:
30-
# Install a specific version of uv.
31-
version: "0.5.15"
34+
version: "1.5.57"
3235

3336
- name: Check if there is a parent commit
3437
id: check-parent-commit
@@ -63,16 +66,16 @@ jobs:
6366
run: |
6467
sudo apt-get -y install openssl graphviz nano texlive graphviz-dev unzip build-essential
6568
66-
- name: Install dependencies
69+
- name: build the book
6770
run: |
68-
uv sync
69-
70-
- name: Build book
71-
run: uv run jupyter-book build . --verbose
71+
uv run quarto render --execute
72+
env:
73+
# This forces Quarto to use the Python inside your uv venv
74+
QUARTO_PYTHON: ${{ github.workspace }}/.venv/bin/python
7275

7376
- name: Publish
7477
if: steps.check-version.outputs.tag
75-
run: uv run ghp-import -n -p -f _build/html
78+
run: uv run quarto publish gh-pages --no-render --no-browser
7679

7780
- name: Publish the release notes
7881
uses: release-drafter/release-drafter@v6.0.0

.github/workflows/tests.yml

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
name: tests
22

33
on:
4-
- pull_request
5-
- push
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
concurrency:
9+
group: tests-${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
611

712
jobs:
813
pre-commit:
@@ -22,16 +27,19 @@ jobs:
2227
with:
2328
fetch-depth: 2
2429

25-
- name: Set up Python
26-
uses: actions/setup-python@v5.3.0
27-
with:
28-
python-version: "3.10"
29-
3030
- name: Install uv
31-
uses: astral-sh/setup-uv@v5
31+
uses: astral-sh/setup-uv@v4
32+
33+
- name: Set up Python
34+
run: uv python install
35+
36+
- name: Install dependencies
37+
run: uv sync --all-extras --dev
38+
39+
- name: Install Quarto
40+
uses: quarto-dev/quarto-actions/setup@v2
3241
with:
33-
# Install a specific version of uv.
34-
version: "0.5.2"
42+
version: "1.5.57"
3543

3644
- name: set timezone
3745
run: |
@@ -42,13 +50,9 @@ jobs:
4250
run: |
4351
sudo apt-get -y install openssl graphviz nano texlive graphviz-dev unzip build-essential
4452
45-
- name: Install dependencies
46-
run: |
47-
uv sync
48-
4953
- name: build the book
5054
run: |
51-
uv run jupyter-book build . --verbose
55+
uv run quarto render --execute
5256
5357
- name: success
5458
run: |

.gitignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Mac
22
.DS_Store
33

4-
# jupyterbook
5-
_build/**
4+
# quarto
5+
_book/
6+
/.quarto/
7+
**/*.quarto_ipynb
8+
_freeze/
9+
.panache*
610

711
# Byte-compiled / optimized / DLL files
812
__pycache__/

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@ repos:
2828
# Run the formatter.
2929
- id: ruff-format
3030
types_or: [python, pyi, jupyter]
31+
- repo: https://github.com/jolars/panache
32+
rev: v2.32.0 # Use the latest release version
33+
hooks:
34+
- id: panache-format

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,23 @@ When you make a pull request, pre-commit and build will run automatically, and f
1818

1919
## Installing the development environment locally
2020

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.
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.12` command but you can use other Python installations.
2222

2323
Clone this repository.
2424

2525
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.
2626

2727
## Building the book
2828

29-
The book is compiled from source markdown and Jupyter notebook files [**jupyter-book**](https://jupyterbook.org/en/stable/) package.
29+
The book is compiled from source markdown and Jupyter notebook files using [**Quarto**](https://quarto.org/). You will need Quarto installed on your system — see the [Quarto installation guide](https://quarto.org/docs/get-started/).
3030

3131
To build the book, run
3232

3333
```bash
34-
uv run jupyter-book build .
34+
uv run quarto render --execute
3535
```
3636

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.
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 `_book`. The `freeze: auto` setting means only notebooks whose source has changed will be re-executed on subsequent builds.
3838

3939
## Uploading the book
4040

@@ -46,10 +46,10 @@ This repo is configured such that new versions automatically build and upload th
4646

4747
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.
4848

49-
See [here](https://jupyterbook.org/publish/gh-pages.html) for how to upload revised HTML files, but the key command is
49+
First build the book, then publish with:
5050

5151
```bash
52-
uv run ghp-import -n -p -f _build/html
52+
uv run quarto publish gh-pages --no-render --no-browser
5353
```
5454

5555
## Code hygiene
@@ -78,7 +78,7 @@ on your staged files. Ensure pre-commit reports all tests as having passed befor
7878

7979
## Running and developing in a Docker container
8080

81-
There is a Dockerfile associated with this project. Pre-reqs
81+
There is a Dockerfile associated with this project.
8282
To use it:
8383

8484
1. Pre-reqs: docker installed, VS Code installed, VS Code docker and Remote Explorer extensions installed.
@@ -90,5 +90,5 @@ There is a Dockerfile associated with this project. Pre-reqs
9090
If you wish to copy any files (eg the built HTML files) back to your local machine to check them, use
9191

9292
```bash
93-
docker cp CONTAINER:app/_build/html/ temp_dir/
93+
docker cp CONTAINER:app/_book/ temp_dir/
9494
```

_config.yml

Lines changed: 0 additions & 53 deletions
This file was deleted.

_quarto.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
project:
2+
type: book
3+
output-dir: _book
4+
5+
book:
6+
title: "Python for Data Science"
7+
author: "The Py4DS Community"
8+
favicon: favicon.ico
9+
cover-image: logo.png
10+
repo-url: https://github.com/aeturrell/python4DS
11+
repo-branch: main
12+
repo-actions: [edit, issue]
13+
google-analytics: "G-LXJC37BJVX"
14+
sidebar:
15+
style: docked
16+
collapse-level: 1
17+
chapters:
18+
- index.md
19+
- part: "Introduction"
20+
chapters:
21+
- introduction.ipynb
22+
- prerequisites.ipynb
23+
- part: "Quick Start"
24+
chapters:
25+
- whole-game.ipynb
26+
- data-visualise.ipynb
27+
- workflow-basics.ipynb
28+
- data-transform.ipynb
29+
- workflow-style.ipynb
30+
- data-tidy.ipynb
31+
- workflow-writing-code.ipynb
32+
- data-import.ipynb
33+
- workflow-packages-and-environments.qmd
34+
- workflow-help.qmd
35+
- part: "Visualise"
36+
chapters:
37+
- visualise.qmd
38+
- vis-layers.ipynb
39+
- exploratory-data-analysis.ipynb
40+
- communicate-plots.ipynb
41+
- part: "Transform"
42+
chapters:
43+
- boolean-data.ipynb
44+
- numbers.ipynb
45+
- strings.ipynb
46+
- regex.ipynb
47+
- categorical-data.ipynb
48+
- dates-and-times.ipynb
49+
- missing-values.ipynb
50+
- joins.ipynb
51+
- part: "Import"
52+
chapters:
53+
- spreadsheets.ipynb
54+
- databases.ipynb
55+
- rectangling.ipynb
56+
- webscraping-and-apis.ipynb
57+
- part: "Programme"
58+
chapters:
59+
- functions.ipynb
60+
- iteration.ipynb
61+
- command-line.md
62+
- part: "Communicate"
63+
chapters:
64+
- markdown.md
65+
- quarto.qmd
66+
appendices:
67+
- references.md
68+
69+
bibliography: references.bib
70+
search: true
71+
twitter-card: true
72+
73+
format:
74+
html:
75+
theme:
76+
light: flatly
77+
dark: superhero
78+
toc: true
79+
toc-depth: 3
80+
toc-expand: false
81+
html-math-method: katex
82+
code-copy: true
83+
code-link: true
84+
code-overflow: wrap
85+
number-sections: false
86+
include-in-header:
87+
- text: |
88+
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>
89+
90+
execute:
91+
freeze: auto
92+
error: false
93+
94+
jupyter: python3

0 commit comments

Comments
 (0)