diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 3d1fdb40ff..6eed09c482 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -73,7 +73,7 @@ jobs: python-version: ${{ env.python_version }} - name: Version Check run: | - pip install --require-hashes -r .github/requirements.txt + pip install --require-hashes -r contrib/dev_reqs/requirements.txt python3 .github/scripts/version_check.py echo "git_commit_hash=$(git rev-parse --short HEAD)" >> $GITHUB_ENV echo "git_commit_date=$(git show -s --format=%ci)" >> $GITHUB_ENV diff --git a/.github/workflows/qc_checks.yaml b/.github/workflows/qc_checks.yaml index 5ca705eefa..257f75d3f6 100644 --- a/.github/workflows/qc_checks.yaml +++ b/.github/workflows/qc_checks.yaml @@ -104,7 +104,7 @@ jobs: uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # pin@v3.0.1 - name: Check Version run: | - pip install --require-hashes -r .github/requirements.txt + pip install --require-hashes -r contrib/dev_reqs/requirements.txt python3 .github/scripts/version_check.py mkdocs: @@ -122,7 +122,7 @@ jobs: python-version: ${{ env.python_version }} - name: Check Config run: | - pip install --require-hashes -r .github/requirements.txt + pip install --require-hashes -r contrib/dev_reqs/requirements.txt pip install --require-hashes -r docs/requirements.txt python docs/ci/check_mkdocs_config.py - name: Check Links @@ -168,7 +168,7 @@ jobs: - name: Download public schema if: needs.paths-filter.outputs.api == 'false' run: | - pip install --require-hashes -r .github/requirements.txt >/dev/null 2>&1 + pip install --require-hashes -r contrib/dev_reqs/requirements.txt >/dev/null 2>&1 version="$(python3 .github/scripts/version_check.py only_version 2>&1)" echo "Version: $version" url="https://raw.githubusercontent.com/inventree/schema/main/export/${version}/api.yaml" @@ -187,7 +187,7 @@ jobs: id: version if: github.ref == 'refs/heads/master' && needs.paths-filter.outputs.api == 'true' run: | - pip install --require-hashes -r .github/requirements.txt >/dev/null 2>&1 + pip install --require-hashes -r contrib/dev_reqs/requirements.txt >/dev/null 2>&1 version="$(python3 .github/scripts/version_check.py only_version 2>&1)" echo "Version: $version" echo "version=$version" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 1a0069b91c..bdfe44fbf1 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -18,7 +18,7 @@ jobs: uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # pin@v4.1.5 - name: Version Check run: | - pip install --require-hashes -r .github/requirements.txt + pip install --require-hashes -r contrib/dev_reqs/requirements.txt python3 .github/scripts/version_check.py - name: Push to Stable Branch uses: ad-m/github-push-action@d91a481090679876dfc4178fef17f286781251df # pin@v0.8.0 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6cace6d147..6c99a6f6d5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,8 +39,8 @@ repos: files: src/backend/requirements\.(in|txt)$ - id: pip-compile name: pip-compile requirements.txt - args: [.github/requirements.in, -o, .github/requirements.txt,--python-version=3.9, --no-strip-extras, --generate-hashes] - files: .github/requirements\.(in|txt)$ + args: [contrib/dev_reqs/requirements.in, -o, contrib/dev_reqs/requirements.txt,--python-version=3.9, --no-strip-extras, --generate-hashes] + files: contrib/dev_reqs/requirements\.(in|txt)$ - id: pip-compile name: pip-compile requirements.txt args: [docs/requirements.in, -o, docs/requirements.txt,--python-version=3.9, --no-strip-extras, --generate-hashes] diff --git a/.github/requirements.in b/contrib/dev_reqs/requirements.in similarity index 100% rename from .github/requirements.in rename to contrib/dev_reqs/requirements.in diff --git a/.github/requirements.txt b/contrib/dev_reqs/requirements.txt similarity index 99% rename from .github/requirements.txt rename to contrib/dev_reqs/requirements.txt index 5729dce9e3..8b5c921d65 100644 --- a/.github/requirements.txt +++ b/contrib/dev_reqs/requirements.txt @@ -1,5 +1,5 @@ # This file was autogenerated by uv via the following command: -# uv pip compile .github/requirements.in -o .github/requirements.txt --python-version=3.9 --no-strip-extras --generate-hashes +# uv pip compile contrib/dev_reqs/requirements.in -o contrib/dev_reqs/requirements.txt --python-version=3.9 --no-strip-extras --generate-hashes certifi==2024.2.2 \ --hash=sha256:0569859f95fc761b18b45ef421b1290a0f65f147e92a1e5eb3e635f9a5e4e66f \ --hash=sha256:dc383c07b76109f368f6106eee2b593b04a011ea4d55f652c6ca24a754d1cdd1 diff --git a/contrib/packager.io/functions.sh b/contrib/packager.io/functions.sh index 8f7f47cc66..bb236be77d 100755 --- a/contrib/packager.io/functions.sh +++ b/contrib/packager.io/functions.sh @@ -44,6 +44,18 @@ function detect_ip() { echo "IP address is ${INVENTREE_IP}" } +function detect_python() { + # Detect if there is already a python version installed in /opt/inventree/env/lib + if test -f "${APP_HOME}/env/bin/python"; then + echo "# Python environment already present" + # Extract earliest python version initialised from /opt/inventree/env/lib + SETUP_PYTHON=$(ls -1 ${APP_HOME}/env/bin/python* | sort | head -n 1) + echo "# Found earliest version: ${SETUP_PYTHON}" + else + echo "# No python environment found - using ${SETUP_PYTHON}" + fi +} + function get_env() { envname=$1 @@ -90,7 +102,7 @@ function detect_envs() { echo "# Using existing config file: ${INVENTREE_CONFIG_FILE}" # Install parser - pip install --require-hashes -r ${APP_HOME}/.github/requirements.txt -q + pip install --require-hashes -r ${APP_HOME}/contrib/dev_reqs/requirements.txt -q # Load config local CONF=$(cat ${INVENTREE_CONFIG_FILE} | jc --yaml) @@ -163,12 +175,20 @@ function create_initscripts() { sudo -u ${APP_USER} --preserve-env=$SETUP_ENVS bash -c "cd ${APP_HOME} && ${SETUP_PYTHON} -m venv env" sudo -u ${APP_USER} --preserve-env=$SETUP_ENVS bash -c "cd ${APP_HOME} && env/bin/pip install invoke wheel" + # Check INSTALLER_EXTRA exists and load it + if test -f "${APP_HOME}/INSTALLER_EXTRA"; then + echo "# Loading extra packages from INSTALLER_EXTRA" + source ${APP_HOME}/INSTALLER_EXTRA + fi + if [ -n "${SETUP_EXTRA_PIP}" ]; then echo "# Installing extra pip packages" if [ -n "${SETUP_DEBUG}" ]; then echo "# Extra pip packages: ${SETUP_EXTRA_PIP}" fi sudo -u ${APP_USER} --preserve-env=$SETUP_ENVS bash -c "cd ${APP_HOME} && env/bin/pip install ${SETUP_EXTRA_PIP}" + # Write extra packages to INSTALLER_EXTRA + echo "SETUP_EXTRA_PIP='${SETUP_EXTRA_PIP}'" >>${APP_HOME}/INSTALLER_EXTRA fi fi @@ -283,6 +303,20 @@ function set_env() { chown ${APP_USER}:${APP_GROUP} ${DATA_DIR} ${INVENTREE_CONFIG_FILE} } +function set_site() { + # Ensure IP is known + if [ -z "${INVENTREE_IP}" ]; then + echo "# No IP address found - skipping" + return + fi + + # Check if INVENTREE_SITE_URL in inventree config + if [ -z "$(inventree config:get INVENTREE_SITE_URL)" ]; then + echo "# Setting up InvenTree site URL" + inventree config:set INVENTREE_SITE_URL=http://${INVENTREE_IP} + fi +} + function final_message() { echo -e "####################################################################################" echo -e "This InvenTree install uses nginx, the settings for the webserver can be found in" diff --git a/contrib/packager.io/postinstall.sh b/contrib/packager.io/postinstall.sh index 03230b955a..89c88833b1 100755 --- a/contrib/packager.io/postinstall.sh +++ b/contrib/packager.io/postinstall.sh @@ -33,6 +33,7 @@ detect_envs detect_docker detect_initcmd detect_ip +detect_python # create processes create_initscripts @@ -45,6 +46,7 @@ update_or_install if [ "${SETUP_CONF_LOADED}" = "true" ]; then set_env fi +set_site start_inventree # show info