Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defer to .txt files for requirements. #18

Merged
merged 8 commits into from
Oct 1, 2024
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
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ on:

jobs:
test:
name: Python ${{ matrix.python }}
name: Build (Python ${{ matrix.python }})
runs-on: ubuntu-latest
strategy:
matrix:
python: ['3.9', '3.10', '3.11']

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

steps:
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Install Test

on:
pull_request:
push:
branches:
- main

jobs:
test:
name: Install (Python ${{ matrix.python }})
runs-on: ubuntu-latest
env:
TERM: xterm-256color
strategy:
matrix:
python: ['3.9', '3.10', '3.11']

steps:
- name: Checkout Code
uses: actions/checkout@v4

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

- name: Stub files & Patch install.sh
run: |
mkdir -p boot/firmware
touch boot/firmware/config.txt
sed -i "s|/boot/firmware|`pwd`/boot/firmware|g" install.sh
sed -i "s|sudo raspi-config|raspi-config|g" pyproject.toml
touch raspi-config
chmod +x raspi-config
echo `pwd` >> $GITHUB_PATH

- name: Run install.sh
run: |
./install.sh --unstable --force
2 changes: 1 addition & 1 deletion .github/workflows/qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
test:
name: linting & spelling
name: Linting & Spelling
runs-on: ubuntu-latest
env:
TERM: xterm-256color
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ on:

jobs:
test:
name: Python ${{ matrix.python }}
name: Test (Python ${{ matrix.python }})
runs-on: ubuntu-latest
env:
TERM: xterm-256color
strategy:
matrix:
python: ['3.9', '3.10', '3.11']

steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ You can optionally run `sudo raspi-config` or the graphical Raspberry Pi Configu
Some of the examples have additional dependencies. You can install them with:

```bash
pip install
```
pip install -r requirements-examples.txt
```
8 changes: 8 additions & 0 deletions boilerplate.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ Press Ctrl+C to exit.
""")
```

If your examples need additional dependencies, then list them in:

```
requirements-examples.txt
```

Otherwise, just delete this file to avoid unnecessarily prompting the user.

## Install / Uninstall Scripts

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.
Expand Down
15 changes: 15 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ function pip_pkg_install {
check_for_error
}

function pip_requirements_install {
# A null Keyring prevents pip stalling in the background
PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring $PYTHON -m pip install -r "$@"
check_for_error
}

while [[ $# -gt 0 ]]; do
K="$1"
case $K in
Expand Down Expand Up @@ -335,6 +341,15 @@ fi

printf "\n"

if [ -f "requirements-examples.txt" ]; then
if confirm "Would you like to install example dependencies?"; then
inform "Installing dependencies from requirements-examples.txt..."
pip_requirements_install requirements-examples.txt
fi
fi

printf "\n"

# Use pdoc to generate basic documentation from the installed module

if confirm "Would you like to generate documentation?"; then
Expand Down
14 changes: 9 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[build-system]
requires = ["hatchling", "hatch-fancy-pypi-readme"]
requires = ["hatchling", "hatch-fancy-pypi-readme", "hatch-requirements-txt"]
build-backend = "hatchling.build"

[project]
name = "PROJECT_NAME"
dynamic = ["version", "readme"]
dynamic = ["version", "readme", "optional-dependencies"]
description = "__DESCRIPTION__"
license = {file = "LICENSE"}
requires-python = ">= 3.7"
Expand Down Expand Up @@ -36,6 +36,9 @@ classifiers = [
]
dependencies = []

[tool.hatch.metadata.hooks.requirements_txt.optional-dependencies]
example-depends = ["requirements-examples.txt"]

[project.urls]
GitHub = "https://www.github.com/pimoroni/PROJECT_NAME-python"
Homepage = "https://www.pimoroni.com"
Expand All @@ -48,7 +51,8 @@ include = [
"PROJECT_NAME",
"README.md",
"CHANGELOG.md",
"LICENSE"
"LICENSE",
"requirements-examples.txt"
]

[tool.hatch.build.targets.sdist]
Expand Down Expand Up @@ -108,6 +112,6 @@ ignore = [
]

[tool.pimoroni]
apt_packages = ["git"]
apt_packages = []
configtxt = []
commands = ["false"]
commands = []
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ isort
twine
hatch
hatch-fancy-pypi-readme
hatch-requirements-txt
tox
pdoc
Empty file added requirements-examples.txt
Empty file.
9 changes: 1 addition & 8 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,5 @@ commands =
ruff check .
codespell .
deps =
check-manifest
ruff
codespell
isort
twine
build
hatch
hatch-fancy-pypi-readme
-r{toxinidir}/requirements-dev.txt