Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix finding the NetCDF library in the Jigsaw build #769

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 55 additions & 36 deletions conda/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,42 +340,8 @@ def build_conda_env(env_type, recreate, mpi, conda_mpi, version,
check_call(commands, logger=logger)

if recreate or update_jigsaw:
# remove conda jigsaw and jigsaw-python
t0 = time.time()
commands = \
f'{activate_env} && ' \
f'conda remove -y --force-remove jigsaw jigsawpy'
check_call(commands, logger=logger)

commands = \
f'{activate_env} && ' \
f'cd {source_path} && ' \
f'git submodule update --init jigsaw-python'
check_call(commands, logger=logger)

print('Building JIGSAW\n')
# add build tools to deployment env, not compass env
commands = \
f'conda install -y cmake cxx-compiler && ' \
f'cd {source_path}/jigsaw-python && ' \
f'python setup.py build_external'
check_call(commands, logger=logger)

print('Installing JIGSAW and JIGSAW-Python\n')
commands = \
f'{activate_env} && ' \
f'cd {source_path}/jigsaw-python && ' \
f'python -m pip install --no-deps -e . && ' \
f'cp jigsawpy/_bin/* ${{CONDA_PREFIX}}/bin'
check_call(commands, logger=logger)

t1 = time.time()
total = t1 - t0
message = f'JIGSAW install took {total:.1f} s.'
if logger is None:
print(message)
else:
logger.info(message)
build_jigsaw(activate_env, conda_base, source_path, env_path,
logger)

# install (or reinstall) compass in edit mode
print('Installing compass\n')
Expand All @@ -394,6 +360,59 @@ def build_conda_env(env_type, recreate, mpi, conda_mpi, version,
check_call(commands, logger=logger)


def build_jigsaw(activate_env, conda_base, source_path, env_path, logger):
# remove conda jigsaw and jigsaw-python
t0 = time.time()
commands = \
f'{activate_env} && ' \
f'conda remove -y --force-remove jigsaw jigsawpy'
check_call(commands, logger=logger)

commands = \
f'{activate_env} && ' \
f'cd {source_path} && ' \
f'git submodule update --init jigsaw-python'
check_call(commands, logger=logger)

print('Building JIGSAW\n')
# add build tools to deployment env, not compass env
jigsaw_build_deps = 'cxx-compiler cmake'
netcdf_lib = f'{env_path}/lib/libnetcdf.so'
cmake_args = f'-DCMAKE_BUILD_TYPE=Release -DNETCDF_LIBRARY={netcdf_lib}'

commands = \
f'source {conda_base}/etc/profile.d/conda.sh && ' \
f'conda activate compass_bootstrap && ' \
f'conda install -y {jigsaw_build_deps} && ' \
f'cd {source_path}/jigsaw-python/external/jigsaw && ' \
f'rm -rf tmp && ' \
f'mkdir tmp && ' \
f'cd tmp && ' \
f'cmake .. {cmake_args} && ' \
f'cmake --build . --config Release --target install --parallel 4 && ' \
f'cd {source_path}/jigsaw-python && ' \
f'rm -rf jigsawpy/_bin jigsawpy/_lib && ' \
f'cp -r external/jigsaw/bin/ jigsawpy/_bin && ' \
f'cp -r external/jigsaw/lib/ jigsawpy/_lib'
check_call(commands, logger=logger)

print('Installing JIGSAW and JIGSAW-Python\n')
commands = \
f'{activate_env} && ' \
f'cd {source_path}/jigsaw-python && ' \
f'python -m pip install --no-deps -e . && ' \
f'cp jigsawpy/_bin/* ${{CONDA_PREFIX}}/bin'
check_call(commands, logger=logger)

t1 = time.time()
total = int(t1 - t0 + 0.5)
message = f'JIGSAW install took {total:.1f} s.'
if logger is None:
print(message)
else:
logger.info(message)


def get_env_vars(machine, compiler, mpilib):

if machine is None:
Expand Down
Loading