Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Poetry includes git-ignored files in build. #8316

Closed
4 tasks done
elongl opened this issue Aug 15, 2023 · 12 comments
Closed
4 tasks done

Poetry includes git-ignored files in build. #8316

elongl opened this issue Aug 15, 2023 · 12 comments
Labels
area/build-system Related to PEP 517 packaging (see poetry-core) kind/bug Something isn't working as expected status/triage This issue needs to be triaged
Milestone

Comments

@elongl
Copy link

elongl commented Aug 15, 2023

  • Poetry version: Poetry (version 1.5.1)
  • Python version: Python: 3.9.6
  • OS version and name: macOS Ventura
  • pyproject.toml
  • I am on the latest stable Poetry version, installed using a recommended method.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have consulted the FAQ and blog for any relevant entries or release notes.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) 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.

@elongl elongl added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Aug 15, 2023
@dimbleby
Copy link
Contributor

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

@elongl
Copy link
Author

elongl commented Aug 16, 2023

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

@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?

@dimbleby
Copy link
Contributor

I've shown you where the code is, please investigate this yourself.

@jameshilliard
Copy link

FYI I fixed a bug that may be related to this. Try the latest poetry-core release and see if that fixes it.

@Secrus Secrus added this to the Poetry 2.0 milestone Oct 6, 2024
@Secrus Secrus added the area/build-system Related to PEP 517 packaging (see poetry-core) label Oct 13, 2024
@finswimmer
Copy link
Member

Fixed by python-poetry/poetry-core#611

@elongl
Copy link
Author

elongl commented Nov 19, 2024

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.

@Secrus
Copy link
Member

Secrus commented Nov 19, 2024

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.

The fix was not released yet. This will be available in the next release

@elongl
Copy link
Author

elongl commented Nov 19, 2024

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.

The fix was not released yet. This will be available in the next release

Got it, thanks a lot for updating.

  1. Is there a planned released date, or a beta version I can use?
  2. 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.

@jameshilliard
Copy link

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).

@elongl
Copy link
Author

elongl commented Nov 20, 2024

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.

@jameshilliard
Copy link

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.

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 23, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
area/build-system Related to PEP 517 packaging (see poetry-core) kind/bug Something isn't working as expected status/triage This issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

5 participants