Created
June 8, 2019 17:58
-
-
Save sodre/724a7cd226572154bb4ad02ac4bef50e to your computer and use it in GitHub Desktop.
shorter version of what is needed for new conda-metapackage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# A Python function for overlaying a source directory on top of a destination dir | |
import os | |
import re | |
from conda_build.utils import merge_tree, _copy_with_shell_fallback | |
def build_absolute_paths(src, dest, dest_prefix): | |
abs_src = os.path.abspath(src) | |
abs_dest = os.path.join(dest_prefix, re.sub(r'^/+', '', dest)) | |
return abs_src, abs_dest | |
def overlay(src, dest, dest_prefix): | |
abs_src, abs_dest = build_absolute_paths(src, dest, dest_prefix) | |
if os.path.isfile(abs_src): | |
os.makedirs(os.path.dirname(abs_dest)) | |
_copy_with_shell_fallback(abs_src, abs_dest) | |
elif os.path.isdir(abs_src): | |
merge_tree(abs_src, abs_dest) | |
if __name__ == "__main__": | |
# The conda-build dir is overlaid on PREFIX/ | |
overlay("/Users/sodre/git/conda/conda-build", "/", "/tmp/tmp0") | |
# The overlay-dir.py file is copied to PREFIX/overlay-dir.py | |
overlay('overlay-dir.py', '/', '/tmp/tmp1') | |
assert(os.path.isfile('/tmp/tmp1/overlay-dir.py')) | |
# The overlay-dir.py file is copied to PREFIX/bin/overlay-dir.py | |
overlay('overlay-dir.py', '/bin/', "/tmp/tmp2") | |
assert(os.path.isfile('/tmp/tmp2/bin/overlay-dir.py')) | |
# The overlay-dir.py file is copied to PREFIX/bin/overlay | |
overlay('overlay-dir.py', '/bin/overlay', "/tmp/tmp3") | |
assert(os.path.isfile('/tmp/tmp3/bin/overlay')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment