Poetry dependencies installation fails using locally installed poetry
FurqanHabibi opened this issue · 4 comments
Description
Poetry dependencies installation fails when using locally installed poetry instead of docker.
Versions
- Module version [Required]:
4.7.1 - Terraform version:
1.3.5 - Provider version(s):
+ provider registry.terraform.io/hashicorp/aws v4.45.0 + provider registry.terraform.io/hashicorp/external v2.2.3 + provider registry.terraform.io/hashicorp/local v2.2.3 + provider registry.terraform.io/hashicorp/null v3.2.1 + provider registry.terraform.io/hashicorp/random v3.4.3
Reproduction Code [Required]
Steps to reproduce the behavior:
First, install poetry locally
curl -sSL https://install.python-poetry.org | python3 -
Run
terraform init
terraform apply
With the following snippet:
module "package_dir_poetry" {
source = "terraform-aws-modules/lambda/aws"
create_function = false
runtime = "python3.9"
source_path = [
{
path = "test-package",
poetry_install = true
}
]
artifacts_dir = "${path.root}/builds/package_dir_poetry/"
}
Expected behavior
Poetry dependencies installation should succeed, and the zip-archive should be created in artifacts-dir
.
Actual behavior
Poetry dependencies installation failed with the following error.
│ Error: local-exec provisioner error
│
│ with module.package_dir_poetry.null_resource.archive[0],
│ on .terraform/modules/package_dir_poetry/package.tf line 67, in resource "null_resource" "archive":
│ 67: provisioner "local-exec" {
│
│ Error running command
│ './builds/package_dir_poetry/9fcdec4410df6eb88932e46afb7ce393c313b1b1509e6c08ee539ae11e7df2e2.plan.json':
│ exit status 1. Output: zip: creating
│ './builds/package_dir_poetry/9fcdec4410df6eb88932e46afb7ce393c313b1b1509e6c08ee539ae11e7df2e2.zip'
│ archive
│ Installing python dependencies with poetry & pip:
│ ./../../../src/le-auto/poetry.lock
│ > mktemp -d terraform-aws-lambda-XXXXXXXX #
│ /var/folders/f9/tqbf3_pd5332wgcmkbzy_z0h0000gq/T/terraform-aws-lambda-58_qjbpb
│ Using poetry lock file: ./../../../src/le-auto/poetry.lock
│ Using poetry configuration file: ./../../../src/le-auto/poetry.lock
│ > cd
│ /var/folders/f9/tqbf3_pd5332wgcmkbzy_z0h0000gq/T/terraform-aws-lambda-58_qjbpb
│ > ['poetry config --no-interaction virtualenvs.create true', 'poetry config
│ --no-interaction virtualenvs.in-project true', 'poetry export --format
│ requirements.txt --output requirements.txt --with-credentials', 'python3.9 -m
│ pip install --no-compile --no-deps --prefix= --target=.
│ --requirement=requirements.txt']
│ zip: Error during zip archive creation
│ Traceback (most recent call last):
│ File "/Users/furqan.habibi/work/le-auto/infra/tf/stg/.terraform/modules/package_dir_poetry/package.py", line 1520, in build_command
│ bpm.execute(build_plan, zs, query)
│ File "/Users/furqan.habibi/work/le-auto/infra/tf/stg/.terraform/modules/package_dir_poetry/package.py", line 868, in execute
│ with install_poetry_dependencies(query, path) as rd:
│ File "/Users/furqan.habibi/.pyenv/versions/3.9.15/lib/python3.9/contextlib.py", line 119, in __enter__
│ return next(self.gen)
│ File "/Users/furqan.habibi/work/le-auto/infra/tf/stg/.terraform/modules/package_dir_poetry/package.py", line 1187, in install_poetry_dependencies
│ check_call(poetry_command, env=subproc_env)
│ File "/Users/furqan.habibi/.pyenv/versions/3.9.15/lib/python3.9/subprocess.py", line 368, in check_call
│ retcode = call(*popenargs, **kwargs)
│ File "/Users/furqan.habibi/.pyenv/versions/3.9.15/lib/python3.9/subprocess.py", line 349, in call
│ with Popen(*popenargs, **kwargs) as p:
│ File "/Users/furqan.habibi/.pyenv/versions/3.9.15/lib/python3.9/subprocess.py", line 951, in __init__
│ self._execute_child(args, executable, preexec_fn, close_fds,
│ File "/Users/furqan.habibi/.pyenv/versions/3.9.15/lib/python3.9/subprocess.py", line 1821, in _execute_child
│ raise child_exception_type(errno_num, err_msg, err_filename)
│ FileNotFoundError: [Errno 2] No such file or directory: 'poetry config
│ --no-interaction virtualenvs.create true'
Additional context
It is most likely caused by the following line, where poetry_command
is a string instead of a list.
terraform-aws-lambda/package.py
Line 1187 in 2e9aaa2
I am working on my PR to solve this.
Same issue
This issue has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this issue will be closed in 10 days
This issue was automatically closed because of stale in 10 days
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.