diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2014-10-25 19:31:28 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2014-10-25 19:31:28 -0400 |
commit | 2c923b60ebb68e23de2f6ba64a3ca226204b116c (patch) | |
tree | 2da665af0c4067601a48fec8620b1adeabeb0dd1 /bootstrap.py | |
parent | 95fcadd6d2fe0b48c9477f27f6b0071d6db18577 (diff) | |
download | external_python_setuptools-2c923b60ebb68e23de2f6ba64a3ca226204b116c.tar.gz external_python_setuptools-2c923b60ebb68e23de2f6ba64a3ca226204b116c.tar.bz2 external_python_setuptools-2c923b60ebb68e23de2f6ba64a3ca226204b116c.zip |
Adding 'bootstrap.py' for bootstrapping a development environment when setuptools metadata isn't already present. Fixes #278.
Diffstat (limited to 'bootstrap.py')
-rw-r--r-- | bootstrap.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/bootstrap.py b/bootstrap.py new file mode 100644 index 00000000..cbc1ca9d --- /dev/null +++ b/bootstrap.py @@ -0,0 +1,51 @@ +""" +If setuptools is not already installed in the environment, it's not possible +to invoke setuptools' own commands. This routine will bootstrap this local +environment by creating a minimal egg-info directory and then invoking the +egg-info command to flesh out the egg-info directory. +""" + +import os +import sys +import textwrap +import subprocess + + +minimal_egg_info = textwrap.dedent(""" + [distutils.commands] + egg_info = setuptools.command.egg_info:egg_info + + [distutils.setup_keywords] + include_package_data = setuptools.dist:assert_bool + install_requires = setuptools.dist:check_requirements + extras_require = setuptools.dist:check_extras + entry_points = setuptools.dist:check_entry_points + + [egg_info.writers] + dependency_links.txt = setuptools.command.egg_info:overwrite_arg + entry_points.txt = setuptools.command.egg_info:write_entries + requires.txt = setuptools.command.egg_info:write_requirements + """) + +def ensure_egg_info(): + if not os.path.exists('setuptools.egg-info'): + build_egg_info() + + +def build_egg_info(): + """ + Build a minimal egg-info, enough to invoke egg_info + """ + + os.mkdir('setuptools.egg-info') + with open('setuptools.egg-info/entry_points.txt', 'w') as ep: + ep.write(minimal_egg_info) + + +def run_egg_info(): + subprocess.check_call([sys.executable, 'setup.py', 'egg_info']) + + +if __name__ == '__main__': + ensure_egg_info() + run_egg_info() |