diff --git a/examples/build-package/main.tf b/examples/build-package/main.tf index 2afce855..26779993 100644 --- a/examples/build-package/main.tf +++ b/examples/build-package/main.tf @@ -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" diff --git a/package.py b/package.py index 6e19846c..7ed446d8 100644 --- a/package.py +++ b/package.py @@ -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: @@ -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 diff --git a/package.tf b/package.tf index 34322514..b34515e8 100644 --- a/package.tf +++ b/package.tf @@ -40,6 +40,8 @@ data "external" "archive_prepare" { ) recreate_missing_package = var.recreate_missing_package + + pip_additional_options = jsonencode(var.pip_additional_options) } } diff --git a/variables.tf b/variables.tf index c71f68ae..c9bacabc 100644 --- a/variables.tf +++ b/variables.tf @@ -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 ############################################