forked from userzimmermann/carefree-objects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
95 lines (73 loc) · 2.71 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# This file was auto-generated by ZETUP
#
# Zimmermann's Extensible Tools for Unified Project setups
#
# https://github.com/zimmermanncode/zetup
from __future__ import print_function
import sys
import os
import re
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
SETUP_REQUIRES = [
'zetup >= 0.2.42',
]
try:
from setuptools.dist import Distribution
from pkg_resources import get_distribution, working_set, \
DistributionNotFound, VersionConflict
except ImportError: # no setuptools
pass
else:
# Make sure that setup requirements are always correctly resolved and
# accessible by:
# - Recursively resolving their runtime requirements
# - Moving any installed eggs to the front of sys.path
# - Updating pkg_resources.working_set accordingly
installer = Distribution().fetch_build_egg
# don't pollute stdout. first backup
__stdout__ = sys.__stdout__
stdout = sys.stdout
# then redirect to stderr...
class StdErrWrapper(object):
# on windows, directly assigning stderr to stdout
# often leads to a detached stderr buffer in the end
def __getattr__(self, name):
return getattr(sys.__stderr__, name)
def detach(self):
# so don't let stderr's buffer get stolen
return self
def __del__(self):
# and also don't let __getattr__ fetch stderr's __del__
pass
sys.stdout = sys.__stdout__ = StdErrWrapper()
def resolve(requirements, parent=None):
for req in requirements:
qualreq = parent and '%s->%s' % (req, parent) or req
print("Resolving setup requirement %s:" % qualreq)
try:
dist = get_distribution(req)
print(repr(dist))
except (DistributionNotFound, VersionConflict):
dist = installer(req)
sys.path.insert(0, dist.location)
working_set.add_entry(dist.location)
extras = re.match(r'[^#\[]*\[([^#\]]*)\]', req)
if extras:
extras = list(map(str.strip, extras.group(1).split(',')))
resolve((str(req).split(';')[0]
for req in dist.requires(extras=extras or ())),
qualreq)
resolve(SETUP_REQUIRES)
zfg = __import__('zetup').Zetup()
resolve(str(req).split(';')[0] for req in zfg.SETUP_REQUIRES or [])
sys.__stdout__ = __stdout__
sys.stdout = stdout
dist = zfg.setup(
setup_requires=SETUP_REQUIRES + [
str(req) for req in zfg.SETUP_REQUIRES or ()],
use_zetup=True,
)
del dist.zetup_made