-
-
Notifications
You must be signed in to change notification settings - Fork 693
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
How to use Poetry with src
directory but with poetry.lock
and pyproject.toml
at root.
#524
Comments
Happens to me also! Wonder what is the best way to solve it without moving poetry files. I was trying to use pip_tmp_dir but it does not work with poetry_install |
Hi, I'll try and look into this. FWIW I'm using this feature with layers and without
Note: in my case, the terraform files are at the root, the lambdas (I have several of the in the same repository) are in subfolders:
I also have another use case where the terraform file is in the lambda folder:
|
@n8felton Re-reading your description of the issue, I believe the issue is caused by the |
As a quick test, does the following work? module "aws_lambda" {
source = "terraform-aws-modules/lambda/aws"
source_path = [
{
path = "..",
patterns = [
".*",
"poetry.lock",
"pyproject.toml"
],
poetry_install = true
},
{
path = "../src"
}
]
create_function = false
build_in_docker = true
runtime = "python3.12"
docker_image = "build-python3.12-poetry:latest-arm64"
docker_file = "../Dockerfile"
} PS: I know it will embed too many things in the zip, but it is just for the purpose of the test. |
Yes, this works "as expected" and includes the dependancies gathered from the Docker container. Snip showing it including the urllib3 dependency that is captured from the Docker container, as well as the
|
Now, you just need to exclude what you certainly do not want in the zip archive, e.g.:
|
The problem with that approach is that I would need to add every file and/or directory I would want to exclude, and it leaves the project open to potentially including files that are added to the repo, but are not added to the exclude list. The goal is to be explicit in what I want included, not what I want excluded. |
Ok, so #525 is not a fix but a feat. |
@pdecat Thank you for the review (so far)! You can now edit/close issues and PRs in |
Having the same issues as @n8felton |
I think it's a bug that the
The Ideally, I should be able to define Having said that, #525 does not fix that bug, but rather allows me to more explicitly define where the |
Hmm, that is surprising. |
What about the pip install method, does it behave in the same way? |
Ok, to exclude that directory, the pattern should be
Log with this pattern:
With
|
It's great that there are patterns that we can use to exclude files or directories, but there are times when the file list is dynamic and where this approach does not work. It would be great to be able to explicitly define a list of files or directories to add, including the toml files. As it stands today, the poetry flags only work if the project is structured in a very opinionated way. |
Is that really much different from the way it worked with pip? Not a troll, I'm really trying to understand why these reports all come at a sudden. I implemented support for poetry in 2022, and it has been in use by several people (me included) since then. |
The pip implementation allow you to specify the path to requirements.txt. The poetry implementation only checks for pyproject.toml at the root of the path. You cannot specify its location, so yes, it is much different.
I don't know about the rest, but I have poetry projects where I also have a requirements.txt file because the poetry integration wasn't working. I never circled back and reported it. |
The answer to this is quite simple - we only just started attempting to use this module a few weeks ago. Our project is a new Python project, so we started it from scratch with some of today's recommended best practices, such as using poetry (instead of pip requirements.txt), and using a |
Noted. FWIW, I'm using |
This issue has been resolved in version 6.8.0 🎉 |
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. |
Description
I'm unable to determine how to use the
poetry_install = true
feature whenpoetry.lock
andpyproject.toml
are found in the root directory, but the source files are in thesrc
directory. I believe the problem stems from wanting to keep these files in the root directory, but for the build process to not include any other files from the root directory.As an example, this can be quickly replicated as such.
Then add the
Dockerfile
to the root, and the Terraformmain.tf
to theterraform
sub-directory.Dockerfile
main.tf
The final directory structure looks like this
To run the example:
Terraform Output
The module successfully finds the poetry files and does the necessary build in docker, but none of the packages installed with
pip
were included in the zip file.If I move the
poetry.lock
andpyproject.toml
into thesrc
directory, and change the source_path to"../src"
, things work as expected, but this is not the desired structure for the project.Working (but undesired) example
Versions
Module version [Required]:
6.5.0
Terraform versions
The text was updated successfully, but these errors were encountered: