Skip to content

add support for downloading python dependancies using urls #10986

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
14 changes: 11 additions & 3 deletions localstack-core/localstack/packages/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,9 @@ class PythonPackageInstaller(PackageInstaller):
normalized_name: str
"""Normalized package name according to PEP440."""

def __init__(self, name: str, version: str, *args, **kwargs):
def __init__(self, name: str, version: str, package_url: str = None, *args, **kwargs):
super().__init__(name, version, *args, **kwargs)
self.package_url = package_url
self.normalized_name = self._normalize_package_name(name)

def _normalize_package_name(self, name: str):
Expand Down Expand Up @@ -289,8 +290,15 @@ def _install(self, target: InstallTarget) -> None:
venv = self._get_venv(target)
python_bin = os.path.join(venv.venv_dir, "bin/python")

# run pip via the python binary of the venv
run([python_bin, "-m", "pip", "install", f"{self.name}=={self.version}"], print_error=False)
if self.package_url:
# install the package from a custom package URL
run([python_bin, "-m", "pip", "install", self.package_url], print_error=False)
else:
# run pip via the python binary of the venv
run(
[python_bin, "-m", "pip", "install", f"{self.name}=={self.version}"],
print_error=False,
)

def _setup_existing_installation(self, target: InstallTarget) -> None:
"""If the venv is already present, it just needs to be initialized once."""
Expand Down
Loading