-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup.py
69 lines (56 loc) · 2.1 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
from __future__ import print_function
import sys
import os
# from setuptools import Distribution
from pkg_resources import get_distribution, working_set, VersionConflict
def samefile(path, other):
"""
Workaround for missing ``os.path.samefile`` in Windows Python 2.7.
"""
return os.path.normcase(os.path.normpath(os.path.realpath(path))) \
== os.path.normcase(os.path.normpath(os.path.realpath(other)))
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
try:
import zetup
except VersionConflict:
egg_info = 'zetup.egg-info'
dist = get_distribution('zetup')
if samefile(
dist.location, os.path.dirname(os.path.realpath(__file__))
) and os.path.exists(egg_info):
print("zetup: Removing possibly outdated %s/" % egg_info,
# don't pollute stdout
file=sys.stderr)
for fname in os.listdir(egg_info):
os.remove(os.path.join(egg_info, fname))
os.rmdir(egg_info)
# when run via pip, the egg-info is still referenced by setuptools,
# which would try to read the contents
for keys in working_set.entry_keys.values():
if 'zetup' in keys:
keys.remove('zetup')
del working_set.by_key['zetup']
from zetup import Zetup, DistributionNotFound, VersionConflict
try:
from zetup.commands import make, pytest, tox, conda
except (ImportError, DistributionNotFound, VersionConflict):
# ==> no zetup commands available
# standard setup commands work anyway
pass
# setup_req = 'setuptools >= 15.0'
# try:
# get_distribution(setup_req)
# except VersionConflict:
# for mod in ['setuptools', 'pkg_resources']:
# for name, _ in list(sys.modules.items()):
# if name == mod or name.startswith(mod + '.'):
# del sys.modules[name]
# sys.path.insert(0, Distribution().fetch_build_egg(setup_req))
zfg = Zetup()
zetup.requires.Requirements('setuptools >= 36.2', zfg=zfg).check()
setup = zfg.setup
setup['package_data']['zetup.commands.make'] = [
'templates/*.jinja',
'templates/package/*.jinja',
]
setup()