Poetry includes git-ignored files in build.
- Poetry version: Poetry (version 1.5.1)
- Python version: Python: 3.9.6
- OS version and name: macOS Ventura
- pyproject.toml
- [x] I am on the latest stable Poetry version, installed using a recommended method.
- [x] I have searched the issues of this repo and believe that this is not a duplicate.
- [x] I have consulted the FAQ and blog for any relevant entries or release notes.
- [x] If an exception occurs when executing a command, I executed it again in debug mode (
-vvvoption) and have included the output below.
Issue
We're using a tool called dbt within our Python package and it has a package management system. Packages are stored in a directory called dbt_packages and they're git-ignored in our repository. However, when running poetry build, it seems to still be included in the final build and I don't understand why because according to the docs:
If a VCS is being used for a package, the exclude field will be seeded with the VCS’ ignore settings (.gitignore for git for example).
Here's the evidence:
(clean) ☁ elementary [master] gst
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
# Note that dbt_packages is not tracked.
(clean) ☁ elementary [master] poetry build
Building elementary-data (0.9.2)
- Building sdist
- Built elementary_data-0.9.2.tar.gz
- Building wheel
- Built elementary_data-0.9.2-py3-none-any.whl
(clean) ☁ elementary [master] tar xvf dist/elementary_data-0.9.2.tar.gz 2>&1 | grep dbt_packages
x elementary_data-0.9.2/elementary/monitor/dbt_project/dbt_packages/elementary/.flake8
x elementary_data-0.9.2/elementary/monitor/dbt_project/dbt_packages/elementary/.git/FETCH_HEAD
x elementary_data-0.9.2/elementary/monitor/dbt_project/dbt_packages/elementary/.git/HEAD
x elementary_data-0.9.2/elementary/monitor/dbt_project/dbt_packages/elementary/.git/ORIG_HEAD
x elementary_data-0.9.2/elementary/monitor/dbt_project/dbt_packages/elementary/.git/config
x elementary_data-0.9.2/elementary/monitor/dbt_project/dbt_packages/elementary/.git/description
...
# dbt_packages is still included even though it's git-ignored.
I also tried moving the git-ignored records to the root of the repository but it still included them. Why does this happen? Thanks.
poetry asks git what it is ignoring, here
you can check for yourself whether the files that you are seeing are included or not, either by putting some print statements in that code or something like:
git --git-dir .git --work-tree . ls-files --others -i --exclude-standard
from the top of your project
poetry asks git what it is ignoring, here
you can check for yourself whether the files that you are seeing are included or not, either by putting some print statements in that code or something like:
git --git-dir .git --work-tree . ls-files --others -i --exclude-standardfrom the top of your project
@dimbleby
Those files (dbt_packages) are ignored but are still included in my build:
☁ elementary [master] ⚡ git --git-dir .git --work-tree . ls-files --others -i --exclude-standard
elementary/monitor/dbt_project/dbt_packages/dbt_utils/.circleci/config.yml
elementary/monitor/dbt_project/dbt_packages/dbt_utils/.github/CODEOWNERS
elementary/monitor/dbt_project/dbt_packages/dbt_utils/.github/ISSUE_TEMPLATE/bug_report.md
elementary/monitor/dbt_project/dbt_packages/dbt_utils/.github/ISSUE_TEMPLATE/dbt_minor_release.md
elementary/monitor/dbt_project/dbt_packages/dbt_utils/.github/ISSUE_TEMPLATE/feature_request.md
elementary/monitor/dbt_project/dbt_packages/dbt_utils/.github/ISSUE_TEMPLATE/utils_minor_release.md
elementary/monitor/dbt_project/dbt_packages/dbt_utils/.github/pull_request_template.md
elementary/monitor/dbt_project/dbt_packages/dbt_utils/.gitignore
...
Why are they included?
I've shown you where the code is, please investigate this yourself.
FYI I fixed a bug that may be related to this. Try the latest poetry-core release and see if that fixes it.
Fixed by https://github.com/python-poetry/poetry-core/pull/611
Hi @jameshilliard @finswimmer, this still occurs to me on the latest release.
Essentially what happens is that I have a Poetry package in which there is a .gitignore not at the root, but rather one of the nested directories. Poetry still tries to include those files.
Hi @jameshilliard @finswimmer, this still occurs to me on the latest release.
Essentially what happens is that I have a Poetry package in which there is a
.gitignorenot at the root, but rather one of the nested directories. Poetry still tries to include those files.
The fix was not released yet. This will be available in the next release
Hi @jameshilliard @finswimmer, this still occurs to me on the latest release. Essentially what happens is that I have a Poetry package in which there is a
.gitignorenot at the root, but rather one of the nested directories. Poetry still tries to include those files.The fix was not released yet. This will be available in the next release
Got it, thanks a lot for updating.
- Is there a planned released date, or a beta version I can use?
- Also, here's my exact use-case as it's pretty weird and I want to make sure it's covered:
I have an API project (Poetry) and a Common package (also Poetry).
The API project installs the Common package using a path dependency.
The Common package has files that are git-ignored and Poetry currently tries to build them into the API project.
Would the fix also take into account the git-ignored files even though they're in the Common package and not the API project?
Thanks.
but rather one of the nested directories
Is the nested directory itself being entirely ignored by the project it is nested within? The purpose of #611 is to disable gitignore usage for cases when the nested directory is entirely ignored(as doing so would always result in an empty package).
but rather one of the nested directories
Is the nested directory itself being entirely ignored by the project it is nested within? The purpose of #611 is to disable gitignore usage for cases when the nested directory is entirely ignored(as doing so would always result in an empty package).
The problem is that it is not ignored but rather included when it shouldn't be.
The problem is that it is not ignored but rather included when it shouldn't be.
Well it the project root is ignored, then poetry will disable the use of gitignore handling entirely.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.