MCPcopy Create free account
hub / github.com/conda/constructor / create

Function create

constructor/shar.py:121–247  ·  view source on GitHub ↗
(info, verbose=False)

Source from the content-addressed store, hash-verified

119
120
121def create(info, verbose=False):
122 tmp_dir_base_path = join(dirname(info["_outpath"]), "tmp")
123 try:
124 os.makedirs(tmp_dir_base_path)
125 except Exception:
126 pass
127 tmp_dir = tempfile.mkdtemp(dir=tmp_dir_base_path)
128 preconda_write_files(info, tmp_dir)
129
130 preconda_tarball = join(tmp_dir, "preconda.tar.bz2")
131 postconda_tarball = join(tmp_dir, "postconda.tar.bz2")
132 pre_t = tarfile.open(preconda_tarball, "w:bz2")
133 post_t = tarfile.open(postconda_tarball, "w:bz2")
134 for rel_path in preconda_files:
135 pre_t.add(join(tmp_dir, rel_path), rel_path)
136
137 for env_name in info.get("_extra_envs_info", ()):
138 for rel_path in (
139 f"pkgs/envs/{env_name}/shortcuts.txt",
140 f"envs/{env_name}/conda-meta/initial-state.explicit.txt",
141 ):
142 pre_t.add(join(tmp_dir, rel_path), rel_path)
143
144 for key in "pre_install", "post_install":
145 if key in info:
146 pre_t.add(
147 info[key],
148 "pkgs/%s.sh" % key,
149 filter=make_executable if has_shebang(info[key]) else None,
150 )
151 cache_dir = join(tmp_dir, "pkgs", "cache")
152 if isdir(cache_dir):
153 for cf in os.listdir(cache_dir):
154 if cf.endswith(".json"):
155 pre_t.add(join(cache_dir, cf), "pkgs/cache/" + cf)
156
157 all_dists = info["_dists"].copy()
158 for env_data in info.get("_extra_envs_info", {}).values():
159 all_dists += env_data["_dists"]
160 all_dists = list({dist: None for dist in all_dists}) # de-duplicate
161
162 for dist in all_dists:
163 if filename_dist(dist).endswith(".conda"):
164 _dist = filename_dist(dist)[:-6]
165 elif filename_dist(dist).endswith(".tar.bz2"):
166 _dist = filename_dist(dist)[:-8]
167 record_file = join(_dist, "info", "repodata_record.json")
168 record_file_src = join(tmp_dir, "pkgs", record_file)
169 record_file_dest = join("pkgs", record_file)
170 pre_t.add(record_file_src, record_file_dest)
171 pre_t.addfile(tarinfo=tarfile.TarInfo("conda-meta/history"))
172 post_t.add(join(tmp_dir, "conda-meta", "history"), "conda-meta/history")
173
174 if os.path.exists(join(tmp_dir, "conda-meta", "frozen")):
175 post_t.add(join(tmp_dir, "conda-meta", "frozen"), "conda-meta/frozen")
176
177 if os.path.exists(join(tmp_dir, ".condarc")):
178 post_t.add(join(tmp_dir, ".condarc"), ".condarc")

Callers 1

main_buildFunction · 0.70

Calls 6

has_shebangFunction · 0.85
filename_distFunction · 0.85
copy_extra_filesFunction · 0.85
copy_conda_exeFunction · 0.85
get_headerFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected