Skip to content

Commit

Permalink
Merge pull request #53 from sarayourfriend/try/pip-options.txt
Browse files Browse the repository at this point in the history
Use installer args file for pip options
  • Loading branch information
freakboy3742 authored Nov 19, 2024
2 parents 89f9578 + 487d2ef commit afafeab
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 7 deletions.
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()
],
)

0 comments on commit afafeab

Please sign in to comment.