From 9f9a05cabb2a41ba52b651362cf9121fa2d475e8 Mon Sep 17 00:00:00 2001 From: Arksine Date: Tue, 22 Dec 2020 17:55:59 -0500 Subject: [PATCH] update_manager: symlink dist packages on virtualenv rebuild This allows for the installation of python "dist-packages" without enabling "system-site-packages" in the virtualenv. As of the moment moonraker only requires the gpiod dist package. Signed-off-by: Eric Callahan --- moonraker/plugins/update_manager.py | 21 +++++++++++++++++++-- scripts/version.txt | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/moonraker/plugins/update_manager.py b/moonraker/plugins/update_manager.py index 2f60d12..a58377c 100644 --- a/moonraker/plugins/update_manager.py +++ b/moonraker/plugins/update_manager.py @@ -30,14 +30,20 @@ REPO_DATA = { 'origin': "https://github.com/arksine/moonraker.git", 'install_script': "scripts/install-moonraker.sh", 'requirements': "scripts/moonraker-requirements.txt", - 'venv_args': "-p python3 --system-site-packages" + 'venv_args': "-p python3", + 'dist_packages': ["gpiod"], + 'dist_dir': "/usr/lib/python3/dist-packages", + 'site_pkg_path': "lib/python3.7/site-packages", }, 'klipper': { 'repo_url': f"{REPO_PREFIX}/kevinoconnor/klipper/branches/master", 'origin': "https://github.com/kevinoconnor/klipper.git", 'install_script': "scripts/install-octopi.sh", 'requirements': "scripts/klippy-requirements.txt", - 'venv_args': "-p python2" + 'venv_args': "-p python2", + 'dist_packages': [], + 'dist_dir': "", + 'site_pkg_path': "", } } @@ -382,6 +388,17 @@ class GitUpdater: return if not os.path.expanduser(self.env): raise self._log_exc("Failed to create new virtualenv", False) + dist_pkgs = REPO_DATA[self.name]['dist_packages'] + dist_dir = REPO_DATA[self.name]['dist_dir'] + site_path = REPO_DATA[self.name]['site_pkg_path'] + for pkg in dist_pkgs: + for f in os.listdir(dist_dir): + if f.startswith(pkg): + src = os.path.join(dist_dir, f) + dest = os.path.join(env_path, site_path, f) + self._notify_status(f"Linking to dist package: {pkg}") + os.symlink(f, dest) + break reqs = os.path.join( self.repo_path, REPO_DATA[self.name]['requirements']) if not os.path.isfile(reqs): diff --git a/scripts/version.txt b/scripts/version.txt index 83fc48a..ccb44ec 100644 --- a/scripts/version.txt +++ b/scripts/version.txt @@ -1,2 +1,2 @@ -env_version=0.2.2 +env_version=0.2.4 deps_version=0.2.2