Skip to content

Commit 5aa193c

Browse files
authored
Merge pull request #18 from pimoroni/dev
Defer to .txt files for requirements.
2 parents b936c5c + 5628cd3 commit 5aa193c

File tree

11 files changed

+83
-19
lines changed

11 files changed

+83
-19
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ on:
88

99
jobs:
1010
test:
11-
name: Python ${{ matrix.python }}
11+
name: Build (Python ${{ matrix.python }})
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
1515
python: ['3.9', '3.10', '3.11']
1616

1717
env:
18+
TERM: xterm-256color
1819
RELEASE_FILE: ${{ github.event.repository.name }}-${{ github.event.release.tag_name || github.sha }}-py${{ matrix.python }}
1920

2021
steps:

.github/workflows/install.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Install Test
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
test:
11+
name: Install (Python ${{ matrix.python }})
12+
runs-on: ubuntu-latest
13+
env:
14+
TERM: xterm-256color
15+
strategy:
16+
matrix:
17+
python: ['3.9', '3.10', '3.11']
18+
19+
steps:
20+
- name: Checkout Code
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Python ${{ matrix.python }}
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: ${{ matrix.python }}
27+
28+
- name: Stub files & Patch install.sh
29+
run: |
30+
mkdir -p boot/firmware
31+
touch boot/firmware/config.txt
32+
sed -i "s|/boot/firmware|`pwd`/boot/firmware|g" install.sh
33+
sed -i "s|sudo raspi-config|raspi-config|g" pyproject.toml
34+
touch raspi-config
35+
chmod +x raspi-config
36+
echo `pwd` >> $GITHUB_PATH
37+
38+
- name: Run install.sh
39+
run: |
40+
./install.sh --unstable --force

.github/workflows/qa.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
jobs:
1010
test:
11-
name: linting & spelling
11+
name: Linting & Spelling
1212
runs-on: ubuntu-latest
1313
env:
1414
TERM: xterm-256color

.github/workflows/test.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ on:
88

99
jobs:
1010
test:
11-
name: Python ${{ matrix.python }}
11+
name: Test (Python ${{ matrix.python }})
1212
runs-on: ubuntu-latest
13+
env:
14+
TERM: xterm-256color
1315
strategy:
1416
matrix:
1517
python: ['3.9', '3.10', '3.11']
1618

1719
steps:
1820
- name: Checkout Code
19-
uses: actions/checkout@v3
21+
uses: actions/checkout@v4
2022

2123
- name: Set up Python ${{ matrix.python }}
2224
uses: actions/setup-python@v5

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,5 @@ You can optionally run `sudo raspi-config` or the graphical Raspberry Pi Configu
6666
Some of the examples have additional dependencies. You can install them with:
6767

6868
```bash
69-
pip install
70-
```
69+
pip install -r requirements-examples.txt
70+
```

boilerplate.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ Press Ctrl+C to exit.
9595
""")
9696
```
9797

98+
If your examples need additional dependencies, then list them in:
99+
100+
```
101+
requirements-examples.txt
102+
```
103+
104+
Otherwise, just delete this file to avoid unnecessarily prompting the user.
105+
98106
## Install / Uninstall Scripts
99107

100108
If your package directory (`PROJECT_NAME/`) differs from your library name, you should update `install.sh` and `uninstall.sh` and hard-code the correct library name.

install.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,12 @@ function pip_pkg_install {
166166
check_for_error
167167
}
168168

169+
function pip_requirements_install {
170+
# A null Keyring prevents pip stalling in the background
171+
PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring $PYTHON -m pip install -r "$@"
172+
check_for_error
173+
}
174+
169175
while [[ $# -gt 0 ]]; do
170176
K="$1"
171177
case $K in
@@ -335,6 +341,15 @@ fi
335341

336342
printf "\n"
337343

344+
if [ -f "requirements-examples.txt" ]; then
345+
if confirm "Would you like to install example dependencies?"; then
346+
inform "Installing dependencies from requirements-examples.txt..."
347+
pip_requirements_install requirements-examples.txt
348+
fi
349+
fi
350+
351+
printf "\n"
352+
338353
# Use pdoc to generate basic documentation from the installed module
339354

340355
if confirm "Would you like to generate documentation?"; then

pyproject.toml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[build-system]
2-
requires = ["hatchling", "hatch-fancy-pypi-readme"]
2+
requires = ["hatchling", "hatch-fancy-pypi-readme", "hatch-requirements-txt"]
33
build-backend = "hatchling.build"
44

55
[project]
66
name = "PROJECT_NAME"
7-
dynamic = ["version", "readme"]
7+
dynamic = ["version", "readme", "optional-dependencies"]
88
description = "__DESCRIPTION__"
99
license = {file = "LICENSE"}
1010
requires-python = ">= 3.7"
@@ -36,6 +36,9 @@ classifiers = [
3636
]
3737
dependencies = []
3838

39+
[tool.hatch.metadata.hooks.requirements_txt.optional-dependencies]
40+
example-depends = ["requirements-examples.txt"]
41+
3942
[project.urls]
4043
GitHub = "https://www.github.com/pimoroni/PROJECT_NAME-python"
4144
Homepage = "https://www.pimoroni.com"
@@ -48,7 +51,8 @@ include = [
4851
"PROJECT_NAME",
4952
"README.md",
5053
"CHANGELOG.md",
51-
"LICENSE"
54+
"LICENSE",
55+
"requirements-examples.txt"
5256
]
5357

5458
[tool.hatch.build.targets.sdist]
@@ -108,6 +112,6 @@ ignore = [
108112
]
109113

110114
[tool.pimoroni]
111-
apt_packages = ["git"]
115+
apt_packages = []
112116
configtxt = []
113-
commands = ["false"]
117+
commands = []

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ isort
55
twine
66
hatch
77
hatch-fancy-pypi-readme
8+
hatch-requirements-txt
89
tox
910
pdoc

requirements-examples.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)