kopia lustrzana https://github.com/jupyterhub/repo2docker
Simplify relative path handling
rodzic
3e1863cd0a
commit
4a9f4a5594
|
@ -46,20 +46,19 @@ def freeze(env_file, frozen_file):
|
||||||
Result will be stored in frozen_file
|
Result will be stored in frozen_file
|
||||||
"""
|
"""
|
||||||
frozen_dest = HERE / frozen_file
|
frozen_dest = HERE / frozen_file
|
||||||
|
|
||||||
if frozen_dest.exists():
|
if frozen_dest.exists():
|
||||||
with frozen_dest.open('r') as f:
|
with frozen_dest.open('r') as f:
|
||||||
line = f.readline()
|
line = f.readline()
|
||||||
if 'GENERATED' not in line:
|
if 'GENERATED' not in line:
|
||||||
print(f"{frozen_file} not autogenerated, not refreezing")
|
print(f"{frozen_file.relative_to(HERE)} not autogenerated, not refreezing")
|
||||||
return
|
return
|
||||||
print(f"Freezing {env_file} -> {frozen_file}")
|
print(f"Freezing {env_file} -> {frozen_file}")
|
||||||
|
|
||||||
with frozen_dest.open('w') as f:
|
with frozen_dest.open('w') as f:
|
||||||
f.write(f"# AUTO GENERATED FROM {env_file}, DO NOT MANUALLY MODIFY\n")
|
f.write(f"# AUTO GENERATED FROM {env_file.relative_to(HERE)}, DO NOT MANUALLY MODIFY\n")
|
||||||
f.write(f"# Frozen on {datetime.utcnow():%Y-%m-%d %H:%M:%S UTC}\n")
|
f.write(f"# Frozen on {datetime.utcnow():%Y-%m-%d %H:%M:%S UTC}\n")
|
||||||
|
|
||||||
env_file_in_container = env_file.relative_to(HERE)
|
|
||||||
frozen_file_in_container = frozen_file.relative_to(HERE)
|
|
||||||
check_call([
|
check_call([
|
||||||
'docker',
|
'docker',
|
||||||
'run',
|
'run',
|
||||||
|
@ -73,11 +72,11 @@ def freeze(env_file, frozen_file):
|
||||||
f"conda install -yq conda={CONDA_VERSION}",
|
f"conda install -yq conda={CONDA_VERSION}",
|
||||||
'conda config --add channels conda-forge',
|
'conda config --add channels conda-forge',
|
||||||
'conda config --system --set auto_update_conda false',
|
'conda config --system --set auto_update_conda false',
|
||||||
f"conda env create -v -f /r2d/{env_file_in_container} -n r2d",
|
f"conda env create -v -f /r2d/{env_file.relative_to(HERE)} -n r2d",
|
||||||
# add conda-forge broken channel as lowest priority in case
|
# add conda-forge broken channel as lowest priority in case
|
||||||
# any of our frozen packages are marked as broken after freezing
|
# any of our frozen packages are marked as broken after freezing
|
||||||
'conda config --append channels conda-forge/label/broken',
|
'conda config --append channels conda-forge/label/broken',
|
||||||
f"conda env export -n r2d >> /r2d/{frozen_file_in_container}",
|
f"conda env export -n r2d >> /r2d/{frozen_file.relative_to(HERE)}",
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
@ -102,7 +101,7 @@ def set_python(py_env_file, py):
|
||||||
raise ValueError(f"python dependency not found in {env['dependencies']}")
|
raise ValueError(f"python dependency not found in {env['dependencies']}")
|
||||||
# update python dependency
|
# update python dependency
|
||||||
with open(py_env_file, 'w') as f:
|
with open(py_env_file, 'w') as f:
|
||||||
f.write(f"# AUTO GENERATED FROM {ENV_FILE}, DO NOT MANUALLY MODIFY\n")
|
f.write(f"# AUTO GENERATED FROM {ENV_FILE.relative_to(HERE)}, DO NOT MANUALLY MODIFY\n")
|
||||||
f.write(f"# Generated on {datetime.utcnow():%Y-%m-%d %H:%M:%S UTC}\n")
|
f.write(f"# Generated on {datetime.utcnow():%Y-%m-%d %H:%M:%S UTC}\n")
|
||||||
yaml.dump(env, f)
|
yaml.dump(env, f)
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue