From 59171a5845519eb706d2097cae3e18bfa29ce177 Mon Sep 17 00:00:00 2001 From: Lorin Date: Sat, 27 Apr 2024 22:43:49 -0600 Subject: [PATCH] no build deps for packages that need numpy --- python/requirements/dbr104/.gitignore | 1 - python/requirements/dbr104/dbr104_arm.txt | 4 +++ .../dbr104/install_non_dev_dependencies.sh | 36 +++++++++++++++++++ .../dbr104/set_install_command.sh | 10 ------ python/tox.ini | 10 ++---- 5 files changed, 43 insertions(+), 18 deletions(-) delete mode 100644 python/requirements/dbr104/.gitignore create mode 100644 python/requirements/dbr104/dbr104_arm.txt create mode 100755 python/requirements/dbr104/install_non_dev_dependencies.sh delete mode 100755 python/requirements/dbr104/set_install_command.sh diff --git a/python/requirements/dbr104/.gitignore b/python/requirements/dbr104/.gitignore deleted file mode 100644 index a9ac5094..00000000 --- a/python/requirements/dbr104/.gitignore +++ /dev/null @@ -1 +0,0 @@ -install_cmd.txt \ No newline at end of file diff --git a/python/requirements/dbr104/dbr104_arm.txt b/python/requirements/dbr104/dbr104_arm.txt new file mode 100644 index 00000000..0196bcf4 --- /dev/null +++ b/python/requirements/dbr104/dbr104_arm.txt @@ -0,0 +1,4 @@ +numpy~=1.20.1 +delta-spark~=1.1.0 +ipython~=7.22.0 +pyspark~=3.2.1 \ No newline at end of file diff --git a/python/requirements/dbr104/install_non_dev_dependencies.sh b/python/requirements/dbr104/install_non_dev_dependencies.sh new file mode 100755 index 00000000..c78dcfe2 --- /dev/null +++ b/python/requirements/dbr104/install_non_dev_dependencies.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +set -e # Exit on error +[ -n "$DEBUG" ] && set -x # Enable debugging if DEBUG environment variable is set + +# This runs from the root of the repository +ARM_REQ_FILE="$(pwd)/requirements/dbr104/dbr104_arm.txt" +GENERIC_REQ_FILE="$(pwd)/requirements/dbr104/dbr104.txt" + +# Check necessary commands and files +command -v pip >/dev/null 2>&1 || { echo >&2 "pip is required but it's not installed. Aborting."; exit 1; } +[ -f "$ARM_REQ_FILE" ] || { echo >&2 "Required file $ARM_REQ_FILE not found. Aborting."; exit 1; } +[ -f "$GENERIC_REQ_FILE" ] || { echo >&2 "Required file $GENERIC_REQ_FILE not found. Aborting."; exit 1; } + +# Get the architecture of the system +sys_arch=$(uname -m) +echo "System Architecture: $sys_arch" + +echo "Upgrading pip..." +pip install --upgrade pip + +case "$sys_arch" in + arm*) + echo "ARM Architecture detected. Specific model: $sys_arch" + echo "Installing ARM-specific dependencies..." + pip install -r "$ARM_REQ_FILE" + pip install --no-deps pandas~=1.2.4 + pip install --no-deps pyarrow~=4.0.0 + pip install --no-deps scipy~=1.6.2 + ;; + *) + echo "Non-ARM Architecture: $sys_arch" + echo "Installing generic dependencies..." + pip install -r "$GENERIC_REQ_FILE" + ;; +esac diff --git a/python/requirements/dbr104/set_install_command.sh b/python/requirements/dbr104/set_install_command.sh deleted file mode 100755 index 99ff398e..00000000 --- a/python/requirements/dbr104/set_install_command.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -# Based on architecture, set an appropriate install command -SYS_ARCH=$(uname -m) -export SYS_ARCH -if [ "$SYS_ARCH" = "arm64" ]; then - NO_BINARY_PACKAGES="pyarrow,pandas,scipy" - echo "pip install --no-binary $NO_BINARY_PACKAGES {opts} {packages}" > install_cmd.txt -else - echo "pip install {opts} {packages}" > install_cmd.txt -fi diff --git a/python/tox.ini b/python/tox.ini index 1fd699f3..d2638a95 100644 --- a/python/tox.ini +++ b/python/tox.ini @@ -30,16 +30,12 @@ commands = coverage run -m unittest discover -s tests -p '*_tests.py' [testenv:dbr104] -allowlist_externals = bash -commands_pre = - bash -c "./requirements/{envname}/set_install_command.sh" -install_command = - bash -c "cat requirements/{envname}/install_cmd.txt" +allowlist_externals = chmod, bash, source deps = -rrequirements/dev.txt - ;NB: dependency order matters for this env - -rrequirements/{envname}/{envname}.txt commands = + chmod +x ./requirements/dbr104/install_non_dev_dependencies.sh + source ./requirements/dbr104/install_non_dev_dependencies.sh coverage erase coverage run -m unittest discover -s tests -p '*_tests.py'