diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2017-09-29 13:40:02 +0300 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2017-09-29 13:40:02 +0300 |
commit | 424a50000a78fff715de4417dba9b4498aeeee4c (patch) | |
tree | d27f003c7d140fef24efd1b2ca1325ae099154b9 /debian/patches/ensurepip-disabled.diff | |
download | python3.5-debian.tar.gz |
Imported python3.5 3.5.4-4debian/3.5.4-4debian
Diffstat (limited to 'debian/patches/ensurepip-disabled.diff')
-rw-r--r-- | debian/patches/ensurepip-disabled.diff | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/debian/patches/ensurepip-disabled.diff b/debian/patches/ensurepip-disabled.diff new file mode 100644 index 0000000..e6ba0e4 --- /dev/null +++ b/debian/patches/ensurepip-disabled.diff @@ -0,0 +1,87 @@ +# DP: Disable ensurepip for the system installation, only enable it for virtual environments. + +Index: b/Lib/ensurepip/__init__.py +=================================================================== +--- a/Lib/ensurepip/__init__.py ++++ b/Lib/ensurepip/__init__.py +@@ -8,6 +8,34 @@ import tempfile + + __all__ = ["version", "bootstrap"] + ++def _ensurepip_is_disabled_in_debian_for_system(): ++ # Detect if ensurepip is being executed inside of a python-virtualenv ++ # environment and return early if so. ++ if hasattr(sys, 'real_prefix'): ++ return ++ ++ # Detect if ensurepip is being executed inside of a stdlib venv ++ # environment and return early if so. ++ if sys.prefix != getattr(sys, "base_prefix", sys.prefix): ++ return ++ ++ # If we've gotten here, then we are running inside of the system Python ++ # and we don't want to use ensurepip to install into the system Python ++ # so instead we'll redirect the user to using dpkg and apt-get. ++ print('''\ ++ensurepip is disabled in Debian/Ubuntu for the system python. ++ ++Python modules for the system python are usually handled by dpkg and apt-get. ++ ++ apt-get install python-<module name> ++ ++Install the python-pip package to use pip itself. Using pip together ++with the system python might have unexpected results for any system installed ++module, so use it on your own risk, or make sure to only use it in virtual ++environments. ++''') ++ sys.exit(1) ++ + + # pip currently requires ssl support, so we try to provide a nicer + # error message when that is missing (http://bugs.python.org/issue19744) +@@ -69,6 +97,11 @@ def bootstrap(*, root=None, upgrade=Fals + + Note that calling this function will alter both sys.path and os.environ. + """ ++ ++ # Ensure that we are only running this inside of a virtual environment ++ # of some kind. ++ _ensurepip_is_disabled_in_debian_for_system() ++ + if altinstall and default_pip: + raise ValueError("Cannot use altinstall and default_pip together") + +Index: b/Lib/venv/__init__.py +=================================================================== +--- a/Lib/venv/__init__.py ++++ b/Lib/venv/__init__.py +@@ -261,7 +261,28 @@ class EnvBuilder: + # intended for the global Python environment + cmd = [context.env_exe, '-Im', 'ensurepip', '--upgrade', + '--default-pip'] +- subprocess.check_output(cmd, stderr=subprocess.STDOUT) ++ # Debian 2015-09-18 barry@debian.org: <python>-venv is a separate ++ # binary package which might not be installed. In that case, the ++ # following command will produce an unhelpful error. Let's make it ++ # more user friendly. ++ try: ++ subprocess.check_output( ++ cmd, stderr=subprocess.STDOUT, ++ universal_newlines=True) ++ except subprocess.CalledProcessError: ++ print("""\ ++The virtual environment was not created successfully because ensurepip is not ++available. On Debian/Ubuntu systems, you need to install the python3-venv ++package using the following command. ++ ++ apt-get install python3-venv ++ ++You may need to use sudo with that command. After installing the python3-venv ++package, recreate your virtual environment. ++ ++Failing command: {} ++""".format(cmd)) ++ sys.exit(1) + + def setup_scripts(self, context): + """ |