Skip to content
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

feat: Optionally allow list of additional CLI options to send to pip install #669

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
18 changes: 18 additions & 0 deletions examples/build-package/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,24 @@ module "package_file_with_pip_requirements" {
]
}

# Create zip-archive which contains:
# 1. A single file - index.py
# 2. Run "pip install" with specified requirements.txt with additional options CLI --only-binary=:all: --platform manylinux2014_x86_64
module "package_file_with_pip_requirements_and_pip_additional_options" {
source = "../../"

create_function = false

runtime = "python3.12"
pip_additional_options = ["-only-binary=:all:", "--platform", "manylinux2014_x86_64"]
source_path = [
"${path.module}/../fixtures/python-app1/index.py",
{
pip_requirements = "${path.module}/../fixtures/python-app1/requirements.txt"
}
]
}

# Create zip-archive which contains:
# 1. A single file - index.py
# 2. Content of directory "dir2"
Expand Down
3 changes: 2 additions & 1 deletion package.py
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,7 @@ def install_pip_requirements(query, requirements_file, tmp_dir):
artifacts_dir = query.artifacts_dir
docker = query.docker
temp_dir = query.temp_dir
pip_additional_options = query.pip_additional_options
docker_image_tag_id = None

if docker:
Expand Down Expand Up @@ -1125,7 +1126,7 @@ def install_pip_requirements(query, requirements_file, tmp_dir):
"--prefix=",
"--target=.",
"--requirement={}".format(requirements_filename),
]
] + pip_additional_options
if docker:
with_ssh_agent = docker.with_ssh_agent
pip_cache_dir = docker.docker_pip_cache
Expand Down
2 changes: 2 additions & 0 deletions package.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ data "external" "archive_prepare" {
)

recreate_missing_package = var.recreate_missing_package

pip_additional_options = jsonencode(var.pip_additional_options)
}
}

Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,12 @@ variable "trigger_on_package_timestamp" {
default = true
}

variable "pip_additional_options" {
description = "Additional options to pass to the pip install command (e.g. to platform, etc.)"
type = list(string)
default = []
}

############################################
# Lambda Advanced Logging Settings
############################################
Expand Down
Loading