10 import pyne._argparse
as ap
12 absexpanduser =
lambda x: os.path.abspath(os.path.expanduser(x))
18 for p
in os.environ[
'PATH'].split(
';')[::-1]:
20 files_on_path.update(os.listdir(p))
21 if 'cl.exe' in files_on_path:
23 elif 'sh.exe' in files_on_path:
24 cmake_cmd += [
'-G "MSYS Makefiles"']
25 elif 'gcc.exe' in files_on_path:
26 cmake_cmd += [
'-G "MinGW Makefiles"']
27 cmake_cmd =
' '.join(cmake_cmd)
31 if not os.path.exists(args.build_dir):
32 os.mkdir(args.build_dir)
33 elif args.clean_build:
34 shutil.rmtree(args.build_dir)
35 os.mkdir(args.build_dir)
37 root_dir = os.path.split(__file__)[0]
38 makefile = os.path.join(args.build_dir,
'Makefile')
40 if not os.path.exists(makefile):
41 rtn = subprocess.call([
'which',
'cmake'], shell=(os.name ==
'nt'))
43 sys.exit(
"CMake could not be found, "
44 "please install CMake before developing Cyclus.")
45 cmake_cmd = [
'cmake', os.path.abspath(root_dir)]
47 cmake_cmd += [
'-DCMAKE_INSTALL_PREFIX=' +
49 if args.cmake_prefix_path:
50 cmake_cmd += [
'-DCMAKE_PREFIX_PATH=' +
53 cmake_cmd += [
'-DCOIN_ROOT_DIR=' +
absexpanduser(args.coin_root)]
55 cmake_cmd += [
'-DBOOST_ROOT=' +
absexpanduser(args.boost_root)]
57 cmake_cmd += [
'-DCMAKE_BUILD_TYPE=' + args.build_type]
59 rtn = subprocess.check_call(cmake_cmd, cwd=args.build_dir,
60 shell=(os.name ==
'nt'))
64 make_cmd += [
'-j' + str(args.threads)]
65 rtn = subprocess.check_call(make_cmd, cwd=args.build_dir,
66 shell=(os.name ==
'nt'))
70 elif not args.build_only:
71 make_cmd += [
'install']
73 rtn = subprocess.check_call(make_cmd, cwd=args.build_dir,
74 shell=(os.name ==
'nt'))
77 makefile = os.path.join(args.build_dir,
'Makefile')
78 if not os.path.exists(args.build_dir)
or not os.path.exists(makefile):
79 sys.exist(
"May not uninstall Cyclus since it has not yet been built.")
80 rtn = subprocess.check_call([
'make',
'uninstall'], cwd=args.build_dir,
81 shell=(os.name ==
'nt'))
87 description =
"An installation helper script. " +\
88 "For more information, please see fuelcycle.org."
89 parser = ap.ArgumentParser(description=description)
91 build_dir =
'where to place the build directory'
92 parser.add_argument(
'--build_dir', help=build_dir, default=
'build')
95 parser.add_argument(
'--uninstall', action=
'store_true', help=uninst, default=
False)
97 clean =
'attempt to remove the build directory before building'
98 parser.add_argument(
'--clean-build', action=
'store_true', help=clean)
100 threads =
"the number of threads to use in the make step"
101 parser.add_argument(
'-j',
'--threads', type=int, help=threads)
103 prefix =
"the relative path to the installation directory"
104 parser.add_argument(
'--prefix', help=prefix, default=localdir)
106 build_only =
'only build the package, do not install'
107 parser.add_argument(
'--build-only', action=
'store_true', help=build_only)
109 test =
'run tests after building'
110 parser.add_argument(
'--test', action=
'store_true', help=test)
112 coin =
"the relative path to the Coin-OR libraries directory"
113 parser.add_argument(
'--coin_root', help=coin)
115 boost =
"the relative path to the Boost libraries directory"
116 parser.add_argument(
'--boost_root', help=boost)
118 cmake_prefix_path =
"the cmake prefix path for use with FIND_PACKAGE, " + \
119 "FIND_PATH, FIND_PROGRAM, or FIND_LIBRARY macros"
120 parser.add_argument(
'--cmake_prefix_path', help=cmake_prefix_path)
122 build_type =
"the CMAKE_BUILD_TYPE"
123 parser.add_argument(
'--build_type', help=build_type)
125 args = parser.parse_args()
131 if __name__ ==
"__main__":