forked from fimapp/golem
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
189 lines (156 loc) · 5.64 KB
/
setup.py
File metadata and controls
189 lines (156 loc) · 5.64 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#!/usr/bin/env python
import os
import re
import subprocess
import sys
from os import path
import imp
from setuptools import find_packages
from setuptools.command.test import test as TestCommand
try:
from cx_Freeze import setup
use_cx_Freeze = True
except ImportError:
from setuptools import setup
use_cx_Freeze = False
def generate_ui_files():
ui_path = path.normpath(path.join(path.abspath(path.dirname(__file__)), "gnr/ui"))
from golem.tools.uigen import gen_ui_files
gen_ui_files(ui_path)
generate_ui_files()
def try_building_docker_images():
try:
subprocess.check_call(["docker", "info"])
except Exception as err:
print("""
***************************************************************"
Docker not available, not building images."
Command 'docker info' returned {}"
***************************************************************"
""".format(err))
return
images_dir = path.join('gnr', 'task')
cwd = os.getcwdu()
with open(path.join(images_dir, 'images.ini')) as f:
for line in f:
try:
image, docker_file, tag = line.split()
if subprocess.check_output(["docker", "images", "-q", image + ":" + tag]):
print "\n Image {} exists - skipping".format(image)
continue
docker_file_dir = path.join(images_dir, os.path.dirname(docker_file))
os.chdir(docker_file_dir)
docker_file = path.basename(docker_file)
cmd = "docker build -t {} -f {} .".format(image, docker_file)
print "\nRunning '{}' ...\n".format(cmd)
subprocess.check_call(cmd.split(" "))
cmd = "docker tag {} {}:{}".format(image, image, tag)
print "\nRunning '{}' ...\n".format(cmd)
subprocess.check_call(cmd.split(" "))
except ValueError:
print "Skipping line {}".format(line)
except subprocess.CalledProcessError as err:
print "Docker build failed: {}".format(err)
sys.exit(1)
finally:
os.chdir(cwd)
try_building_docker_images()
class PyTest(TestCommand):
''' py.test integration with setuptools,
https://pytest.org/latest/goodpractises.html\
#integration-with-setuptools-test-commands '''
user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")]
def initialize_options(self):
TestCommand.initialize_options(self)
self.pytest_args = []
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
# import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(self.pytest_args)
sys.exit(errno)
def parse_requirements(requirements_file):
requirements = []
dependency_links = []
for line in open(path.join(path.dirname(__file__), requirements_file)):
line = line.strip()
m = re.match('.+#egg=(?P<package>.+)$', line)
if m:
requirements.append(m.group('package'))
dependency_links.append(line)
else:
requirements.append(line)
return requirements, dependency_links
def find_required_packages():
if sys.platform.startswith('darwin'):
return find_packages(exclude=['examples'])
return find_packages(include=['golem*', 'gnr*'])
def current_dir():
return os.path.dirname(os.path.abspath(__file__))
# TODO: Refer correct README file here
# with open('README.rst') as readme_file:
# readme = readme_file.read()
# TODO: We don't have any HISTORY file yet
# with open('HISTORY.rst') as history_file:
# history = history_file.read().replace('.. :changelog:', '')
requirements, dependency_links = parse_requirements('requirements.txt')
test_requirements = ['mock', 'pytest']
options = {}
executables = []
cmdclass = {'test': PyTest}
packages = find_required_packages()
if use_cx_Freeze:
package_creator = imp.load_source(
'package_creator',
os.path.join('scripts', 'packaging', 'package_creator.py')
)
package_creator.update_setup_config(
setup_dir=current_dir(),
options=options,
cmdclass=cmdclass,
executables=executables
)
setup(
name='golem',
version='0.1.0',
description="Golem project.",
# TODO: Update if README is available
# long_description=readme + '\n\n' + history,
author="Golem Team",
author_email='contact@golemproject.net',
url='http://golemproject.net',
packages=packages,
entry_points={
'console_scripts': [
'golemapp = golemapp:start',
'golemcli = golemcli:start',
]
},
install_requires=requirements,
include_package_data=True,
dependency_links=dependency_links,
# TODO: No license yet
# license="ISCL",
zip_safe=False,
keywords='golem',
# classifiers=[
# 'Development Status :: 2 - Pre-Alpha',
# 'Intended Audience :: Developers',
# 'License :: OSI Approved :: ISC License (ISCL)',
# 'Natural Language :: English',
# "Programming Language :: Python :: 2",
# 'Programming Language :: Python :: 2.6',
# 'Programming Language :: Python :: 2.7',
# 'Programming Language :: Python :: 3',
# 'Programming Language :: Python :: 3.3',
# 'Programming Language :: Python :: 3.4',
# ],
cmdclass=cmdclass,
options=options,
executables=executables,
test_suite='tests',
tests_require=test_requirements
)