1616import setuptools
1717import py2exe
1818import imp
19- import sys , os .path , glob
19+ import sys
20+ import os .path
21+ import glob
2022import pkgutil
2123
24+
2225# This module is meant to be imported from the `garlicsim_wx` `setup.py` file,
2326# and should not be used otherwise:
2427assert any ('setup.py' in s for s in sys .argv )
2528
26- path_to_garlicsim = os .path .abspath ('../garlicsim' )
27- path_to_garlicsim_lib = os .path .abspath ('../garlicsim_lib' )
28- path_to_test_garlicsim = os .path .abspath ('../garlicsim' )
29- paths_to_add = [path_to_garlicsim , path_to_garlicsim_lib ]
29+ path_to_garlicsim = path_to_test_garlicsim = \
30+ os .path .realpath ('../garlicsim' )
31+ path_to_garlicsim_lib = path_to_test_garlicsim_lib = \
32+ os .path .realpath ('../garlicsim_lib' )
33+ paths_to_add = [path_to_garlicsim , path_to_test_garlicsim ,
34+ path_to_garlicsim_lib , path_to_test_garlicsim_lib ]
3035for path_to_add in paths_to_add :
3136 if path_to_add not in sys .path :
3237 sys .path .append (path_to_add )
3338
39+
3440def cute_find_module (module_name ):
3541 '''Find the path to a module by its name.'''
3642 current_module_name = module_name
@@ -63,8 +69,8 @@ def get_garlicsim_packages():
6369 '''
6470 Get all the packages in `garlicsim`.
6571
66- This returns an answer in the form: `['garlicsim.data_structures ',
67- 'garlicsim.bootstrap', 'garlicsim.misc', ...]`
72+ This returns an answer in the form: `['garlicsim',
73+ 'garlicsim.data_structures', 'garlicsim. bootstrap', 'garlicsim.misc', ...]`
6874 '''
6975 return ['garlicsim.' + p for p
7076 in setuptools .find_packages ('../garlicsim/garlicsim' )] + \
@@ -77,8 +83,8 @@ def get_garlicsim_lib_packages():
7783 '''
7884 Get all the packages in `garlicsim_lib`.
7985
80- This returns an answer in the form: `['garlicsim_lib.simpacks.life ',
81- 'garlicsim_lib.simpacks.prisoner', ...]`
86+ This returns an answer in the form: `['garlicsim_lib',
87+ 'garlicsim_lib.simpacks.life', 'garlicsim_lib.simpacks. prisoner', ...]`
8288 '''
8389 return ['garlicsim_lib.' + p for p
8490 in setuptools .find_packages ('../garlicsim_lib/garlicsim_lib' )] + \
@@ -91,7 +97,7 @@ def get_garlicsim_wx_packages():
9197 '''
9298 Get all the packages in `garlicsim_wx`.
9399
94- This returns an answer in the form: `['garlicsim_wx.frame',
100+ This returns an answer in the form: `['garlicsim_wx', 'garlicsim_wx .frame',
95101 'garlicsim_wx.widgets', 'garlicsim_wx.misc', ...]`
96102 '''
97103 return ['garlicsim_wx.' + p for p
@@ -105,8 +111,8 @@ def get_test_garlicsim_packages():
105111 '''
106112 Get all the packages in `test_garlicsim`.
107113
108- This returns an answer in the form: `['test_garlicsim.data_structures',
109- ' test_garlicsim.bootstrap ', 'test_garlicsim.misc ', ...]`
114+ This returns an answer in the form: `['test_garlicsim',
115+ test_garlicsim.test_misc ', 'test_garlicsim.test_data_structures ', ...]`
110116 '''
111117 return ['test_garlicsim.' + p for p
112118 in setuptools .find_packages ('../garlicsim/test_garlicsim' )] + \
@@ -115,6 +121,38 @@ def get_test_garlicsim_packages():
115121test_garlicsim_packages = get_test_garlicsim_packages ()
116122
117123
124+ def get_test_garlicsim_lib_packages ():
125+ '''
126+ Get all the packages in `test_garlicsim_lib`.
127+
128+ This returns an answer in the form: `['test_garlicsim_lib',
129+ 'test_garlicsim_lib.test_misc', 'test_garlicsim_lib.test_scripts', ...]`
130+ '''
131+ return [
132+ 'test_garlicsim_lib.' + p for p in
133+ setuptools .find_packages ('../garlicsim_lib/test_garlicsim_lib' )
134+ ] + \
135+ ['test_garlicsim_lib' ]
136+
137+ test_garlicsim_lib_packages = get_test_garlicsim_lib_packages ()
138+
139+
140+ def get_test_garlicsim_wx_packages ():
141+ '''
142+ Get all the packages in `test_garlicsim_wx`.
143+
144+ This returns an answer in the form: `['test_garlicsim_wx',
145+ 'test_garlicsim_wx.test_misc', 'test_garlicsim_wx.test_scripts', ...]`
146+ '''
147+ return [
148+ 'test_garlicsim_wx.' + p for p
149+ in setuptools .find_packages ('../garlicsim_wx/test_garlicsim_wx' )
150+ ] + \
151+ ['test_garlicsim_wx' ]
152+
153+ test_garlicsim_wx_packages = get_test_garlicsim_wx_packages ()
154+
155+
118156def get_garlicsim_data_files ():
119157 '''
120158 Get `garlicsim`'s data files.
@@ -190,6 +228,44 @@ def get_test_garlicsim_data_files():
190228 return total_data_files
191229
192230
231+ def get_test_garlicsim_lib_data_files ():
232+ '''
233+ Get `test_garlicsim_lib`'s data files.
234+
235+ This returns a list of tuples, where the second item in each tuple is a
236+ list of files and the first item is the path to which these files should be
237+ copied when doing the `py2exe` packaging.
238+ '''
239+ total_data_files = []
240+ for package in test_garlicsim_lib_packages :
241+ path = package_to_path (package )
242+ all_files_and_folders = \
243+ glob .glob (path_to_test_garlicsim_lib + '/' + path + '/*' )
244+ data_files = [f for f in all_files_and_folders if
245+ (not '.py' in f [- 4 :]) and (not os .path .isdir (f ))]
246+ total_data_files .append (('lib/' + path , data_files ))
247+ return total_data_files
248+
249+
250+ def get_test_garlicsim_wx_data_files ():
251+ '''
252+ Get `test_garlicsim_wx`'s data files.
253+
254+ This returns a list of tuples, where the second item in each tuple is a
255+ list of files and the first item is the path to which these files should be
256+ copied when doing the `py2exe` packaging.
257+ '''
258+ total_data_files = []
259+ for package in test_garlicsim_wx_packages :
260+ path = package_to_path (package )
261+ all_files_and_folders = \
262+ glob .glob (path_to_test_garlicsim_wx + '/' + path + '/*' )
263+ data_files = [f for f in all_files_and_folders if
264+ (not '.py' in f [- 4 :]) and (not os .path .isdir (f ))]
265+ total_data_files .append (('lib/' + path , data_files ))
266+ return total_data_files
267+
268+
193269def get_garlicsim_script_files ():
194270 '''
195271 Get `garlicsim`'s script files.
@@ -240,18 +316,22 @@ def get_dlls_and_stuff():
240316
241317def get_all_data_files ():
242318 '''
243- Get all the data files that need to be copied to win_dist.
319+ Get all the data files that need to be copied to ` win_dist` .
244320
245321 This includes the data files for the `garlicsim`, `garlicsim_lib` and
246322 `garlicsim_wx` packages, and some miscellaneous data files.
247323
248- This returns a list of tuples, where the second item in each tuple is a list
249- of files and the first item is the path to which these files should be
324+ This returns a list of tuples, where the second item in each tuple is a
325+ list of files and the first item is the path to which these files should be
250326 copied when doing the py2exe packaging.
251327 '''
252- return get_garlicsim_data_files () + get_garlicsim_lib_data_files () + \
253- get_garlicsim_wx_data_files () + get_test_garlicsim_data_files () + \
254- get_garlicsim_script_files () + get_dlls_and_stuff ()
328+ return (
329+ get_garlicsim_data_files () + get_garlicsim_lib_data_files () +
330+ get_garlicsim_wx_data_files () + get_test_garlicsim_data_files () +
331+ get_test_garlicsim_lib_data_files () +
332+ get_test_garlicsim_wx_data_files () + get_garlicsim_script_files () +
333+ get_dlls_and_stuff ()
334+ )
255335
256336
257337def get_all_submodules (package_name ):
0 commit comments