mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-29 20:30:39 +00:00 
			
		
		
		
	Fixes for installer (#7344)
* - move reqs file to contrib - detect previously used python version - safe extra requirements to INSTALLER_EXTRA * add missing fi * move site setting
This commit is contained in:
		
							
								
								
									
										2
									
								
								.github/workflows/docker.yaml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/docker.yaml
									
									
									
									
										vendored
									
									
								
							| @@ -73,7 +73,7 @@ jobs: | |||||||
|           python-version: ${{ env.python_version }} |           python-version: ${{ env.python_version }} | ||||||
|       - name: Version Check |       - name: Version Check | ||||||
|         run: | |         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 |           python3 .github/scripts/version_check.py | ||||||
|           echo "git_commit_hash=$(git rev-parse --short HEAD)" >> $GITHUB_ENV |           echo "git_commit_hash=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | ||||||
|           echo "git_commit_date=$(git show -s --format=%ci)" >> $GITHUB_ENV |           echo "git_commit_date=$(git show -s --format=%ci)" >> $GITHUB_ENV | ||||||
|   | |||||||
							
								
								
									
										8
									
								
								.github/workflows/qc_checks.yaml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								.github/workflows/qc_checks.yaml
									
									
									
									
										vendored
									
									
								
							| @@ -104,7 +104,7 @@ jobs: | |||||||
|         uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # pin@v3.0.1 |         uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # pin@v3.0.1 | ||||||
|       - name: Check Version |       - name: Check Version | ||||||
|         run: | |         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 |           python3 .github/scripts/version_check.py | ||||||
|  |  | ||||||
|   mkdocs: |   mkdocs: | ||||||
| @@ -122,7 +122,7 @@ jobs: | |||||||
|           python-version: ${{ env.python_version }} |           python-version: ${{ env.python_version }} | ||||||
|       - name: Check Config |       - name: Check Config | ||||||
|         run: | |         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 |           pip install --require-hashes -r docs/requirements.txt | ||||||
|           python docs/ci/check_mkdocs_config.py |           python docs/ci/check_mkdocs_config.py | ||||||
|       - name: Check Links |       - name: Check Links | ||||||
| @@ -168,7 +168,7 @@ jobs: | |||||||
|       - name: Download public schema |       - name: Download public schema | ||||||
|         if: needs.paths-filter.outputs.api == 'false' |         if: needs.paths-filter.outputs.api == 'false' | ||||||
|         run: | |         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)" |           version="$(python3 .github/scripts/version_check.py only_version 2>&1)" | ||||||
|           echo "Version: $version" |           echo "Version: $version" | ||||||
|           url="https://raw.githubusercontent.com/inventree/schema/main/export/${version}/api.yaml" |           url="https://raw.githubusercontent.com/inventree/schema/main/export/${version}/api.yaml" | ||||||
| @@ -187,7 +187,7 @@ jobs: | |||||||
|         id: version |         id: version | ||||||
|         if: github.ref == 'refs/heads/master' && needs.paths-filter.outputs.api == 'true' |         if: github.ref == 'refs/heads/master' && needs.paths-filter.outputs.api == 'true' | ||||||
|         run: | |         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)" |           version="$(python3 .github/scripts/version_check.py only_version 2>&1)" | ||||||
|           echo "Version: $version" |           echo "Version: $version" | ||||||
|           echo "version=$version" >> "$GITHUB_OUTPUT" |           echo "version=$version" >> "$GITHUB_OUTPUT" | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								.github/workflows/release.yaml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/release.yaml
									
									
									
									
										vendored
									
									
								
							| @@ -18,7 +18,7 @@ jobs: | |||||||
|         uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # pin@v4.1.6 |         uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # pin@v4.1.6 | ||||||
|       - name: Version Check |       - name: Version Check | ||||||
|         run: | |         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 |           python3 .github/scripts/version_check.py | ||||||
|       - name: Push to Stable Branch |       - name: Push to Stable Branch | ||||||
|         uses: ad-m/github-push-action@d91a481090679876dfc4178fef17f286781251df # pin@v0.8.0 |         uses: ad-m/github-push-action@d91a481090679876dfc4178fef17f286781251df # pin@v0.8.0 | ||||||
|   | |||||||
| @@ -39,8 +39,8 @@ repos: | |||||||
|         files: src/backend/requirements\.(in|txt)$ |         files: src/backend/requirements\.(in|txt)$ | ||||||
|       - id: pip-compile |       - id: pip-compile | ||||||
|         name: pip-compile requirements.txt |         name: pip-compile requirements.txt | ||||||
|         args: [.github/requirements.in, -o, .github/requirements.txt,--python-version=3.9, --no-strip-extras, --generate-hashes] |         args: [contrib/dev_reqs/requirements.in, -o, contrib/dev_reqs/requirements.txt,--python-version=3.9, --no-strip-extras, --generate-hashes] | ||||||
|         files: .github/requirements\.(in|txt)$ |         files: contrib/dev_reqs/requirements\.(in|txt)$ | ||||||
|       - id: pip-compile |       - id: pip-compile | ||||||
|         name: pip-compile requirements.txt |         name: pip-compile requirements.txt | ||||||
|         args: [docs/requirements.in, -o, docs/requirements.txt,--python-version=3.9, --no-strip-extras, --generate-hashes] |         args: [docs/requirements.in, -o, docs/requirements.txt,--python-version=3.9, --no-strip-extras, --generate-hashes] | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| # This file was autogenerated by uv via the following command: | # 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 \ | certifi==2024.2.2 \ | ||||||
|     --hash=sha256:0569859f95fc761b18b45ef421b1290a0f65f147e92a1e5eb3e635f9a5e4e66f \ |     --hash=sha256:0569859f95fc761b18b45ef421b1290a0f65f147e92a1e5eb3e635f9a5e4e66f \ | ||||||
|     --hash=sha256:dc383c07b76109f368f6106eee2b593b04a011ea4d55f652c6ca24a754d1cdd1 |     --hash=sha256:dc383c07b76109f368f6106eee2b593b04a011ea4d55f652c6ca24a754d1cdd1 | ||||||
| @@ -44,6 +44,18 @@ function detect_ip() { | |||||||
|   echo "IP address is ${INVENTREE_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() { | function get_env() { | ||||||
|   envname=$1 |   envname=$1 | ||||||
|  |  | ||||||
| @@ -90,7 +102,7 @@ function detect_envs() { | |||||||
|     echo "# Using existing config file: ${INVENTREE_CONFIG_FILE}" |     echo "# Using existing config file: ${INVENTREE_CONFIG_FILE}" | ||||||
|  |  | ||||||
|     # Install parser |     # 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 |     # Load config | ||||||
|     local CONF=$(cat ${INVENTREE_CONFIG_FILE} | jc --yaml) |     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} && ${SETUP_PYTHON} -m venv env" | ||||||
|     sudo -u ${APP_USER} --preserve-env=$SETUP_ENVS bash -c "cd ${APP_HOME} && env/bin/pip install invoke wheel" |     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 |     if [ -n "${SETUP_EXTRA_PIP}" ]; then | ||||||
|       echo "# Installing extra pip packages" |       echo "# Installing extra pip packages" | ||||||
|       if [ -n "${SETUP_DEBUG}" ]; then |       if [ -n "${SETUP_DEBUG}" ]; then | ||||||
|         echo "# Extra pip packages: ${SETUP_EXTRA_PIP}" |         echo "# Extra pip packages: ${SETUP_EXTRA_PIP}" | ||||||
|       fi |       fi | ||||||
|       sudo -u ${APP_USER} --preserve-env=$SETUP_ENVS bash -c "cd ${APP_HOME} && env/bin/pip install ${SETUP_EXTRA_PIP}" |       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 | ||||||
|   fi |   fi | ||||||
|  |  | ||||||
| @@ -283,6 +303,20 @@ function set_env() { | |||||||
|   chown ${APP_USER}:${APP_GROUP} ${DATA_DIR} ${INVENTREE_CONFIG_FILE} |   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() { | function final_message() { | ||||||
|   echo -e "####################################################################################" |   echo -e "####################################################################################" | ||||||
|   echo -e "This InvenTree install uses nginx, the settings for the webserver can be found in" |   echo -e "This InvenTree install uses nginx, the settings for the webserver can be found in" | ||||||
|   | |||||||
| @@ -33,6 +33,7 @@ detect_envs | |||||||
| detect_docker | detect_docker | ||||||
| detect_initcmd | detect_initcmd | ||||||
| detect_ip | detect_ip | ||||||
|  | detect_python | ||||||
|  |  | ||||||
| # create processes | # create processes | ||||||
| create_initscripts | create_initscripts | ||||||
| @@ -45,6 +46,7 @@ update_or_install | |||||||
| if [ "${SETUP_CONF_LOADED}" = "true" ]; then | if [ "${SETUP_CONF_LOADED}" = "true" ]; then | ||||||
|   set_env |   set_env | ||||||
| fi | fi | ||||||
|  | set_site | ||||||
| start_inventree | start_inventree | ||||||
|  |  | ||||||
| # show info | # show info | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user