2014-10-26 02:31:28 +03:00
|
|
|
"""
|
|
|
|
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.
|
|
|
|
"""
|
|
|
|
|
2017-07-13 21:23:07 +03:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2014-10-26 02:31:28 +03:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import textwrap
|
|
|
|
import subprocess
|
2017-06-04 22:33:40 +03:00
|
|
|
import io
|
2014-10-26 02:31:28 +03:00
|
|
|
|
2017-01-02 06:12:23 +02:00
|
|
|
|
2014-10-26 02:31:28 +03:00
|
|
|
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
|
|
|
|
""")
|
|
|
|
|
2016-07-12 18:00:43 +03:00
|
|
|
|
2014-10-26 02:31:28 +03:00
|
|
|
def ensure_egg_info():
|
2015-01-03 04:49:37 +02:00
|
|
|
if os.path.exists('setuptools.egg-info'):
|
|
|
|
return
|
|
|
|
print("adding minimal entry_points")
|
|
|
|
build_egg_info()
|
2014-10-26 02:31:28 +03:00
|
|
|
|
|
|
|
|
|
|
|
def build_egg_info():
|
|
|
|
"""
|
|
|
|
Build a minimal egg-info, enough to invoke egg_info
|
|
|
|
"""
|
|
|
|
|
|
|
|
os.mkdir('setuptools.egg-info')
|
2017-06-04 22:33:40 +03:00
|
|
|
with io.open('setuptools.egg-info/entry_points.txt', 'w') as ep:
|
2014-10-26 02:31:28 +03:00
|
|
|
ep.write(minimal_egg_info)
|
|
|
|
|
|
|
|
|
|
|
|
def run_egg_info():
|
2015-01-03 05:02:21 +02:00
|
|
|
cmd = [sys.executable, 'setup.py', 'egg_info']
|
2015-01-03 04:57:30 +02:00
|
|
|
print("Regenerating egg_info")
|
2015-01-03 05:02:21 +02:00
|
|
|
subprocess.check_call(cmd)
|
|
|
|
print("...and again.")
|
|
|
|
subprocess.check_call(cmd)
|
2014-10-26 02:31:28 +03:00
|
|
|
|
|
|
|
|
2017-02-02 17:50:47 +02:00
|
|
|
def main():
|
2014-10-26 02:31:28 +03:00
|
|
|
ensure_egg_info()
|
2017-02-24 18:49:51 +02:00
|
|
|
run_egg_info()
|
2017-02-02 17:50:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
__name__ == '__main__' and main()
|