forked from wxWidgets/Phoenix
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
Latest commit
374 lines (298 loc) · 13.5 KB
/
Copy pathsetup.py
File metadata and controls
374 lines (298 loc) · 13.5 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
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
371
372
373
374
#----------------------------------------------------------------------
# Name: setup.py
# Purpose: Distutils build script for wxPython (phoenix)
#
# Author: Robin Dunn
#
# Created: 3-Nov-2010
# Copyright: (c) 2010-2018 by Total Control Software
# License: wxWindows License
#----------------------------------------------------------------------
importsys, os
importglob
fromsetuptoolsimportsetup, find_packages
fromdistutils.command.buildimportbuildasorig_build
fromsetuptools.command.installimportinstallasorig_install
fromsetuptools.command.bdist_eggimportbdist_eggasorig_bdist_egg
fromsetuptools.command.sdistimportsdistasorig_sdist
try:
fromwheel.bdist_wheelimportbdist_wheelasorig_bdist_wheel
haveWheel=True
exceptImportError:
haveWheel=False
frombuildtools.configimportConfig, msg, opj, runcmd, canGetSOName, getSOName
importbuildtools.versionasversion
# Create a buildtools.config.Configuration object
cfg=Config(noWxConfig=True)
DOCS_BASE='http://docs.wxPython.org'
#----------------------------------------------------------------------
NAME=version.PROJECT_NAME
DESCRIPTION="Cross platform GUI toolkit for Python, \"Phoenix\" version"
AUTHOR="Robin Dunn"
AUTHOR_EMAIL="robin@alldunn.com"
URL="http://wxPython.org/"
DOWNLOAD_URL="https://pypi.org/project/{}".format(NAME)
LICENSE="wxWindows Library License (https://opensource.org/licenses/wxwindows.php)"
PLATFORMS="WIN32,WIN64,OSX,POSIX"
KEYWORDS="GUI,wx,wxWindows,wxWidgets,cross-platform,user-interface,awesome"
LONG_DESCRIPTION="""\
Welcome to wxPython's Project Phoenix! Phoenix is the improved next-generation
wxPython, "better, stronger, faster than he was before." This new
implementation is focused on improving speed, maintainability and
extensibility. Just like "Classic" wxPython, Phoenix wraps the wxWidgets C++
toolkit and provides access to the user interface portions of the wxWidgets
API, enabling Python applications to have a native GUI on Windows, Macs or
Unix systems, with a native look and feel and requiring very little (if any)
platform specific code.
For more information please refer to the
`README file <https://github.com/wxWidgets/Phoenix/blob/wxPython-{version}/README.rst>`_,
the `Migration Guide <{docs_base}/MigrationGuide.html>`_,
or the `wxPython API documentation <{docs_base}/index.html>`_.
Archive files containing a copy of the wxPython documentation, the demo and
samples, and also a set of MSVC .pdb files for Windows are available
`here <https://extras.wxPython.org/wxPython4/extras/>`_.
The utility tools wxdocs and wxdemo will download the appropriate files with wxget,
(if necessary), unpack them, (if necessary) and launch the appropriate version of
the respective items. (Documents are launched in the default browser and demo is started
with python).
""".format(version=cfg.VERSION, docs_base=DOCS_BASE)
CLASSIFIERS="""\
Development Status :: 6 - Mature
Environment :: MacOS X :: Cocoa
Environment :: Win32 (MS Windows)
Environment :: X11 Applications :: GTK
Intended Audience :: Developers
License :: OSI Approved
Operating System :: MacOS :: MacOS X
Operating System :: Microsoft :: Windows :: Windows 7
Operating System :: Microsoft :: Windows :: Windows 10
Operating System :: POSIX
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3.4
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: Implementation :: CPython
Topic :: Software Development :: User Interfaces
"""
INSTALL_REQUIRES= [line.strip()
forlineinopen('requirements/install.txt').readlines()
ifnotline.startswith('#')]
isWindows=sys.platform.startswith('win')
isDarwin=sys.platform=="darwin"
#----------------------------------------------------------------------
# Classes used in place of some distutils/setuptools classes.
classwx_build(orig_build):
"""
Delegate to build.py for doing the actual build, (including wxWidgets)
instead of letting distutils do it all.
"""
user_options= [
('skip-build', None, 'skip building the C/C++ code (assumes it has already been done)'),
]
boolean_options= ['skip-build']
definitialize_options(self):
orig_build.initialize_options(self)
self.skip_build='--skip-build'insys.argv
deffinalize_options(self):
orig_build.finalize_options(self)
self.build_lib=self.build_platlib
defrun(self):
ifnotself.skip_build:
# Run build.py to do the actual building of the extension modules
msg('WARNING: Building this way assumes that all generated files have been \n'
'generated already. If that is not the case then use build.py directly \n'
'to generate the source and perform the build stage. You can use \n'
'--skip-build with the bdist_* or install commands to avoid this \n'
'message and the wxWidgets and Phoenix build steps in the future.\n')
# Use the same Python that is running this script.
cmd= ['"{}"'.format(sys.executable), '-u', 'build.py', 'build']
cmd=' '.join(cmd)
runcmd(cmd)
# Let distutils handle building up the package folder under the
# build/lib folder like normal.
orig_build.run(self)
def_cleanup_symlinks(cmd):
# Clean out any libwx* symlinks in the build_lib folder, as they will
# turn into copies in the egg since zip files can't handle symlinks.
# The links are not really needed since the extensions link to the
# specific soname, and they could bloat the egg too much if they were
# left in.
#
# TODO: can eggs have post-install scripts that would allow us to
# restore the links? No.
#
build_lib=cmd.get_finalized_command('build').build_lib
build_lib=opj(build_lib, 'wx')
forlibnameinglob.glob(opj(build_lib, 'libwx*')):
ifos.path.islink(libname):
ifisDarwin:
# On Mac the name used by the extension module is the real
# file, so we can just get rid of all the links.
os.unlink(libname)
elifcanGetSOName():
# On linux the soname used in the extension modules may
# be (probably is) one of the symlinks, so we have to be
# more tricky here. If the named file is a link and it is
# the soname, then remove the link and rename the
# linked-to file to this name.
soname=getSOName(libname)
ifsoname==os.path.basename(libname):
realfile=os.path.join(build_lib, os.readlink(libname))
os.unlink(libname)
os.rename(realfile, libname)
else:
os.unlink(libname)
else:
# Otherwise just leave the symlink there since we don't
# know what to do with it.
pass
classwx_bdist_egg(orig_bdist_egg):
deffinalize_options(self):
orig_bdist_egg.finalize_options(self)
# Redo the calculation of the egg's filename since we always have
# extension modules, but they are not built by setuptools so it
# doesn't know about them.
frompkg_resourcesimportDistribution
fromsysconfigimportget_python_version
basename=Distribution(
None, None, self.ei_cmd.egg_name, self.ei_cmd.egg_version,
get_python_version(),
self.plat_name
).egg_name()
self.egg_output=os.path.join(self.dist_dir, basename+'.egg')
defrun(self):
# Ensure that there is a basic library build for bdist_egg to pull from.
self.run_command("build")
_cleanup_symlinks(self)
# Run the default bdist_egg command
orig_bdist_egg.run(self)
ifhaveWheel:
classwx_bdist_wheel(orig_bdist_wheel):
deffinalize_options(self):
# Do a bit of monkey-patching to let bdist_wheel know that there
# really are extension modules in this build, even though they are
# not built here.
def_has_ext_modules(self):
returnTrue
fromsetuptools.distimportDistribution
#Distribution.is_pure = _is_pure
Distribution.has_ext_modules=_has_ext_modules
orig_bdist_wheel.finalize_options(self)
defrun(self):
# Ensure that there is a basic library build for bdist_egg to pull from.
self.run_command("build")
_cleanup_symlinks(self)
# Run the default bdist_wheel command
orig_bdist_wheel.run(self)
classwx_install(orig_install):
deffinalize_options(self):
orig_install.finalize_options(self)
self.install_lib=self.install_platlib
defrun(self):
self.run_command("build")
orig_install.run(self)
classwx_sdist(orig_sdist):
defrun(self):
# Use build.py to perform the sdist
cmd= ['"{}"'.format(sys.executable), '-u', 'build.py', 'sdist']
cmd=' '.join(cmd)
runcmd(cmd)
# Put the filename in dist_files in case the upload command is used.
# On the other hand, PyPI's upload size limit is waaaaaaaaay too
# small so it probably doesn't matter too much...
sdist_file=opj(self.dist_dir, self.distribution.get_fullname()+'.tar.gz')
self.distribution.dist_files.append(('sdist', '', sdist_file))
# Map these new classes to the appropriate distutils command names.
CMDCLASS= {
'build' : wx_build,
'bdist_egg' : wx_bdist_egg,
'install' : wx_install,
'sdist' : wx_sdist,
}
ifhaveWheel:
CMDCLASS['bdist_wheel'] =wx_bdist_wheel
#----------------------------------------------------------------------
# Monkey-patch copy_file and copy_tree such that they preserve symlinks. We
# need this since we're copying the wx shared libs into the package folder
# and the default implementations would have copied the file content multiple
# times instead of just copying the symlinks.
defwx_copy_file(src, dst, preserve_mode=1, preserve_times=1, update=0,
link=None, verbose=1, dry_run=0):
ifnotos.path.islink(src):
returnorig_copy_file(
src, dst, preserve_mode, preserve_times, update, link, verbose, dry_run)
else:
# make a new, matching symlink in dst
ifos.path.isdir(dst):
dst=os.path.join(dst, os.path.basename(src))
linkdst=os.readlink(src)
ifverbose>=1:
fromdistutilsimportlog
log.info("%s %s -> %s", 'copying symlink', src, dst)
ifnotdry_runandnotos.path.exists(dst):
os.symlink(linkdst, dst)
return (dst, 1)
importdistutils.file_util
orig_copy_file=distutils.file_util.copy_file
distutils.file_util.copy_file=wx_copy_file
defwx_copy_tree(src, dst, preserve_mode=1, preserve_times=1,
preserve_symlinks=0, update=0, verbose=1, dry_run=0):
returnorig_copy_tree(
src, dst, preserve_mode, preserve_times, 1, update, verbose, dry_run)
importdistutils.dir_util
orig_copy_tree=distutils.dir_util.copy_tree
distutils.dir_util.copy_tree=wx_copy_tree
#----------------------------------------------------------------------
WX_PKGLIST= [cfg.PKGDIR] + [cfg.PKGDIR+'.'+pkgforpkginfind_packages('wx')]
ENTRY_POINTS= {
'console_scripts' : [
"img2png = wx.tools.img2png:main",
"img2py = wx.tools.img2py:main",
"img2xpm = wx.tools.img2xpm:main",
"pywxrc = wx.tools.pywxrc:main",
# ],
# 'gui_scripts' : [ # TODO: Why was this commented out?
"wxget = wx.tools.wxget:main", # New wx wget
"wxdocs = wx.tools.wxget_docs_demo:docs_main", # Get/Launch Docs
"wxdemo = wx.tools.wxget_docs_demo:demo_main", # Get/Launch Demo
"helpviewer = wx.tools.helpviewer:main",
"pycrust = wx.py.PyCrust:main",
"pyshell = wx.py.PyShell:main",
"pyslices = wx.py.PySlices:main",
"pyslicesshell = wx.py.PySlicesShell:main",
],
}
SCRIPTS= []
DATA_FILES= []
HEADERS=None
BUILD_OPTIONS= { } #'build_base' : cfg.BUILD_BASE }
#if cfg.WXPORT == 'msw':
# BUILD_OPTIONS[ 'compiler' ] = cfg.COMPILER
#----------------------------------------------------------------------
if__name__=='__main__':
setup(name=NAME,
version=cfg.VERSION,
description=DESCRIPTION,
long_description=LONG_DESCRIPTION,
author=AUTHOR,
author_email=AUTHOR_EMAIL,
url=URL,
download_url=DOWNLOAD_URL,
license=LICENSE,
platforms=PLATFORMS,
classifiers= [cforcinCLASSIFIERS.split("\n") ifc],
keywords=KEYWORDS,
install_requires=INSTALL_REQUIRES,
zip_safe=False,
use_2to3=False,
include_package_data=True,
packages=WX_PKGLIST,
ext_package=cfg.PKGDIR,
options= { 'build' : BUILD_OPTIONS },
scripts=SCRIPTS,
data_files=DATA_FILES,
headers=HEADERS,
cmdclass=CMDCLASS,
entry_points=ENTRY_POINTS,
)