2015-02-26 23:21:05 +01:00
|
|
|
from toolchain import Recipe, shprint
|
|
|
|
from os.path import join, exists
|
|
|
|
import sh
|
|
|
|
import os
|
|
|
|
import fnmatch
|
|
|
|
import shutil
|
|
|
|
|
|
|
|
|
|
|
|
class HostSetuptools(Recipe):
|
2016-10-14 14:07:10 +02:00
|
|
|
depends = ["openssl", "hostpython"]
|
2016-02-14 14:49:25 +01:00
|
|
|
archs = ["x86_64"]
|
2016-10-14 10:13:38 +02:00
|
|
|
url = "setuptools"
|
2015-02-26 23:21:05 +01:00
|
|
|
|
|
|
|
def prebuild_arch(self, arch):
|
|
|
|
hostpython = sh.Command(self.ctx.hostpython)
|
|
|
|
sh.curl("-O", "https://bootstrap.pypa.io/ez_setup.py")
|
2016-10-14 10:05:44 +02:00
|
|
|
shprint(hostpython, "./ez_setup.py")
|
2016-10-14 16:01:50 +02:00
|
|
|
# Extract setuptools egg and remove .pth files. Otherwise subsequent
|
|
|
|
# python package installations using setuptools will raise exceptions.
|
|
|
|
# Setuptools version 28.3.0
|
|
|
|
site_packages_path = join(
|
|
|
|
self.ctx.dist_dir, 'hostpython',
|
|
|
|
'lib', 'python2.7', 'site-packages')
|
|
|
|
os.chdir(site_packages_path)
|
|
|
|
with open('setuptools.pth', 'r') as f:
|
|
|
|
setuptools_egg_path = f.read().strip('./').strip('\n')
|
|
|
|
unzip = sh.Command('unzip')
|
|
|
|
shprint(unzip, setuptools_egg_path)
|
|
|
|
os.remove(setuptools_egg_path)
|
|
|
|
os.remove('setuptools.pth')
|
2016-11-04 15:49:44 +01:00
|
|
|
# XXX: setuptools egg is referenced in easy-install.pth, check removal
|
|
|
|
# after unpacking setuptools if necessary
|
|
|
|
#os.remove('easy-install.pth')
|
2016-10-14 16:01:50 +02:00
|
|
|
shutil.rmtree('EGG-INFO')
|
2015-02-26 23:21:05 +01:00
|
|
|
|
2016-02-14 14:49:25 +01:00
|
|
|
recipe = HostSetuptools()
|