update_manager: use glob pattern matching to find site package folder

This allows for python version flexibility.  Resolves #76.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2021-01-31 09:07:55 -05:00
parent 81104a6618
commit fe2cec1087
2 changed files with 10 additions and 6 deletions

View File

@ -4,6 +4,7 @@
# #
# This file may be distributed under the terms of the GNU GPLv3 license. # This file may be distributed under the terms of the GNU GPLv3 license.
import os import os
import glob
import re import re
import logging import logging
import json import json
@ -439,12 +440,15 @@ class GitUpdater:
if p.strip()] if p.strip()]
self.python_dist_path = os.path.abspath( self.python_dist_path = os.path.abspath(
config.get('python_dist_path')) config.get('python_dist_path'))
if not os.path.exists(self.python_dist_path): env_package_path = os.path.abspath(os.path.join(
raise config.error(
"Invalid path for option 'python_dist_path'")
self.env_package_path = os.path.abspath(os.path.join(
os.path.dirname(self.env), "..", os.path.dirname(self.env), "..",
config.get('env_package_path'))) config.get('env_package_path')))
matches = glob.glob(env_package_path)
if len(matches) == 1:
self.env_package_path = matches[0]
else:
raise config.error("No match for 'env_package_path': %s"
% (env_package_path,))
for opt in ["repo_path", "env", "python_reqs", "install_script", for opt in ["repo_path", "env", "python_reqs", "install_script",
"python_dist_path", "env_package_path"]: "python_dist_path", "env_package_path"]:
val = getattr(self, opt) val = getattr(self, opt)

View File

@ -7,7 +7,7 @@ requirements: scripts/moonraker-requirements.txt
venv_args: -p python3 venv_args: -p python3
install_script: scripts/install-moonraker.sh install_script: scripts/install-moonraker.sh
python_dist_path: /usr/lib/python3/dist-packages python_dist_path: /usr/lib/python3/dist-packages
env_package_path: lib/python3.7/site-packages env_package_path: lib/python*/site-packages
python_dist_packages: python_dist_packages:
gpiod gpiod
@ -17,4 +17,4 @@ requirements: scripts/klippy-requirements.txt
venv_args: -p python2 venv_args: -p python2
install_script: scripts/install-octopi.sh install_script: scripts/install-octopi.sh
python_dist_path: /usr/lib/python2.7/dist-packages python_dist_path: /usr/lib/python2.7/dist-packages
env_package_path: lib/python2.7/site-packages env_package_path: lib/python*/site-packages