From 21a9d60d98e948d834135a880c89b15ae636e8d0 Mon Sep 17 00:00:00 2001 From: alexloss Date: Thu, 8 Apr 2021 15:19:12 +0200 Subject: [PATCH 1/4] Fix pip virtualenv discovery for softwareupdates --- src/octoprint/util/piptestballoon/setup.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/octoprint/util/piptestballoon/setup.py b/src/octoprint/util/piptestballoon/setup.py index 13dfc2ffdc..0c6b8a6009 100644 --- a/src/octoprint/util/piptestballoon/setup.py +++ b/src/octoprint/util/piptestballoon/setup.py @@ -1,4 +1,5 @@ from __future__ import absolute_import, division, print_function +import io import os import sys @@ -25,12 +26,17 @@ def produce_output(stream): cmd.finalize_options() install_dir = cmd.install_lib - virtual_env = hasattr(sys, "real_prefix") + virtual_env = hasattr(sys, "real_prefix") or ( + hasattr(sys, "base_prefix") and sys.base_prefix != sys.prefix + ) writable = os.access(install_dir, os.W_OK) - print("PIP_INSTALL_DIR={}".format(install_dir), file=stream) - print("PIP_VIRTUAL_ENV={}".format(virtual_env), file=stream) - print("PIP_WRITABLE={}".format(writable), file=stream) + lines = ["PIP_INSTALL_DIR={}".format(install_dir), + "PIP_VIRTUAL_ENV={}".format(virtual_env), + "PIP_WRITABLE={}".format(writable)] + + for line in lines: + print(line, file=stream) stream.flush() @@ -38,7 +44,7 @@ def produce_output(stream): if path is not None: # environment variable set, write to a log path = os.path.abspath(path) - with open(path, mode="w+b") as output: + with io.open(path, mode="wt+", encoding='utf-8') as output: produce_output(output) else: # write to stdout From ee8648a8d26c4b0b79cad8e90e88531f05425480 Mon Sep 17 00:00:00 2001 From: alexloss Date: Thu, 8 Apr 2021 16:14:15 +0200 Subject: [PATCH 2/4] Use setup.py frm latest OctoPrint version. --- src/octoprint/util/piptestballoon/setup.py | 58 ++++++++++++---------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/src/octoprint/util/piptestballoon/setup.py b/src/octoprint/util/piptestballoon/setup.py index 0c6b8a6009..036d9a56f4 100644 --- a/src/octoprint/util/piptestballoon/setup.py +++ b/src/octoprint/util/piptestballoon/setup.py @@ -1,10 +1,8 @@ -from __future__ import absolute_import, division, print_function -import io -import os -import sys +# -*- coding: utf-8 -*- +from __future__ import absolute_import, division, print_function, unicode_literals """ -This "python package" doesn't actually install. This is intenional. It is merely +This "python package" doesn't actually install. This is intentional. It is merely used to figure out some information about the environment a specific pip call is running under (installation dir, whether it belongs to a virtual environment, whether the install location is writable by the current user), and for that it @@ -18,37 +16,45 @@ --verbose or --log flags. """ +import io +import os +import sys + + def produce_output(stream): - from distutils.command.install import install as cmd_install - from distutils.dist import Distribution + from distutils.command.install import install as cmd_install + from distutils.dist import Distribution + + cmd = cmd_install(Distribution()) + cmd.finalize_options() - cmd = cmd_install(Distribution()) - cmd.finalize_options() + install_dir = cmd.install_lib + virtual_env = hasattr(sys, "real_prefix") or ( + hasattr(sys, "base_prefix") and sys.base_prefix != sys.prefix + ) + writable = os.access(install_dir, os.W_OK) - install_dir = cmd.install_lib - virtual_env = hasattr(sys, "real_prefix") or ( - hasattr(sys, "base_prefix") and sys.base_prefix != sys.prefix - ) - writable = os.access(install_dir, os.W_OK) + lines = [ + "PIP_INSTALL_DIR={}".format(install_dir), + "PIP_VIRTUAL_ENV={}".format(virtual_env), + "PIP_WRITABLE={}".format(writable), + ] - lines = ["PIP_INSTALL_DIR={}".format(install_dir), - "PIP_VIRTUAL_ENV={}".format(virtual_env), - "PIP_WRITABLE={}".format(writable)] + for line in lines: + print(line, file=stream) - for line in lines: - print(line, file=stream) - stream.flush() + stream.flush() path = os.environ.get("TESTBALLOON_OUTPUT", None) if path is not None: - # environment variable set, write to a log - path = os.path.abspath(path) - with io.open(path, mode="wt+", encoding='utf-8') as output: - produce_output(output) + # environment variable set, write to a log + path = os.path.abspath(path) + with io.open(path, "wt+", encoding="utf-8") as output: + produce_output(output) else: - # write to stdout - produce_output(sys.stdout) + # write to stdout + produce_output(sys.stdout) # fail intentionally sys.exit(-1) From 4706da278d73a71e67652a5a18da099e8cd31ddf Mon Sep 17 00:00:00 2001 From: alexloss Date: Thu, 8 Apr 2021 16:46:23 +0200 Subject: [PATCH 3/4] Enable pip install if using sudo. --- src/octoprint/util/pip.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/octoprint/util/pip.py b/src/octoprint/util/pip.py index 6de4213ee9..2abafb53c8 100644 --- a/src/octoprint/util/pip.py +++ b/src/octoprint/util/pip.py @@ -202,7 +202,7 @@ def _setup_pip(self): # in a virtual environment may we proceed with the --user parameter. ok, pip_user, pip_virtual_env, pip_install_dir = self._check_pip_setup(pip_command) - if not ok: + if not ok and (not pip_sudo or not pip_install_dir): self._logger.error("Cannot use pip") return From 92c51895324258e89c5b980ed32046b54b4c4101 Mon Sep 17 00:00:00 2001 From: Josef-MrBeam Date: Thu, 6 May 2021 16:59:38 +0200 Subject: [PATCH 4/4] fixed the softwareupdate asyny error fix #1246 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 2f22d210d4..c9893ce1f1 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ "pyserial>=2.7,<2.8", "netaddr>=0.7.17,<0.8", "watchdog>=0.8.3,<0.9", - "sarge>=0.1.4,<0.2", + "sarge==0.1.4", "netifaces>=0.10,<0.11", "pylru>=1.0.9,<1.1", "rsa>=3.2,<3.3",