-
Notifications
You must be signed in to change notification settings - Fork 95
/
setup.py
370 lines (335 loc) · 13.7 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
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
# -*- coding: utf-8 -*-
"""The setuptools based Ecere SDK setup module."""
import os
# import platform
from platform import python_version
pyver = python_version()
from os import path
dir = path.dirname(__file__)
if dir == '':
rwd = path.abspath('.')
else:
rwd = path.abspath(dir)
print('----------------------------------------------------------------------------')
print('__file__:', __file__)
print('dir:', dir)
print('rwd:', rwd)
#os.chdir(rwd)
#rwd = os.getcwd()
#os.chdir(path.join('bindings', 'py'))
pwd = path.join(rwd, 'bindings', 'py')
from setuptools import Command
from setuptools import find_packages
from setuptools import setup
from setuptools.command.install import install
from codecs import open
import subprocess
import sys
#import bindings.py.build_eC
import distutils.command.build
#sys.path.insert(0, dir)
#dddd = path.join(here, 'bindings', 'py')
#sys.path.append(path.dirname(__file__))
#sys.path.append(pwd)
#version_from_git = subprocess.check_output(['git', 'describe', '--tags', '--abbrev=0']).rstrip().decode('u8')
version_from_git = '0.44.15'
with open(path.join(rwd, 'README.md'), encoding='u8') as f:
long_description = f.read()
from subprocess import call
import multiprocessing
numJobs = '-j' + str(multiprocessing.cpu_count())
def buildEcereSDK():
print('buildEcereSDK')
call(['echo', 'buildEcereSDK'], shell=True)
proc = subprocess.Popen(['make', 'ENABLE_PYTHON_RPATHS=1', 'ECERE_AUDIO=y', numJobs], shell=False)
proc.communicate()
call(['dir', path.join('obj', 'win32', 'bin')], shell=True)
return proc.returncode == 0
def buildPrepInstall():
print('buildPrepInstall')
call(['echo', 'buildPrepInstall'], shell=True)
proc = subprocess.Popen(['make', 'prepinstall'], shell=False)
proc.communicate()
call(['dir', path.join('obj', 'win32', 'bin')], shell=True)
return proc.returncode == 0
def buildPyPrepInstall():
print('buildPyPrepInstall')
call(['echo', 'buildPyPrepInstall'], shell=True)
proc = subprocess.Popen(['make', 'py_prepinstall'], shell=False)
proc.communicate()
call(['dir', path.join('obj', 'win32', 'bin')], shell=True)
return proc.returncode == 0
def buildBindingsC():
print('buildBindingsC')
call(['echo', 'buildBindingsC'], shell=True)
proc = subprocess.Popen(['make', 'c_bindings'], shell=False)
proc.communicate()
call(['dir', path.join('obj', 'win32', 'bin')], shell=True)
return proc.returncode == 0
def buildBindingsGenPy():
print('buildBindingsGenPy')
call(['echo', 'buildBindingsGenPy'], shell=True)
proc = subprocess.Popen(['make', 'py_bindings_gen'], shell=False)
proc.communicate()
return proc.returncode == 0
def buildAll():
print('buildAll')
call(['echo', 'buildAll'], shell=True)
if buildEcereSDK():
if buildBindingsC():
if buildPrepInstall():
if buildPyPrepInstall():
if buildBindingsGenPy():
return True
return False
#class BuildCommand(distutils.command.build.build):
# """Customized setuptools build command."""
# def run(self):
#os.chdir(rwd)
#proc = subprocess.Popen(['make', 'ECERE_AUDIO=y', '-j8'], shell=False)
#proc.communicate()
#if proc.returncode == 0:
# proc = subprocess.Popen(['make', 'prepinstall'], shell=False)
# proc.communicate()
# if proc.returncode == 0:
# #owd = os.getcwd()
# os.chdir(os.path.join(rwd, 'bindings'))
# proc = subprocess.Popen(['make', 'py'], shell=False)
# proc.communicate()
# if proc.returncode == 0:
# os.chdir(pwd)
# distutils.command.build.build.run(self)
# #else: os.chdir(owd)
#os.chdir(pwd)
#os.chdir(pwd)
# distutils.command.build.build.run(self)
#class BuildCommand(Command):
# user_options = []
# def initialize_options(self):
# """Abstract method that is required to be overwritten"""
# def finalize_options(self):
# """Abstract method that is required to be overwritten"""
# def run(self):
# print(" => bootstrapping development environment ...")
# proc = subprocess.Popen(['make', '-j8'], shell=False)
# proc.communicate()
#class BuildPyCommand(setuptools.command.build_py.build_py):
# """Custom build command."""
# def run(self):
# self.run_command('make -j8')
# setuptools.command.build_py.build_py.run(self)
class CustomInstallCommand(install):
"""Customized setuptools install command."""
def run(self):
print('error !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
proc = subprocess.Popen(['make', 'V=1', 'ECERE_AUDIO=y', numJobs], shell=False)
proc.communicate()
if proc.returncode == 0:
install.run(self)
#class TestConsole(TestCase):
# def test_basic(self):
# main()
print(' -- before setup -- ')
print(__file__)
print('arg zero: ', sys.argv[0])
print('count: ', len(sys.argv))
print('args: ', str(sys.argv))
print('version: ', str(sys.version))
#print(mods)
#print(find_packages(where=pyDir))
#exit()
# ['-c', 'install', '--record', '~/install-record.txt', '--single-version-externally-managed', '--compile']
if 'sdist' in sys.argv or 'build' in sys.argv or 'install' in sys.argv or 'bdist_wheel' in sys.argv:
print('buildOk = buildAll()')
buildOk = buildAll()
else:
print('buildOk = True')
buildOk = True
if not buildOk:
raise Exception('build failed error: not calling setup() -- abort!')
else:
if sys.platform == 'win32':
#libdir = path.join('..', '..', 'obj', 'win32', 'bin')
#bindir = path.join('..', '..', 'obj', 'win32', 'bin')
libdir = path.join('obj', 'win32', 'py')
bindir = path.join('obj', 'win32', 'bin')
libpfx = ''
libext = '.dll'
exeext = '.exe'
elif sys.platform == 'linux' or sys.platform == 'linux2':
#libdir = path.join('..', '..', 'obj', 'linux', 'lib')
#bindir = path.join('..', '..', 'obj', 'linux', 'bin')
libdir = path.join(rwd, 'obj', 'linux', 'py')
bindir = path.join(rwd, 'obj', 'linux', 'bin')
libpfx = 'lib'
libext = '.so.0' # hardcoded marjor version number
exeext = ''
elif sys.platform == 'darwin':
libdir = path.join(rwd, 'obj', 'apple', 'py')
bindir = path.join(rwd, 'obj', 'apple', 'bin')
libpfx = 'lib'
libext = '.dylib'
exeext = ''
else:
print('error: unexpected platform')
print(sys.platform)
print(os.name)
#pyDir = path.join(rwd, 'bindings', 'py')
pyDir = path.join('bindings', 'py')
#from shutil import copyfile
#if sys.argv[0] == 'setup.py':
# if not 'install' in sys.argv:
#copyfile(path.join(pyDir, 'eC.py'), path.join('EcereSDK', 'eC.py'))
#copyfile(path.join(pyDir, 'ecere.py'), path.join('EcereSDK', 'ecere.py'))
#copyfile(path.join(pyDir, 'EDA.py'), path.join('EcereSDK', 'EDA.py'))
# copyfile(path.join(pyDir, 'eC.py'), 'eC.py')
# copyfile(path.join(pyDir, 'ecere.py'), 'ecere.py')
# copyfile(path.join(pyDir, 'EDA.py'), 'EDA.py')
bld_eC = path.join(pyDir, 'build_eC.py')
bld_ecere = path.join(pyDir, 'build_ecere.py')
bld_EDA = path.join(pyDir, 'build_EDA.py')
mods = [bld_eC + ':ffi_eC', bld_ecere + ':ffi_ecere', bld_EDA + ':ffi_EDA']
#foundPackages = []
#mod_eC = path.join(pyDir, 'eC')
#mod_ecere = path.join(pyDir, 'ecere')
#mod_EDA = path.join(pyDir, 'EDA')
setup(
name='EcereSDK',
version=version_from_git + '.dev31',
description='The Ecere Software Development Kit (SDK)',
long_description=long_description,
long_description_content_type='text/markdown',
url='https://ecere.org',
author='Jérôme Jacovella-St-Louis, Ecere Corporation',
author_email='jerome@ecere.com',
license='BSD 3-Clause (Revised)',
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Console',
#'Environment :: Console :: Curses',
#'Environment :: Console :: Framebuffer',
'Environment :: Handhelds/PDA\'s',
'Environment :: MacOS X',
'Environment :: No Input/Output (Daemon)',
'Environment :: Web Environment',
'Environment :: Win32 (MS Windows)',
'Environment :: X11 Applications',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: Android',
#'Operating System :: BeOS',
#'Operating System :: iOS',
#'Operating System :: MacOS',
#'Operating System :: MacOS :: MacOS 9',
'Operating System :: MacOS :: MacOS X',
#'Operating System :: Microsoft',
#'Operating System :: Microsoft :: MS-DOS',
#'Operating System :: Microsoft :: Windows',
'Operating System :: Microsoft :: Windows :: Windows 10',
#'Operating System :: Microsoft :: Windows :: Windows 3.1 or Earlier',
'Operating System :: Microsoft :: Windows :: Windows 7',
'Operating System :: Microsoft :: Windows :: Windows 8',
'Operating System :: Microsoft :: Windows :: Windows 8.1',
#'Operating System :: Microsoft :: Windows :: Windows 95/98/2000',
#'Operating System :: Microsoft :: Windows :: Windows CE',
#'Operating System :: Microsoft :: Windows :: Windows NT/2000',
'Operating System :: Microsoft :: Windows :: Windows Server 2003',
'Operating System :: Microsoft :: Windows :: Windows Server 2008',
#'Operating System :: Microsoft :: Windows :: Windows Vista',
#'Operating System :: Microsoft :: Windows :: Windows XP',
#'Operating System :: OS/2',
#'Operating System :: OS Independent',
#'Operating System :: Other OS',
#'Operating System :: PalmOS',
#'Operating System :: PDA Systems',
#'Operating System :: POSIX',
#'Operating System :: POSIX :: AIX',
'Operating System :: POSIX :: BSD',
#'Operating System :: POSIX :: BSD :: BSD/OS',
#'Operating System :: POSIX :: BSD :: FreeBSD',
#'Operating System :: POSIX :: BSD :: NetBSD',
#'Operating System :: POSIX :: BSD :: OpenBSD',
#'Operating System :: POSIX :: GNU Hurd',
#'Operating System :: POSIX :: HP-UX',
#'Operating System :: POSIX :: IRIX',
'Operating System :: POSIX :: Linux',
#'Operating System :: POSIX :: Other',
#'Operating System :: POSIX :: SCO',
#'Operating System :: POSIX :: SunOS/Solaris',
#'Operating System :: Unix',
'Programming Language :: C',
#'Programming Language :: eC',
#'Programming Language :: Python :: 2',
#'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3',
'Topic :: Software Development',
'Topic :: Software Development :: User Interfaces',
],
keywords='cross-platform gui 2D 3D development',
packages=['EcereSDK'],
#packages=['eceresdk'],
#packages=foundPackages,
#py_modules = [mod_eC, mod_ecere, mod_EDA],
package_dir={'EcereSDK':pyDir}, # required to find eC.py, ecere.py and EDA.py
#package_dir={'':'.'},
#cmdclass={'install': CustomInstallCommand},
#cmdclass={
#'pylint': PylintCommand,
#'build_py': BuildPyCommand,
#'build_py': BuildPyCommand,
# 'build': BuildCommand,
#},
# include everything in source control
#include_package_data=True,
# ...but exclude README.txt from all packages
#exclude_package_data={'': ['.gitattributes', '.gitignore', '.mailmap', '.travis.yml', '.appveyor.yml', '*.3ds', '*.3DS', 'samples']},
#python_requires='>2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
python_requires='>=3.4',
#setup_requires=['setuptools_git >= 0.3', 'cffi >= 1.11.5'], # 1.0.0 1.11.5 1.6.0
setup_requires=['pip >= 18.0', 'wheel', 'cffi >= 1.0.0', 'setuptools-git >= 1.0'],
cffi_modules=mods,
#cffi_modules=[path.join('bindings', 'py', 'build_eC.py:ffi_eC')],
#cffi_modules=['build_eC.py:ffi_eC', 'build_ecere.py:ffi_ecere'],
install_requires=['cffi >= 1.0.0'],
#extras_require={
# 'dev': ['check-manifest'],
# 'test': ['coverage'],
#},
package_data={
# 'sample': ['package_data.dat'],
},
data_files=[
('lib/python%s/site-packages/EcereSDK/lib' % (pyver[0:pyver.rfind('.')]), [
os.path.join(libdir, libpfx + 'ecereCOM' + libext),
os.path.join(libdir, libpfx + 'ecere' + libext),
os.path.join(libdir, libpfx + 'EDA' + libext),
os.path.join(libdir, libpfx + 'EcereAudio' + libext),
os.path.join(libdir, libpfx + 'ec' + libext),
os.path.join(libdir, libpfx + 'ec2' + libext),
#os.path.join(libdir, libpfx + 'eC_c' + libext),
#os.path.join(libdir, libpfx + 'ecere_c' + libext),
#os.path.join(libdir, libpfx + 'EDA_c' + libext),
]),
('lib/python%s/site-packages/EcereSDK/bin' % (pyver[0:pyver.rfind('.')]), [
os.path.join(bindir, 'ecp' + exeext),
os.path.join(bindir, 'ecc' + exeext),
os.path.join(bindir, 'ecs' + exeext),
os.path.join(bindir, 'ear' + exeext),
os.path.join(bindir, 'epj2make' + exeext),
os.path.join(bindir, 'bgen' + exeext),
os.path.join(bindir, 'documentor' + exeext),
os.path.join(bindir, 'ecere-ide' + exeext),
]),
('lib/python%s/site-packages/EcereSDK/samples' % (pyver[0:pyver.rfind('.')]), [
'samples/bindings/py/helloWorld.py',
'samples/bindings/py/helloForm.py',
'samples/bindings/py/hello3D.py',
])
],
#entry_points={
# 'console_scripts': [
# #'build_eC=build_eC:compile_eC',
# 'sample=sample:main',
# ],
#},
)