Lines 1-3
Link Here
|
|
|
1 |
from __future__ import division, absolute_import, print_function |
2 |
|
1 |
import os |
3 |
import os |
2 |
import re |
4 |
import re |
3 |
import sys |
5 |
import sys |
Lines 165-171
Link Here
|
165 |
fid = open(config_file) |
167 |
fid = open(config_file) |
166 |
mathlibs = [] |
168 |
mathlibs = [] |
167 |
s = '#define MATHLIB' |
169 |
s = '#define MATHLIB' |
168 |
for line in fid.readlines(): |
170 |
for line in fid: |
169 |
if line.startswith(s): |
171 |
if line.startswith(s): |
170 |
value = line[len(s):].strip() |
172 |
value = line[len(s):].strip() |
171 |
if value: |
173 |
if value: |
Lines 218-225
Link Here
|
218 |
else: |
220 |
else: |
219 |
if include_non_existing: |
221 |
if include_non_existing: |
220 |
new_paths.append(n) |
222 |
new_paths.append(n) |
221 |
print('could not resolve pattern in %r: %r' \ |
223 |
print('could not resolve pattern in %r: %r' % |
222 |
% (local_path,n)) |
224 |
(local_path,n)) |
223 |
else: |
225 |
else: |
224 |
n2 = njoin(local_path,n) |
226 |
n2 = njoin(local_path,n) |
225 |
if os.path.exists(n2): |
227 |
if os.path.exists(n2): |
Lines 230-237
Link Here
|
230 |
elif include_non_existing: |
232 |
elif include_non_existing: |
231 |
new_paths.append(n) |
233 |
new_paths.append(n) |
232 |
if not os.path.exists(n): |
234 |
if not os.path.exists(n): |
233 |
print('non-existing path in %r: %r' \ |
235 |
print('non-existing path in %r: %r' % |
234 |
% (local_path,n)) |
236 |
(local_path,n)) |
235 |
|
237 |
|
236 |
elif is_sequence(n): |
238 |
elif is_sequence(n): |
237 |
new_paths.extend(_fix_paths(n,local_path,include_non_existing)) |
239 |
new_paths.extend(_fix_paths(n,local_path,include_non_existing)) |
Lines 249-259
Link Here
|
249 |
|
251 |
|
250 |
_temporary_directory = None |
252 |
_temporary_directory = None |
251 |
def clean_up_temporary_directory(): |
253 |
def clean_up_temporary_directory(): |
252 |
from numpy.distutils import log |
|
|
253 |
global _temporary_directory |
254 |
global _temporary_directory |
254 |
if not _temporary_directory: |
255 |
if not _temporary_directory: |
255 |
return |
256 |
return |
256 |
log.debug('removing %s', _temporary_directory) |
|
|
257 |
try: |
257 |
try: |
258 |
shutil.rmtree(_temporary_directory) |
258 |
shutil.rmtree(_temporary_directory) |
259 |
except OSError: |
259 |
except OSError: |
Lines 394-401
Link Here
|
394 |
return [] |
394 |
return [] |
395 |
modules = [] |
395 |
modules = [] |
396 |
f = open(source,'r') |
396 |
f = open(source,'r') |
397 |
f_readlines = getattr(f,'xreadlines',f.readlines) |
397 |
for line in f: |
398 |
for line in f_readlines(): |
|
|
399 |
m = f90_module_name_match(line) |
398 |
m = f90_module_name_match(line) |
400 |
if m: |
399 |
if m: |
401 |
name = m.group('name') |
400 |
name = m.group('name') |
Lines 557-563
Link Here
|
557 |
def get_ext_source_files(ext): |
556 |
def get_ext_source_files(ext): |
558 |
# Get sources and any include files in the same directory. |
557 |
# Get sources and any include files in the same directory. |
559 |
filenames = [] |
558 |
filenames = [] |
560 |
sources = filter(is_string, ext.sources) |
559 |
sources = [_m for _m in ext.sources if is_string(_m)] |
561 |
filenames.extend(sources) |
560 |
filenames.extend(sources) |
562 |
filenames.extend(get_dependencies(sources)) |
561 |
filenames.extend(get_dependencies(sources)) |
563 |
for d in ext.depends: |
562 |
for d in ext.depends: |
Lines 568-580
Link Here
|
568 |
return filenames |
567 |
return filenames |
569 |
|
568 |
|
570 |
def get_script_files(scripts): |
569 |
def get_script_files(scripts): |
571 |
scripts = filter(is_string, scripts) |
570 |
scripts = [_m for _m in scripts if is_string(_m)] |
572 |
return scripts |
571 |
return scripts |
573 |
|
572 |
|
574 |
def get_lib_source_files(lib): |
573 |
def get_lib_source_files(lib): |
575 |
filenames = [] |
574 |
filenames = [] |
576 |
sources = lib[1].get('sources',[]) |
575 |
sources = lib[1].get('sources',[]) |
577 |
sources = filter(is_string, sources) |
576 |
sources = [_m for _m in sources if is_string(_m)] |
578 |
filenames.extend(sources) |
577 |
filenames.extend(sources) |
579 |
filenames.extend(get_dependencies(sources)) |
578 |
filenames.extend(get_dependencies(sources)) |
580 |
depends = lib[1].get('depends',[]) |
579 |
depends = lib[1].get('depends',[]) |
Lines 606-616
Link Here
|
606 |
Linux, but not on OS X. |
605 |
Linux, but not on OS X. |
607 |
|
606 |
|
608 |
""" |
607 |
""" |
609 |
so_ext = distutils.sysconfig.get_config_var('SO') or '' |
608 |
confvars = distutils.sysconfig.get_config_vars() |
610 |
# fix long extension for Python >=3.2, see PEP 3149. |
609 |
# SO is deprecated in 3.3.1, use EXT_SUFFIX instead |
611 |
if (not is_python_ext) and 'SOABI' in distutils.sysconfig.get_config_vars(): |
610 |
so_ext = confvars.get('EXT_SUFFIX', None) |
612 |
# Does nothing unless SOABI config var exists |
611 |
if so_ext is None: |
613 |
so_ext = so_ext.replace('.' + distutils.sysconfig.get_config_var('SOABI'), '', 1) |
612 |
so_ext = confvars.get('SO', '') |
|
|
613 |
|
614 |
if not is_python_ext: |
615 |
# hardcode known values, config vars (including SHLIB_SUFFIX) are |
616 |
# unreliable (see #3182) |
617 |
# darwin, windows and debug linux are wrong in 3.3.1 and older |
618 |
if (sys.platform.startswith('linux') or |
619 |
sys.platform.startswith('gnukfreebsd')): |
620 |
so_ext = '.so' |
621 |
elif sys.platform.startswith('darwin'): |
622 |
so_ext = '.dylib' |
623 |
elif sys.platform.startswith('win'): |
624 |
so_ext = '.dll' |
625 |
else: |
626 |
# fall back to config vars for unknown platforms |
627 |
# fix long extension for Python >=3.2, see PEP 3149. |
628 |
if 'SOABI' in confvars: |
629 |
# Does nothing unless SOABI config var exists |
630 |
so_ext = so_ext.replace('.' + confvars.get('SOABI'), '', 1) |
614 |
|
631 |
|
615 |
return so_ext |
632 |
return so_ext |
616 |
|
633 |
|
Lines 628-634
Link Here
|
628 |
if os.path.isfile(s): |
645 |
if os.path.isfile(s): |
629 |
filenames.append(s) |
646 |
filenames.append(s) |
630 |
else: |
647 |
else: |
631 |
print('Not existing data file:',s) |
648 |
print('Not existing data file:', s) |
632 |
else: |
649 |
else: |
633 |
raise TypeError(repr(s)) |
650 |
raise TypeError(repr(s)) |
634 |
return filenames |
651 |
return filenames |
Lines 647-702
Link Here
|
647 |
frame = frame.f_back |
664 |
frame = frame.f_back |
648 |
return frame |
665 |
return frame |
649 |
|
666 |
|
650 |
class SconsInfo(object): |
|
|
651 |
""" |
652 |
Container object holding build info for building a package with scons. |
653 |
|
654 |
Parameters |
655 |
---------- |
656 |
scons_path : str or None |
657 |
Path to scons script, relative to the directory of setup.py. |
658 |
If None, no scons script is specified. This can be useful to add only |
659 |
pre- and post-hooks to a configuration. |
660 |
parent_name : str or None |
661 |
Name of the parent package (for example "numpy"). |
662 |
pre_hook : sequence of callables or None |
663 |
Callables that are executed before scons is invoked. |
664 |
Each callable should be defined as ``callable(*args, **kw)``. |
665 |
post_hook : sequence of callables or None |
666 |
Callables that are executed after scons is invoked. |
667 |
Each callable should be defined as ``callable(*args, **kw)``. |
668 |
source_files : list of str or None |
669 |
List of paths to source files, relative to the directory of setup.py. |
670 |
pkg_path : str or None |
671 |
Path to the package for which the `SconsInfo` instance holds the |
672 |
build info, relative to the directory of setup.py. |
673 |
|
674 |
Notes |
675 |
----- |
676 |
All parameters are available as attributes of a `SconsInfo` instance. |
677 |
|
678 |
""" |
679 |
def __init__(self, scons_path, parent_name, pre_hook, |
680 |
post_hook, source_files, pkg_path): |
681 |
self.scons_path = scons_path |
682 |
self.parent_name = parent_name |
683 |
self.pre_hook = pre_hook |
684 |
self.post_hook = post_hook |
685 |
self.source_files = source_files |
686 |
if pkg_path: |
687 |
self.pkg_path = pkg_path |
688 |
else: |
689 |
if scons_path: |
690 |
self.pkg_path = os.path.dirname(scons_path) |
691 |
else: |
692 |
self.pkg_path = '' |
693 |
|
667 |
|
694 |
###################### |
668 |
###################### |
695 |
|
669 |
|
696 |
class Configuration(object): |
670 |
class Configuration(object): |
697 |
|
671 |
|
698 |
_list_keys = ['packages', 'ext_modules', 'data_files', 'include_dirs', |
672 |
_list_keys = ['packages', 'ext_modules', 'data_files', 'include_dirs', |
699 |
'libraries', 'headers', 'scripts', 'py_modules', 'scons_data', |
673 |
'libraries', 'headers', 'scripts', 'py_modules', |
700 |
'installed_libraries'] |
674 |
'installed_libraries'] |
701 |
_dict_keys = ['package_dir', 'installed_pkg_config'] |
675 |
_dict_keys = ['package_dir', 'installed_pkg_config'] |
702 |
_extra_keys = ['name', 'version'] |
676 |
_extra_keys = ['name', 'version'] |
Lines 853-859
Link Here
|
853 |
caller_level = 1): |
827 |
caller_level = 1): |
854 |
l = subpackage_name.split('.') |
828 |
l = subpackage_name.split('.') |
855 |
subpackage_path = njoin([self.local_path]+l) |
829 |
subpackage_path = njoin([self.local_path]+l) |
856 |
dirs = filter(os.path.isdir,glob.glob(subpackage_path)) |
830 |
dirs = [_m for _m in glob.glob(subpackage_path) if os.path.isdir(_m)] |
857 |
config_list = [] |
831 |
config_list = [] |
858 |
for d in dirs: |
832 |
for d in dirs: |
859 |
if not os.path.isfile(njoin(d,'__init__.py')): |
833 |
if not os.path.isfile(njoin(d,'__init__.py')): |
Lines 895-901
Link Here
|
895 |
pn = dot_join(*([parent_name] + subpackage_name.split('.')[:-1])) |
869 |
pn = dot_join(*([parent_name] + subpackage_name.split('.')[:-1])) |
896 |
args = (pn,) |
870 |
args = (pn,) |
897 |
def fix_args_py2(args): |
871 |
def fix_args_py2(args): |
898 |
if setup_module.configuration.func_code.co_argcount > 1: |
872 |
if setup_module.configuration.__code__.co_argcount > 1: |
899 |
args = args + (self.top_path,) |
873 |
args = args + (self.top_path,) |
900 |
return args |
874 |
return args |
901 |
def fix_args_py3(args): |
875 |
def fix_args_py3(args): |
Lines 922-935
Link Here
|
922 |
|
896 |
|
923 |
Parameters |
897 |
Parameters |
924 |
---------- |
898 |
---------- |
925 |
subpackage_name: str,None |
899 |
subpackage_name : str or None |
926 |
Name of the subpackage to get the configuration. '*' in |
900 |
Name of the subpackage to get the configuration. '*' in |
927 |
subpackage_name is handled as a wildcard. |
901 |
subpackage_name is handled as a wildcard. |
928 |
subpackage_path: str |
902 |
subpackage_path : str |
929 |
If None, then the path is assumed to be the local path plus the |
903 |
If None, then the path is assumed to be the local path plus the |
930 |
subpackage_name. If a setup.py file is not found in the |
904 |
subpackage_name. If a setup.py file is not found in the |
931 |
subpackage_path, then a default configuration is used. |
905 |
subpackage_path, then a default configuration is used. |
932 |
parent_name: str |
906 |
parent_name : str |
933 |
Parent name. |
907 |
Parent name. |
934 |
""" |
908 |
""" |
935 |
if subpackage_name is None: |
909 |
if subpackage_name is None: |
Lines 985-997
Link Here
|
985 |
|
959 |
|
986 |
Parameters |
960 |
Parameters |
987 |
---------- |
961 |
---------- |
988 |
subpackage_name: str |
962 |
subpackage_name : str |
989 |
name of the subpackage |
963 |
name of the subpackage |
990 |
subpackage_path: str |
964 |
subpackage_path : str |
991 |
if given, the subpackage path such as the subpackage is in |
965 |
if given, the subpackage path such as the subpackage is in |
992 |
subpackage_path / subpackage_name. If None,the subpackage is |
966 |
subpackage_path / subpackage_name. If None,the subpackage is |
993 |
assumed to be located in the local path / subpackage_name. |
967 |
assumed to be located in the local path / subpackage_name. |
994 |
standalone: bool |
968 |
standalone : bool |
995 |
""" |
969 |
""" |
996 |
|
970 |
|
997 |
if standalone: |
971 |
if standalone: |
Lines 1029-1038
Link Here
|
1029 |
|
1003 |
|
1030 |
Parameters |
1004 |
Parameters |
1031 |
---------- |
1005 |
---------- |
1032 |
data_path: seq,str |
1006 |
data_path : seq or str |
1033 |
Argument can be either |
1007 |
Argument can be either |
1034 |
|
1008 |
|
1035 |
* 2-sequence (<datadir suffix>,<path to data directory>) |
1009 |
* 2-sequence (<datadir suffix>, <path to data directory>) |
1036 |
* path to data directory where python datadir suffix defaults |
1010 |
* path to data directory where python datadir suffix defaults |
1037 |
to package dir. |
1011 |
to package dir. |
1038 |
|
1012 |
|
Lines 1091-1104
Link Here
|
1091 |
pattern_list = allpath(d).split(os.sep) |
1065 |
pattern_list = allpath(d).split(os.sep) |
1092 |
pattern_list.reverse() |
1066 |
pattern_list.reverse() |
1093 |
# /a/*//b/ -> /a/*/b |
1067 |
# /a/*//b/ -> /a/*/b |
1094 |
rl = range(len(pattern_list)-1); rl.reverse() |
1068 |
rl = list(range(len(pattern_list)-1)); rl.reverse() |
1095 |
for i in rl: |
1069 |
for i in rl: |
1096 |
if not pattern_list[i]: |
1070 |
if not pattern_list[i]: |
1097 |
del pattern_list[i] |
1071 |
del pattern_list[i] |
1098 |
# |
1072 |
# |
1099 |
for path in paths: |
1073 |
for path in paths: |
1100 |
if not os.path.isdir(path): |
1074 |
if not os.path.isdir(path): |
1101 |
print('Not a directory, skipping',path) |
1075 |
print('Not a directory, skipping', path) |
1102 |
continue |
1076 |
continue |
1103 |
rpath = rel_path(path, self.local_path) |
1077 |
rpath = rel_path(path, self.local_path) |
1104 |
path_list = rpath.split(os.sep) |
1078 |
path_list = rpath.split(os.sep) |
Lines 1151-1157
Link Here
|
1151 |
|
1125 |
|
1152 |
Parameters |
1126 |
Parameters |
1153 |
---------- |
1127 |
---------- |
1154 |
files: sequence |
1128 |
files : sequence |
1155 |
Argument(s) can be either |
1129 |
Argument(s) can be either |
1156 |
|
1130 |
|
1157 |
* 2-sequence (<datadir prefix>,<path to data file(s)>) |
1131 |
* 2-sequence (<datadir prefix>,<path to data file(s)>) |
Lines 1330-1336
Link Here
|
1330 |
|
1304 |
|
1331 |
Parameters |
1305 |
Parameters |
1332 |
---------- |
1306 |
---------- |
1333 |
files: str, seq |
1307 |
files : str or seq |
1334 |
Argument(s) can be either: |
1308 |
Argument(s) can be either: |
1335 |
|
1309 |
|
1336 |
* 2-sequence (<includedir suffix>,<path to header file(s)>) |
1310 |
* 2-sequence (<includedir suffix>,<path to header file(s)>) |
Lines 1385-1393
Link Here
|
1385 |
|
1359 |
|
1386 |
Parameters |
1360 |
Parameters |
1387 |
---------- |
1361 |
---------- |
1388 |
name: str |
1362 |
name : str |
1389 |
name of the extension |
1363 |
name of the extension |
1390 |
sources: seq |
1364 |
sources : seq |
1391 |
list of the sources. The list of sources may contain functions |
1365 |
list of the sources. The list of sources may contain functions |
1392 |
(called source generators) which must take an extension instance |
1366 |
(called source generators) which must take an extension instance |
1393 |
and a build directory as inputs and return a source file or list of |
1367 |
and a build directory as inputs and return a source file or list of |
Lines 1395-1422
Link Here
|
1395 |
generated. If the Extension instance has no sources after |
1369 |
generated. If the Extension instance has no sources after |
1396 |
processing all source generators, then no extension module is |
1370 |
processing all source generators, then no extension module is |
1397 |
built. |
1371 |
built. |
1398 |
include_dirs: |
1372 |
include_dirs : |
1399 |
define_macros: |
1373 |
define_macros : |
1400 |
undef_macros: |
1374 |
undef_macros : |
1401 |
library_dirs: |
1375 |
library_dirs : |
1402 |
libraries: |
1376 |
libraries : |
1403 |
runtime_library_dirs: |
1377 |
runtime_library_dirs : |
1404 |
extra_objects: |
1378 |
extra_objects : |
1405 |
extra_compile_args: |
1379 |
extra_compile_args : |
1406 |
extra_link_args: |
1380 |
extra_link_args : |
1407 |
extra_f77_compile_args: |
1381 |
extra_f77_compile_args : |
1408 |
extra_f90_compile_args: |
1382 |
extra_f90_compile_args : |
1409 |
export_symbols: |
1383 |
export_symbols : |
1410 |
swig_opts: |
1384 |
swig_opts : |
1411 |
depends: |
1385 |
depends : |
1412 |
The depends list contains paths to files or directories that the |
1386 |
The depends list contains paths to files or directories that the |
1413 |
sources of the extension module depend on. If any path in the |
1387 |
sources of the extension module depend on. If any path in the |
1414 |
depends list is newer than the extension module, then the module |
1388 |
depends list is newer than the extension module, then the module |
1415 |
will be rebuilt. |
1389 |
will be rebuilt. |
1416 |
language: |
1390 |
language : |
1417 |
f2py_options: |
1391 |
f2py_options : |
1418 |
module_dirs: |
1392 |
module_dirs : |
1419 |
extra_info: dict,list |
1393 |
extra_info : dict or list |
1420 |
dict or list of dict of keywords to be appended to keywords. |
1394 |
dict or list of dict of keywords to be appended to keywords. |
1421 |
|
1395 |
|
1422 |
Notes |
1396 |
Notes |
Lines 1653-1717
Link Here
|
1653 |
self.installed_pkg_config[self.name] = [(template, install_dir, |
1627 |
self.installed_pkg_config[self.name] = [(template, install_dir, |
1654 |
subst_dict)] |
1628 |
subst_dict)] |
1655 |
|
1629 |
|
1656 |
def add_scons_installed_library(self, name, install_dir): |
|
|
1657 |
""" |
1658 |
Add a scons-built installable library to distutils. |
1659 |
|
1660 |
Parameters |
1661 |
---------- |
1662 |
name : str |
1663 |
The name of the library. |
1664 |
install_dir : str |
1665 |
Path to install the library, relative to the current sub-package. |
1666 |
|
1667 |
""" |
1668 |
install_dir = os.path.join(self.package_path, install_dir) |
1669 |
self.installed_libraries.append(InstallableLib(name, {}, install_dir)) |
1670 |
|
1671 |
def add_sconscript(self, sconscript, subpackage_path=None, |
1672 |
standalone = False, pre_hook = None, |
1673 |
post_hook = None, source_files = None, package_path=None): |
1674 |
"""Add a sconscript to configuration. |
1675 |
|
1676 |
pre_hook and post hook should be sequences of callable, which will be |
1677 |
use before and after executing scons. The callable should be defined as |
1678 |
callable(*args, **kw). It is ugly, but well, hooks are ugly anyway... |
1679 |
|
1680 |
sconscript can be None, which can be useful to add only post/pre |
1681 |
hooks.""" |
1682 |
if standalone: |
1683 |
parent_name = None |
1684 |
else: |
1685 |
parent_name = self.name |
1686 |
|
1687 |
dist = self.get_distribution() |
1688 |
# Convert the sconscript name to a relative filename (relative from top |
1689 |
# setup.py's directory) |
1690 |
fullsconsname = self.paths(sconscript)[0] |
1691 |
|
1692 |
# XXX: Think about a way to automatically register source files from |
1693 |
# scons... |
1694 |
full_source_files = [] |
1695 |
if source_files: |
1696 |
full_source_files.extend([self.paths(i)[0] for i in source_files]) |
1697 |
|
1698 |
scons_info = SconsInfo(fullsconsname, parent_name, |
1699 |
pre_hook, post_hook, |
1700 |
full_source_files, package_path) |
1701 |
if dist is not None: |
1702 |
if dist.scons_data is None: |
1703 |
dist.scons_data = [] |
1704 |
dist.scons_data.append(scons_info) |
1705 |
self.warn('distutils distribution has been initialized,'\ |
1706 |
' it may be too late to add a subpackage '+ subpackage_name) |
1707 |
# XXX: we add a fake extension, to correctly initialize some |
1708 |
# options in distutils command. |
1709 |
dist.add_extension('', sources = []) |
1710 |
else: |
1711 |
self.scons_data.append(scons_info) |
1712 |
# XXX: we add a fake extension, to correctly initialize some |
1713 |
# options in distutils command. |
1714 |
self.add_extension('', sources = []) |
1715 |
|
1630 |
|
1716 |
def add_scripts(self,*files): |
1631 |
def add_scripts(self,*files): |
1717 |
"""Add scripts to configuration. |
1632 |
"""Add scripts to configuration. |
Lines 2086-2096
Link Here
|
2086 |
""" |
2001 |
""" |
2087 |
self.py_modules.append((self.name,name,generate_config_py)) |
2002 |
self.py_modules.append((self.name,name,generate_config_py)) |
2088 |
|
2003 |
|
2089 |
def scons_make_config_py(self, name = '__config__'): |
|
|
2090 |
"""Generate package __config__.py file containing system_info |
2091 |
information used during building the package. |
2092 |
""" |
2093 |
self.py_modules.append((self.name, name, scons_generate_config_py)) |
2094 |
|
2004 |
|
2095 |
def get_info(self,*names): |
2005 |
def get_info(self,*names): |
2096 |
"""Get resources information. |
2006 |
"""Get resources information. |
Lines 2098-2104
Link Here
|
2098 |
Return information (from system_info.get_info) for all of the names in |
2008 |
Return information (from system_info.get_info) for all of the names in |
2099 |
the argument list in a single dictionary. |
2009 |
the argument list in a single dictionary. |
2100 |
""" |
2010 |
""" |
2101 |
from system_info import get_info, dict_append |
2011 |
from .system_info import get_info, dict_append |
2102 |
info_dict = {} |
2012 |
info_dict = {} |
2103 |
for a in names: |
2013 |
for a in names: |
2104 |
dict_append(info_dict,**get_info(a)) |
2014 |
dict_append(info_dict,**get_info(a)) |
Lines 2233-2289
Link Here
|
2233 |
return info |
2143 |
return info |
2234 |
|
2144 |
|
2235 |
def is_bootstrapping(): |
2145 |
def is_bootstrapping(): |
2236 |
import __builtin__ |
2146 |
if sys.version_info[0] >= 3: |
|
|
2147 |
import builtins |
2148 |
else: |
2149 |
import __builtin__ as builtins |
2150 |
|
2237 |
try: |
2151 |
try: |
2238 |
__builtin__.__NUMPY_SETUP__ |
2152 |
builtins.__NUMPY_SETUP__ |
2239 |
return True |
2153 |
return True |
2240 |
except AttributeError: |
2154 |
except AttributeError: |
2241 |
return False |
2155 |
return False |
2242 |
__NUMPY_SETUP__ = False |
2156 |
__NUMPY_SETUP__ = False |
2243 |
|
2157 |
|
2244 |
def scons_generate_config_py(target): |
|
|
2245 |
"""generate config.py file containing system_info information |
2246 |
used during building the package. |
2247 |
|
2248 |
usage: |
2249 |
config['py_modules'].append((packagename, '__config__',generate_config_py)) |
2250 |
""" |
2251 |
from distutils.dir_util import mkpath |
2252 |
from numscons import get_scons_configres_dir, get_scons_configres_filename |
2253 |
d = {} |
2254 |
mkpath(os.path.dirname(target)) |
2255 |
f = open(target, 'w') |
2256 |
f.write('# this file is generated by %s\n' % (os.path.abspath(sys.argv[0]))) |
2257 |
f.write('# it contains system_info results at the time of building this package.\n') |
2258 |
f.write('__all__ = ["show"]\n\n') |
2259 |
confdir = get_scons_configres_dir() |
2260 |
confilename = get_scons_configres_filename() |
2261 |
for root, dirs, files in os.walk(confdir): |
2262 |
if files: |
2263 |
file = os.path.join(root, confilename) |
2264 |
assert root.startswith(confdir) |
2265 |
pkg_name = '.'.join(root[len(confdir)+1:].split(os.sep)) |
2266 |
fid = open(file, 'r') |
2267 |
try: |
2268 |
cnt = fid.read() |
2269 |
d[pkg_name] = eval(cnt) |
2270 |
finally: |
2271 |
fid.close() |
2272 |
# d is a dictionary whose keys are package names, and values the |
2273 |
# corresponding configuration. Each configuration is itself a dictionary |
2274 |
# (lib : libinfo) |
2275 |
f.write('_config = %s\n' % d) |
2276 |
f.write(r''' |
2277 |
def show(): |
2278 |
for pkg, config in _config.items(): |
2279 |
print("package %s configuration:" % pkg) |
2280 |
for lib, libc in config.items(): |
2281 |
print(' %s' % lib) |
2282 |
for line in libc.split('\n'): |
2283 |
print('\t%s' % line) |
2284 |
''') |
2285 |
f.close() |
2286 |
return target |
2287 |
|
2158 |
|
2288 |
######################### |
2159 |
######################### |
2289 |
|
2160 |
|