2 from __future__
import print_function, unicode_literals
10 if sys.version_info[0] < 3:
11 from urllib
import urlopen
13 from urllib.request
import urlopen
18 import pyne._argparse
as ap
20 absexpanduser =
lambda x: os.path.abspath(os.path.expanduser(x))
26 for p
in os.environ[
'PATH'].split(
';')[::-1]:
28 files_on_path.update(os.listdir(p))
29 if 'cl.exe' in files_on_path:
31 elif 'sh.exe' in files_on_path:
32 cmake_cmd += [
'-G "MSYS Makefiles"']
33 elif 'gcc.exe' in files_on_path:
34 cmake_cmd += [
'-G "MinGW Makefiles"']
35 cmake_cmd =
' '.join(cmake_cmd)
38 root_dir = os.path.split(__file__)[0]
39 fname = os.path.join(root_dir,
'src',
'version.cc.in')
40 cmd =
'touch {0}'.format(fname)
41 subprocess.check_call(cmd.split(), shell=(os.name ==
'nt'))
44 if not os.path.exists(args.build_dir):
45 os.mkdir(args.build_dir)
46 elif args.clean_build:
47 shutil.rmtree(args.build_dir)
48 os.mkdir(args.build_dir)
50 root_dir = os.path.split(__file__)[0]
51 makefile = os.path.join(args.build_dir,
'Makefile')
52 on_darwin = platform.system() ==
'Darwin' 53 libext =
'.dylib' if on_darwin
else '.so' 55 if not os.path.exists(makefile):
56 rtn = subprocess.call([
'which',
'cmake'], shell=(os.name ==
'nt'))
58 sys.exit(
"CMake could not be found, " 59 "please install CMake before developing Cyclus.")
60 cmake_cmd = [
'cmake', os.path.abspath(root_dir)]
62 cmake_cmd += [
'-DCMAKE_INSTALL_PREFIX=' +
64 if args.cmake_prefix_path:
65 cmake_cmd += [
'-DCMAKE_PREFIX_PATH=' +
67 if cmake_cmd
is not None:
68 cmake_cmd += [
'-DDEFAULT_ALLOW_MILPS=' +
69 (
'TRUE' if args.allow_milps
else 'FALSE')]
71 cmake_cmd += [
'-DDEPS_ROOT_DIR=' +
absexpanduser(args.deps_root)]
73 cmake_cmd += [
'-DCOIN_ROOT_DIR=' +
absexpanduser(args.coin_root)]
75 cmake_cmd += [
'-DBOOST_ROOT=' +
absexpanduser(args.boost_root)]
77 cmake_cmd += [
'-DCYCLUS_ROOT_DIR='+
absexpanduser(args.cyclus_root)]
80 cmake_cmd += [
'-DHDF5_ROOT=' + h5root,
81 '-DHDF5_LIBRARIES={0}/lib/libhdf5{1};{0}/lib/libhdf5_hl{1}'.format(h5root, libext),
82 '-DHDF5_LIBRARY_DIRS=' + h5root +
'/lib',
83 '-DHDF5_INCLUDE_DIRS=' + h5root +
'/include',
86 cmake_cmd += [
'-DCMAKE_BUILD_TYPE=' + args.build_type]
88 cmake_cmd += [
'-DCORE_VERSION=' + args.core_version]
89 if args.D
is not None:
90 cmake_cmd += [
'-D' + x
for x
in args.D]
92 cmake_cmd += [
'-Wdev',
'--debug-output']
94 rtn = subprocess.check_call(cmake_cmd, cwd=args.build_dir,
95 shell=(os.name ==
'nt'))
105 make_cmd += [
'-j' + str(args.threads)]
106 rtn = subprocess.check_call(make_cmd, cwd=args.build_dir,
107 shell=(os.name ==
'nt'))
111 elif not args.build_only:
112 make_cmd += [
'install']
114 rtn = subprocess.check_call(make_cmd, cwd=args.build_dir,
115 shell=(os.name ==
'nt'))
118 makefile = os.path.join(args.build_dir,
'Makefile')
119 if not os.path.exists(args.build_dir)
or not os.path.exists(makefile):
120 sys.exit(
"May not uninstall Cyclus since it has not yet been built.")
121 rtn = subprocess.check_call([
'make',
'uninstall'], cwd=args.build_dir,
122 shell=(os.name ==
'nt'))
128 description =
"A Cyclus installation helper script. " +\
129 "For more information, please see cyclus.github.com." 130 parser = ap.ArgumentParser(description=description)
132 build_dir =
'where to place the build directory' 133 parser.add_argument(
'--build_dir', help=build_dir, default=
'build')
136 parser.add_argument(
'--uninstall', action=
'store_true', help=uninst, default=
False)
138 noupdate =
'do not update the hash in version.cc' 139 parser.add_argument(
'--no-update', dest=
'update', action=
'store_false',
140 help=noupdate, default=
True)
142 clean =
'attempt to remove the build directory before building' 143 parser.add_argument(
'--clean-build', action=
'store_true', help=clean)
145 threads =
"the number of threads to use in the make step" 146 parser.add_argument(
'-j',
'--threads', type=int, help=threads)
148 prefix =
"the relative path to the installation directory" 149 parser.add_argument(
'--prefix', help=prefix, default=localdir)
151 config_only =
'only configure the package, do not build or install' 152 parser.add_argument(
'--config-only', action=
'store_true', help=config_only)
154 build_only =
'only build the package, do not install' 155 parser.add_argument(
'--build-only', action=
'store_true', help=build_only)
157 test =
'run tests after building' 158 parser.add_argument(
'--test', action=
'store_true', help=test)
160 parser.add_argument(
'--allow-milps', action=
'store_true',
161 dest=
'allow_milps', default=
None,
162 help=
'Allows mixed integer linear programs by default')
163 parser.add_argument(
'--dont-allow-milps', action=
'store_false',
165 help=
"Don't Allows mixed integer linear programs " 168 deps =
"the path to the directory containing all dependencies" 169 parser.add_argument(
'--deps-root',
'--deps_root', help=deps,
170 default=
None, dest=
'deps_root')
172 coin =
"the relative path to the Coin-OR libraries directory" 173 parser.add_argument(
'--coin-root',
'--coin_root', help=coin)
175 boost =
"the relative path to the Boost libraries directory" 176 parser.add_argument(
'--boost_root', help=boost)
178 hdf5 =
"the path to the HDF5 libraries directory" 179 parser.add_argument(
'--hdf5_root', help=hdf5)
181 cyclus =
"the relative path to Cyclus installation directory" 182 parser.add_argument(
'--cyclus-root',
'--cyclus_root', help=cyclus)
184 cmake_prefix_path =
"the cmake prefix path for use with FIND_PACKAGE, " + \
185 "FIND_PATH, FIND_PROGRAM, or FIND_LIBRARY macros" 186 parser.add_argument(
'--cmake_prefix_path', help=cmake_prefix_path)
188 build_type =
"the CMAKE_BUILD_TYPE" 189 parser.add_argument(
'--build-type',
'--build_type', help=build_type)
191 parser.add_argument(
'--core-version', dest=
'core_version', default=
None,
192 help=
'Sets the core version number.')
194 parser.add_argument(
'-D', metavar=
'VAR', action=
'append',
195 help=
'Set enviornment variable(s).')
196 parser.add_argument(
'--cmake-debug', action=
'store_true', default=
False,
197 dest=
'cmake_debug', help=
'puts CMake itself in a debug mode ' 198 'when dealing with build system issues.')
200 args = parser.parse_args()
202 if args.deps_root
is not None:
203 roots = [
'coin_root',
'boost_root',
'hdf5_root',
'cyclus_root']
205 if not getattr(args, name,
None):
206 setattr(args, name, args.deps_root)
213 if __name__ ==
"__main__":
def check_windows_cmake(cmake_cmd)
def uninstall_cyclus(args)