Skip to content

Commit

Permalink
Add package url factory
Browse files Browse the repository at this point in the history
  • Loading branch information
trungleduc committed Oct 14, 2024
1 parent 6b8a7a5 commit 8739c99
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions empack/pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import sys
from pathlib import Path, PosixPath, PureWindowsPath
from tempfile import TemporaryDirectory
from typing import Optional

from appdirs import user_cache_dir
from traitlets import Callable

from .filter_env import filter_env, filter_pkg, iterate_env_pkg_meta
from .micromamba_wrapper import create_environment
Expand Down Expand Up @@ -171,6 +173,7 @@ def pack_env(
compression_format=ALLOWED_FORMATS[0],
compresslevel=9,
outdir=None,
package_url_factory: Optional[Callable] = None,
):
with TemporaryDirectory() as tmp_dir:
# filter the complete environment
Expand All @@ -196,16 +199,22 @@ def pack_env(
)

base_fname = filename_base_from_meta(pkg_meta)
packages_info.append(
dict(
name=pkg_meta["name"],
version=pkg_meta["version"],
build=pkg_meta["build"],
filename_stem=base_fname,
filename=f"{base_fname}.tar.{compression_format}",
)

pkg_dict = dict(
name=pkg_meta["name"],
version=pkg_meta["version"],
build=pkg_meta["build"],
filename_stem=base_fname,
filename=f"{base_fname}.tar.{compression_format}",
)

package_url = None
if package_url_factory:
package_url = package_url_factory(pkg_dict)
if package_url is not None:
pkg_dict["url"] = package_url
packages_info.append(pkg_dict)

# save the list of packages
env_meta = {
"prefix": str(relocate_prefix),
Expand Down

0 comments on commit 8739c99

Please sign in to comment.