feat: Enhance Python environment detection in build scripts and improve project root resolution in PyInstaller spec
Some checks are pending
Tests & Quality Checks / Test on Python 3.11 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.12 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.11-1 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.12-1 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.10 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.11-2 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.12-2 (push) Waiting to run
Tests & Quality Checks / Build Artifacts (push) Blocked by required conditions
Tests & Quality Checks / Build Artifacts-1 (push) Blocked by required conditions
Some checks are pending
Tests & Quality Checks / Test on Python 3.11 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.12 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.11-1 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.12-1 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.10 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.11-2 (push) Waiting to run
Tests & Quality Checks / Test on Python 3.12-2 (push) Waiting to run
Tests & Quality Checks / Build Artifacts (push) Blocked by required conditions
Tests & Quality Checks / Build Artifacts-1 (push) Blocked by required conditions
This commit is contained in:
parent
93316c7e2f
commit
a539b91762
2 changed files with 40 additions and 7 deletions
|
|
@ -35,6 +35,7 @@ APP_NAME="WebDropBridge"
|
|||
DMG_VOLUME_NAME="WebDrop Bridge"
|
||||
BUNDLE_IDENTIFIER="de.him_tools.webdrop-bridge"
|
||||
VERSION=""
|
||||
PYTHON_BIN=""
|
||||
|
||||
# Default .env file
|
||||
ENV_FILE="$PROJECT_ROOT/.env"
|
||||
|
|
@ -81,7 +82,18 @@ if [ -z "$BRAND" ]; then
|
|||
BRAND="webdrop_bridge"
|
||||
fi
|
||||
|
||||
eval "$(python3 "$BRAND_HELPER" env --brand "$BRAND")"
|
||||
if [ -x "$PROJECT_ROOT/.venv/bin/python" ]; then
|
||||
PYTHON_BIN="$PROJECT_ROOT/.venv/bin/python"
|
||||
elif command -v python3 &> /dev/null; then
|
||||
PYTHON_BIN="$(command -v python3)"
|
||||
fi
|
||||
|
||||
if [ -z "$PYTHON_BIN" ]; then
|
||||
echo "❌ Python 3 not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
eval "$("$PYTHON_BIN" "$BRAND_HELPER" env --brand "$BRAND")"
|
||||
APP_NAME="$WEBDROP_ASSET_PREFIX"
|
||||
DMG_VOLUME_NAME="$WEBDROP_APP_DISPLAY_NAME"
|
||||
BUNDLE_IDENTIFIER="$WEBDROP_BUNDLE_ID"
|
||||
|
|
@ -92,7 +104,7 @@ if [ -n "$WEBDROP_APP_DISPLAY_NAME" ]; then
|
|||
echo "🏷️ Building brand: $WEBDROP_APP_DISPLAY_NAME ($WEBDROP_BRAND_ID)"
|
||||
fi
|
||||
|
||||
VERSION="$(python3 -c "from pathlib import Path; import sys; sys.path.insert(0, str(Path(r'$BUILD_DIR/scripts').resolve())); from version_utils import get_current_version; print(get_current_version())")"
|
||||
VERSION="$("$PYTHON_BIN" -c "from pathlib import Path; import sys; sys.path.insert(0, str(Path(r'$BUILD_DIR/scripts').resolve())); from version_utils import get_current_version; print(get_current_version())")"
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
|
|
@ -159,14 +171,14 @@ check_prerequisites() {
|
|||
log_info "Checking prerequisites..."
|
||||
|
||||
# Check Python
|
||||
if ! command -v python3 &> /dev/null; then
|
||||
if [ ! -x "$PYTHON_BIN" ]; then
|
||||
log_error "Python 3 not found"
|
||||
exit 1
|
||||
fi
|
||||
log_success "Python 3 found: $(python3 --version)"
|
||||
log_success "Python 3 found: $($PYTHON_BIN --version)"
|
||||
|
||||
# Check PyInstaller
|
||||
if ! python3 -m pip show pyinstaller &> /dev/null; then
|
||||
if ! "$PYTHON_BIN" -m pip show pyinstaller &> /dev/null; then
|
||||
log_error "PyInstaller not installed. Run: pip install pyinstaller"
|
||||
exit 1
|
||||
fi
|
||||
|
|
@ -222,7 +234,7 @@ build_executable() {
|
|||
export WEBDROP_VERSION="$VERSION"
|
||||
export WEBDROP_BUNDLE_ID="$BUNDLE_IDENTIFIER"
|
||||
|
||||
python3 -m PyInstaller \
|
||||
"$PYTHON_BIN" -m PyInstaller \
|
||||
--distpath="$DIST_DIR" \
|
||||
--workpath="$TEMP_BUILD" \
|
||||
"$SPEC_FILE"
|
||||
|
|
|
|||
|
|
@ -11,8 +11,29 @@ import os
|
|||
|
||||
|
||||
project_root = Path.cwd()
|
||||
|
||||
if not (project_root / "src").exists():
|
||||
project_root = Path(__file__).resolve().parents[1]
|
||||
env_root = os.environ.get("WEBDROP_PROJECT_ROOT")
|
||||
if env_root:
|
||||
candidate = Path(env_root).resolve()
|
||||
if (candidate / "src").exists():
|
||||
project_root = candidate
|
||||
|
||||
if not (project_root / "src").exists():
|
||||
# PyInstaller exposes SPECPATH while evaluating spec files.
|
||||
spec_path = globals().get("SPECPATH")
|
||||
if spec_path:
|
||||
spec_candidate = Path(spec_path).resolve()
|
||||
for candidate in (spec_candidate, spec_candidate.parent):
|
||||
if (candidate / "src").exists():
|
||||
project_root = candidate
|
||||
break
|
||||
|
||||
if not (project_root / "src").exists():
|
||||
raise SystemExit(
|
||||
"Unable to determine project root for PyInstaller spec. "
|
||||
"Run from repository root or set WEBDROP_PROJECT_ROOT."
|
||||
)
|
||||
|
||||
pathex = [str(project_root / "src")]
|
||||
entry_script = str(project_root / "src" / "webdrop_bridge" / "main.py")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue