aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2016-01-24 10:07:40 -0500
committerJason R. Coombs <jaraco@jaraco.com>2016-01-24 10:07:40 -0500
commite7f9dab06dc2515fe11e7f31ea948eed5e141470 (patch)
treeeec9669a863418b59b9329648cd0ac7b6ba9d9ab
parent3b7b733ca9f2e3193426682ae6357b3f29307aa2 (diff)
downloadexternal_python_setuptools-e7f9dab06dc2515fe11e7f31ea948eed5e141470.tar.gz
external_python_setuptools-e7f9dab06dc2515fe11e7f31ea948eed5e141470.tar.bz2
external_python_setuptools-e7f9dab06dc2515fe11e7f31ea948eed5e141470.zip
Add 'launch' hook, based on pip.utils.setuptools_build
-rw-r--r--CHANGES.txt15
-rw-r--r--setuptools/launch.py28
2 files changed, 43 insertions, 0 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 0fbfc26d..c82ec5a5 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,6 +2,21 @@
CHANGES
=======
+19.6
+----
+
+* Added a new entry script ``setuptools.launch``,
+ implementing the shim found in
+ ``pip.util.setuptools_build``. Use this command to launch
+ distutils-only packages under setuptools in the same way that
+ pip does, causing the setuptools monkeypatching of distutils
+ to be invoked prior to invoking a script. Useful for debugging
+ or otherwise installing a distutils-only package under
+ setuptools when pip isn't available or otherwise does not
+ expose the desired functionality. For example::
+
+ $ python -m setuptools.launch setup.py develop
+
19.5
----
diff --git a/setuptools/launch.py b/setuptools/launch.py
new file mode 100644
index 00000000..68cce681
--- /dev/null
+++ b/setuptools/launch.py
@@ -0,0 +1,28 @@
+"""
+Launch the Python script on the command line after
+setuptools is bootstrapped via import.
+"""
+
+# Note that setuptools gets imported implicitly by the
+# invocation of this script using python -m setuptools.launch
+
+import tokenize
+import sys
+
+
+def load():
+ """
+ Load the script in sys.argv[1] and run it as if it had
+ been invoked naturally.
+ """
+ globals()['__file__'] = sys.argv[1]
+ sys.argv[:] = sys.argv[1:]
+
+ open_ = getattr(tokenize, 'open', open)
+ script = open_(__file__).read()
+ norm_script = script.replace('\\r\\n', '\\n')
+ return compile(norm_script, __file__, 'exec')
+
+
+if __name__ == '__main__':
+ exec(load())