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

Use installer args file for pip options #53

Merged
merged 4 commits into from
Nov 19, 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
1 change: 1 addition & 0 deletions {{ cookiecutter.format }}/briefcase.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ target_version = "0.3.20"
[paths]
app_path = "src/app"
app_requirements_path = "requirements.txt"
app_requirement_installer_args_path = "pip-options.txt"
support_path = "support"
{{ {
"3.9": 'support_revision = "3.9.20+20241016"',
Expand Down
5 changes: 0 additions & 5 deletions {{ cookiecutter.format }}/install_requirements.sh

This file was deleted.

6 changes: 4 additions & 2 deletions {{ cookiecutter.format }}/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,14 @@ modules:
# command line compatible, and the output objects are compatible,
# so we can override the CC build environment variable to force the
# use of gcc.
- env CC="gcc -pthread" INSTALL_TARGET="/app/briefcase/app_packages" sh ./install_requirements.sh
- CC="gcc -pthread" /app/bin/python3 pip_install.py
sources:
- type: file
path: requirements.txt
- type: file
path: install_requirements.sh
path: pip-options.txt
- type: file
path: pip_install.py
- name: app
buildsystem: simple
build-options:
Expand Down
Empty file.
33 changes: 33 additions & 0 deletions {{ cookiecutter.format }}/pip_install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from pathlib import Path
import os
import sys

# Run pip install with default arguments + options read from the app requirement
# installer args path.
# execv is simpler than subprocess, as it avoids needing to manage the subprocess
# or pipe in/out, which would add a lot of unnecessary complexity for no value.
# This script only helps build the command, it does not need to check the output at all.

os.execv(
sys.executable,
[
sys.executable,
"-m",
"pip",
"install",
"--no-cache-dir",
"-r",
"requirements.txt",
"--target",
"/app/briefcase/app_packages",
]
+ [
arg
for arg in (Path(__file__).parent / "pip-options.txt")
.read_text()
.split("\n")
# skip empty lines, including trailing newlines or empty default file
# (which contains a single newline character)
if arg and not arg.isspace()
],
)