From ff371f18f0076bc63da05334f7e551c1cc29e10d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 1 Jan 2017 22:34:28 -0500 Subject: Strip out vendored packages and require them instead. Ref #581. --- bootstrap.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index c5f470a4..761b8dfc 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -5,6 +5,8 @@ environment by creating a minimal egg-info directory and then invoking the egg-info command to flesh out the egg-info directory. """ +__requires__ = ['packaging', 'six', 'appdirs'] + import os import sys import textwrap -- cgit v1.2.1 From a36dbf75bd6b1283fd3da28c25fd583f20025c36 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 1 Jan 2017 23:12:23 -0500 Subject: In the bootstrap script, generate a requirements.txt file and use it to install the dependencies just in time to make them available long enough to generate the egg info. --- bootstrap.py | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index 761b8dfc..705a8720 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -5,13 +5,18 @@ environment by creating a minimal egg-info directory and then invoking the egg-info command to flesh out the egg-info directory. """ -__requires__ = ['packaging', 'six', 'appdirs'] - import os +import io +import re +import contextlib +import tempfile +import shutil import sys import textwrap import subprocess +import pip + minimal_egg_info = textwrap.dedent(""" [distutils.commands] egg_info = setuptools.command.egg_info:egg_info @@ -54,6 +59,35 @@ def run_egg_info(): subprocess.check_call(cmd) +def gen_deps(): + with io.open('setup.py', encoding='utf-8') as strm: + text = strm.read() + pattern = r'install_requires=\[(.*?)\]' + match = re.search(pattern, text, flags=re.M|re.DOTALL) + reqs = eval(match.group(1).replace('\n', '')) + with io.open('requirements.txt', 'w', encoding='utf-8') as reqs_file: + reqs_file.write('\n'.join(reqs)) + + +@contextlib.contextmanager +def install_deps(): + "Just in time make the deps available" + gen_deps() + tmpdir = tempfile.mkdtemp() + args = [ + 'install', + '-t', tmpdir, + '-r', 'requirements.txt', + ] + pip.main(args) + os.environ['PYTHONPATH'] = tmpdir + try: + yield tmpdir + finally: + shutil.rmtree(tmpdir) + + if __name__ == '__main__': ensure_egg_info() - run_egg_info() + with install_deps(): + run_egg_info() -- cgit v1.2.1 From 767dcea007cf19b016c33f036f750c87b5876d1f Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 1 Jan 2017 23:15:38 -0500 Subject: Use unicode literals --- bootstrap.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index 705a8720..f7644f12 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -5,6 +5,8 @@ environment by creating a minimal egg-info directory and then invoking the egg-info command to flesh out the egg-info directory. """ +from __future__ import unicode_literals + import os import io import re @@ -47,7 +49,8 @@ def build_egg_info(): """ os.mkdir('setuptools.egg-info') - with open('setuptools.egg-info/entry_points.txt', 'w') as ep: + filename = 'setuptools.egg-info/entry_points.txt' + with io.open(filename, 'w', encoding='utf-8') as ep: ep.write(minimal_egg_info) -- cgit v1.2.1 From 4481a64e2c905f40afa478ebd5418614f322b9b0 Mon Sep 17 00:00:00 2001 From: Jonathan Helmus Date: Thu, 2 Feb 2017 08:54:37 -0600 Subject: Add --skip-dep-install to boostrap.py script The --skip-dep-install flag skips installation of setuptools dependencies using pip, delegating this responsibility to other tools. This can be used to install setuptools without the need for pip. closes #950 --- bootstrap.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index f7644f12..1a789311 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -7,6 +7,7 @@ egg-info command to flesh out the egg-info directory. from __future__ import unicode_literals +import argparse import os import io import re @@ -17,7 +18,6 @@ import sys import textwrap import subprocess -import pip minimal_egg_info = textwrap.dedent(""" [distutils.commands] @@ -75,6 +75,7 @@ def gen_deps(): @contextlib.contextmanager def install_deps(): "Just in time make the deps available" + import pip gen_deps() tmpdir = tempfile.mkdtemp() args = [ @@ -91,6 +92,15 @@ def install_deps(): if __name__ == '__main__': + parser = argparse.ArgumentParser(description='bootstrap setuptools') + parser.add_argument( + '--skip-dep-install', action='store_true', + help=("Do not attempt to install setuptools dependencies. These " + "should be provided in the environment in another manner.")) + args = parser.parse_args() ensure_egg_info() - with install_deps(): + if args.skip_dep_install: run_egg_info() + else: + with install_deps(): + run_egg_info() -- cgit v1.2.1 From c182abae2af4cb5e12bb8200995a0026de07f146 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 2 Feb 2017 10:50:47 -0500 Subject: Extract main function --- bootstrap.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index 1a789311..2ca678ff 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -91,7 +91,7 @@ def install_deps(): shutil.rmtree(tmpdir) -if __name__ == '__main__': +def main(): parser = argparse.ArgumentParser(description='bootstrap setuptools') parser.add_argument( '--skip-dep-install', action='store_true', @@ -104,3 +104,6 @@ if __name__ == '__main__': else: with install_deps(): run_egg_info() + + +__name__ == '__main__' and main() -- cgit v1.2.1 From 174e84e0ce297c38aa11f6618c7d0dad7f1a5acf Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 2 Feb 2017 11:01:37 -0500 Subject: In bootstrap, defer installation of dependencies if unneeded. Ref #958. --- bootstrap.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index 2ca678ff..ad9b067e 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -7,7 +7,6 @@ egg-info command to flesh out the egg-info directory. from __future__ import unicode_literals -import argparse import os import io import re @@ -92,16 +91,12 @@ def install_deps(): def main(): - parser = argparse.ArgumentParser(description='bootstrap setuptools') - parser.add_argument( - '--skip-dep-install', action='store_true', - help=("Do not attempt to install setuptools dependencies. These " - "should be provided in the environment in another manner.")) - args = parser.parse_args() ensure_egg_info() - if args.skip_dep_install: + try: + # first assume dependencies are present run_egg_info() - else: + except Exception: + # but if that fails, try again with dependencies just in time with install_deps(): run_egg_info() -- cgit v1.2.1 From e65c45538fab94008b8066edd134725be8f9c400 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 2 Feb 2017 11:21:38 -0500 Subject: Always generate the dependencies. --- bootstrap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index ad9b067e..ee3b53c8 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -75,7 +75,6 @@ def gen_deps(): def install_deps(): "Just in time make the deps available" import pip - gen_deps() tmpdir = tempfile.mkdtemp() args = [ 'install', @@ -92,6 +91,7 @@ def install_deps(): def main(): ensure_egg_info() + gen_deps() try: # first assume dependencies are present run_egg_info() -- cgit v1.2.1 From 3d0cc355fb5e8012cb8c72f0e25042a5a44f31d6 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 24 Feb 2017 11:49:51 -0500 Subject: Revert "Merge pull request #933 from pypa/feature/581-depend-not-bundle" This reverts commit 089cdeb489a0fa94d11b7307b54210ef9aa40511, reversing changes made to aaec654d804cb78dbb6391afff721a63f26a71cd. --- bootstrap.py | 47 ++--------------------------------------------- 1 file changed, 2 insertions(+), 45 deletions(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index ee3b53c8..24d7093c 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -5,14 +5,7 @@ environment by creating a minimal egg-info directory and then invoking the egg-info command to flesh out the egg-info directory. """ -from __future__ import unicode_literals - import os -import io -import re -import contextlib -import tempfile -import shutil import sys import textwrap import subprocess @@ -48,8 +41,7 @@ def build_egg_info(): """ os.mkdir('setuptools.egg-info') - filename = 'setuptools.egg-info/entry_points.txt' - with io.open(filename, 'w', encoding='utf-8') as ep: + with open('setuptools.egg-info/entry_points.txt', 'w') as ep: ep.write(minimal_egg_info) @@ -61,44 +53,9 @@ def run_egg_info(): subprocess.check_call(cmd) -def gen_deps(): - with io.open('setup.py', encoding='utf-8') as strm: - text = strm.read() - pattern = r'install_requires=\[(.*?)\]' - match = re.search(pattern, text, flags=re.M|re.DOTALL) - reqs = eval(match.group(1).replace('\n', '')) - with io.open('requirements.txt', 'w', encoding='utf-8') as reqs_file: - reqs_file.write('\n'.join(reqs)) - - -@contextlib.contextmanager -def install_deps(): - "Just in time make the deps available" - import pip - tmpdir = tempfile.mkdtemp() - args = [ - 'install', - '-t', tmpdir, - '-r', 'requirements.txt', - ] - pip.main(args) - os.environ['PYTHONPATH'] = tmpdir - try: - yield tmpdir - finally: - shutil.rmtree(tmpdir) - - def main(): ensure_egg_info() - gen_deps() - try: - # first assume dependencies are present - run_egg_info() - except Exception: - # but if that fails, try again with dependencies just in time - with install_deps(): - run_egg_info() + run_egg_info() __name__ == '__main__' and main() -- cgit v1.2.1 From 3b443bc9ca9d7159f57fc232c97a4635ecb4086f Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 4 Jun 2017 15:33:40 -0400 Subject: Use io.open when saving entry_points. --- bootstrap.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index 24d7093c..f3a12c07 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -9,6 +9,7 @@ import os import sys import textwrap import subprocess +import io minimal_egg_info = textwrap.dedent(""" @@ -41,7 +42,7 @@ def build_egg_info(): """ os.mkdir('setuptools.egg-info') - with open('setuptools.egg-info/entry_points.txt', 'w') as ep: + with io.open('setuptools.egg-info/entry_points.txt', 'w') as ep: ep.write(minimal_egg_info) -- cgit v1.2.1 From dd622e26da86651bf1f0506452c2c55eb1eb8f4d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 13 Jul 2017 14:23:07 -0400 Subject: Use unicode_literals in bootstrap script --- bootstrap.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index f3a12c07..8c7d7fc3 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -5,6 +5,8 @@ environment by creating a minimal egg-info directory and then invoking the egg-info command to flesh out the egg-info directory. """ +from __future__ import unicode_literals + import os import sys import textwrap -- cgit v1.2.1