Skip to content

Commit 6799533

Browse files
author
Ram Rachum
committed
-
1 parent 828c484 commit 6799533

File tree

4 files changed

+75
-21
lines changed

4 files changed

+75
-21
lines changed

garlicsim_wx/garlicsim_wx/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# or distributed without explicit written permission from Ram Rachum.
33

44
'''
5-
garlicsim_wx, a wxPython GUI for garlicsim.
5+
A wxPython-based GUI for garlicsim.
66
77
The final goal of this project is to become a fully-fledged application for
88
working with simulations, friendly enough that it may be used by
@@ -29,7 +29,7 @@
2929
__version__ = '0.4'
3030

3131
def start():
32-
'''Start the gui.'''
32+
'''Start the GUI.'''
3333

3434
new_gui_project_simpack_name = None
3535
for arg in sys.argv:

garlicsim_wx/garlicsim_wx/frame/frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def __setup_gui_project(self, gui_project):
280280
)
281281

282282
if isinstance(self.big_widget, workspace_widgets.StateReprViewer):
283-
self.state_repr_viewer= self.big_widget
283+
self.state_repr_viewer = self.big_widget
284284

285285
"""
286286
big_widget_classes = \

garlicsim_wx/py2exe_cruft/setup_extension.py

Lines changed: 70 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import py2exe
1818
import imp
1919
import sys, os.path, glob
20+
import pkgutil
2021

2122
# This module is meant to be imported from the garlicsim_wx setup.py file, and
2223
# should not be used otherwise:
@@ -83,6 +84,13 @@ def get_garlicsim_wx_packages():
8384

8485

8586
def get_garlicsim_data_files():
87+
'''
88+
Get garlicsim's data files.
89+
90+
This returns a list of tuples, where the second item in each tuple is a list
91+
of files and the first item is the path to which these files should be
92+
copied when doing the py2exe packaging.
93+
'''
8694
total_data_files = []
8795
for package in garlicsim_packages:
8896
path = package_to_path(package)
@@ -95,6 +103,13 @@ def get_garlicsim_data_files():
95103

96104

97105
def get_garlicsim_lib_data_files():
106+
'''
107+
Get garlicsim_lib's data files.
108+
109+
This returns a list of tuples, where the second item in each tuple is a list
110+
of files and the first item is the path to which these files should be
111+
copied when doing the py2exe packaging.
112+
'''
98113
total_data_files = []
99114
for package in garlicsim_lib_packages:
100115
path = package_to_path(package)
@@ -107,6 +122,13 @@ def get_garlicsim_lib_data_files():
107122

108123

109124
def get_garlicsim_wx_data_files():
125+
'''
126+
Get garlicsim_wx's data files.
127+
128+
This returns a list of tuples, where the second item in each tuple is a list
129+
of files and the first item is the path to which these files should be
130+
copied when doing the py2exe packaging.
131+
'''
110132
total_data_files = []
111133
for package in garlicsim_wx_packages:
112134
path = package_to_path(package)
@@ -118,6 +140,13 @@ def get_garlicsim_wx_data_files():
118140

119141

120142
def get_dlls_and_stuff():
143+
'''
144+
Get some miscellaneous files that need to be copied to py2exe_dist.
145+
146+
This returns a list of tuples, where the second item in each tuple is a list
147+
of files and the first item is the path to which these files should be
148+
copied when doing the py2exe packaging.
149+
'''
121150
total_data_files = []
122151
path_to_folder = './py2exe_cruft/dlls_and_stuff'
123152
folders_to_do = [path_to_folder]
@@ -138,12 +167,29 @@ def get_dlls_and_stuff():
138167

139168

140169
def get_all_data_files():
141-
'''For use in py2exe only.tododoc'''
170+
'''
171+
Get all the data files that need to be copied to py2exe_dist.
172+
173+
This includes the data files for the `garlicsim`, `garlicsim_lib` and
174+
`garlicsim_wx` packages, and some miscellaneous data files.
175+
176+
This returns a list of tuples, where the second item in each tuple is a list
177+
of files and the first item is the path to which these files should be
178+
copied when doing the py2exe packaging.
179+
'''
142180
return get_garlicsim_data_files() + get_garlicsim_lib_data_files() + \
143181
get_garlicsim_wx_data_files() + get_dlls_and_stuff()
144182

145183

146-
def get_all_subpackages(package_name):
184+
def get_all_submodules(package_name):
185+
'''
186+
Get all submodules of a package, recursively.
187+
188+
This includes both modules and packages.
189+
190+
For example:
191+
`get_all_subpackages('numpy') == ['numpy.core', 'numpy.random', ...]`
192+
'''
147193
return [
148194
(package_name + '.' + m) for m in
149195
setuptools.find_packages(
@@ -152,6 +198,16 @@ def get_all_subpackages(package_name):
152198
]
153199

154200

201+
def get_strict_modules(package_name):
202+
'''tododoc'''
203+
package_path = imp.find_module(package_name, sys.path)[1]
204+
return [module for (loader, module, is_package) in
205+
pkgutil.iter_modules(path, package_name + '.') if not is_package]
206+
207+
208+
# This is a list of packages that should be included in the library, with all
209+
# their subpackages. In theory, the `packages` option of py2exe should take care
210+
# of it, but it has bugs in it so we're doing this ourselves.
155211
packages_to_include_with_all_subpackages = [
156212

157213
'garlicsim', 'garlicsim_lib',
@@ -161,6 +217,7 @@ def get_all_subpackages(package_name):
161217
]
162218

163219

220+
# List of modules to be included in the library.
164221
includes = reduce(
165222
list.__add__,
166223
[get_all_subpackages(package_name) for package_name in \
@@ -169,7 +226,11 @@ def get_all_subpackages(package_name):
169226

170227

171228
py2exe_kwargs = {
229+
230+
# We're giving a less nerdy description here, because this will be shown on
231+
# the executable, where non-nerds might see it:
172232
'description': 'Pythonic framework for computer simulations',
233+
173234
'windows': [
174235
{
175236
'script': 'py2exe_cruft/GarlicSim.py',
@@ -181,25 +242,20 @@ def get_all_subpackages(package_name):
181242
]
182243
}
183244
],
184-
'zipfile': 'lib/library.zip', #tododoc: probably cancel
185245
'data_files': get_all_data_files(),
246+
247+
# We don't really have a zipfile, this is the path to the library folder:
248+
'zipfile': 'lib/library.zip',
249+
# Keep in mind that this `library.zip` filename here will simply be ignored.
250+
186251
'options': {
187252
'py2exe': {
188253
'dist_dir': 'py2exe_dist',
189-
'skip_archive': True,
190-
191-
# tododoc.Here you put packages you want py2exe to include with all
192-
# subpackages. Problem is, there's a bug in py2exe which will make
193-
# it think a non-package directory is a package if it contains a
194-
# package within it. Then it'll get listed as a package, and when
195-
# import time comes the script will fail.
196254

197-
# So there's a danger for us here: For example, we can't include
198-
# `numpy` because it has some `tests` folder which falls under this
199-
# bug.
255+
# We prefer to have all the files in a folder instead of a zip file.
256+
'skip_archive': True,
200257

201258
'includes': includes,
202-
203259
}
204260
}
205261
}

garlicsim_wx/setup.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
import py2exe_cruft.setup_extension
1919

2020

21-
# tododoc: document this module exhaustively.
22-
2321
# Automatically deleting the build directory, in case one was left over from
2422
# last time.
2523
try:
@@ -44,12 +42,12 @@ def get_garlicsim_wx_packages():
4442

4543
my_long_description = \
4644
'''\
47-
garlicsim_wx, a wxPython GUI for garlicsim.
45+
A wxPython-based GUI for garlicsim.
4846
4947
The final goal of this project is to become a fully-fledged application for
5048
working with simulations, friendly enough that it may be used by
5149
non-programmers.
52-
d'''
50+
'''
5351

5452

5553
my_classifiers = [

0 commit comments

Comments
 (0)