-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Poetry-core picks up unrelated .gitignore which results in an empty wheel #5547
Comments
I spent a whole day debugging why my AUR package is empty when packaging a Python project which uses Poetry. AUR packages are git repos and they often contain a |
In https://trac.sagemath.org/ticket/33866 we have adopted the above patch to |
I'm a developer for the Spack package manager. Spack builds all software from source, including packages using the poetry build system. We've gotten several reports of users who have ended up with empty or broken poetry installs due to this bug:
Is there any work in progress to resolve this issue, or should we patch poetry using the above patch? |
The above patch is a shotgun pointed at unknown places, but if it works for you, more power to you. We have a user who has been working on fixing this issue/gathering input on how to solve it without breaking other things, but I have yet to see them put a PR up -- however, it is intended that we fix this in Poetry. |
Glad to know that this is a WIP! One of our users suggested setting |
This occurs when you have a Poetry-managed project that is not a VCS repository (most often a tarball) extracted into the tree of a git repository, and the path that it is extracted to is listed in the Technically the search for a |
Do you know what the progress is with this PR? |
I have not heard anything in a couple weeks; if you're interested in trying to solve this yourself, I would suggest that you go ahead. |
Workaround python-poetry/poetry#5547 Signed-off-by: txtsd <code@ihavea.quest>
A package may run git as part of its build process, and if the package source code is not from a git checkout, then git may traverse up the directory tree to find buildroot's repository directory (.git). For instance, Poetry Core, a Python build backend, will read the contents of .gitignore for paths to exclude when creating a Python package. If it finds buildroot's .gitignore file, then Poetry Core will exclude all of the package's files[1]. This exports GIT_CEILING_DIRECTORIES for both package and host builds so that git will not traverse beyond $(BUILD_DIR)/$(BUILD_DIR_HOST). [1]: python-poetry/poetry#5547 Signed-off-by: Jeffery To <jeffery.to@gmail.com>
A package may run git as part of its build process, and if the package source code is not from a git checkout, then git may traverse up the directory tree to find buildroot's repository directory (.git). For instance, Poetry Core, a Python build backend, will read the contents of .gitignore for paths to exclude when creating a Python package. If it finds buildroot's .gitignore file, then Poetry Core will exclude all of the package's files[1]. This exports GIT_CEILING_DIRECTORIES for both package and host builds so that git will not traverse beyond $(BUILD_DIR)/$(BUILD_DIR_HOST). [1]: python-poetry/poetry#5547 Signed-off-by: Jeffery To <jeffery.to@gmail.com>
A package may run git as part of its build process, and if the package source code is not from a git checkout, then git may traverse up the directory tree to find buildroot's repository directory (.git). For instance, Poetry Core, a Python build backend, will read the contents of .gitignore for paths to exclude when creating a Python package. If it finds buildroot's .gitignore file, then Poetry Core will exclude all of the package's files[1]. This exports GIT_CEILING_DIRECTORIES for both package and host builds so that git will not traverse beyond $(BUILD_DIR)/$(BUILD_DIR_HOST). [1]: python-poetry/poetry#5547 Signed-off-by: Jeffery To <jeffery.to@gmail.com>
A package may run git as part of its build process, and if the package source code is not from a git checkout, then git may traverse up the directory tree to find buildroot's repository directory (.git). For instance, Poetry Core, a Python build backend, will read the contents of .gitignore for paths to exclude when creating a Python package. If it finds buildroot's .gitignore file, then Poetry Core will exclude all of the package's files[1]. This exports GIT_CEILING_DIRECTORIES for both package and host builds so that git will not traverse beyond $(BUILD_DIR)/$(BUILD_DIR_HOST). [1]: python-poetry/poetry#5547 Signed-off-by: Jeffery To <jeffery.to@gmail.com> (cherry picked from commit f597f34)
A package may run git as part of its build process, and if the package source code is not from a git checkout, then git may traverse up the directory tree to find buildroot's repository directory (.git). For instance, Poetry Core, a Python build backend, will read the contents of .gitignore for paths to exclude when creating a Python package. If it finds buildroot's .gitignore file, then Poetry Core will exclude all of the package's files[1]. This exports GIT_CEILING_DIRECTORIES for both package and host builds so that git will not traverse beyond $(BUILD_DIR)/$(BUILD_DIR_HOST). [1]: python-poetry/poetry#5547 Signed-off-by: Jeffery To <jeffery.to@gmail.com>
A package may run git as part of its build process, and if the package source code is not from a git checkout, then git may traverse up the directory tree to find buildroot's repository directory (.git). For instance, Poetry Core, a Python build backend, will read the contents of .gitignore for paths to exclude when creating a Python package. If it finds buildroot's .gitignore file, then Poetry Core will exclude all of the package's files[1]. This exports GIT_CEILING_DIRECTORIES for both package and host builds so that git will not traverse beyond $(BUILD_DIR)/$(BUILD_DIR_HOST). [1]: python-poetry/poetry#5547 Signed-off-by: Jeffery To <jeffery.to@gmail.com> (cherry picked from commit f597f34)
The problem is that poetry mis-interprets the .gitignore files. The .gitignore file in the root of the FreeBSD repository has:
This is supposed to only affect x/y/work and x/y/work-xx. Why does poetry apply these ignore lines at all? The .gitignore file that exists up in the hierarchy is irrelevant to the currently built project. This needs to be fixed. |
Yeah, spent a whole day tracking this down myself when packaging poetry-core for buildroot, hopefully python-poetry/poetry-core#611 should fix it properly. |
A package may run git as part of its build process, and if the package source code is not from a git checkout, then git may traverse up the directory tree to find buildroot's repository directory (.git). For instance, Poetry Core, a Python build backend, will read the contents of .gitignore for paths to exclude when creating a Python package. If it finds buildroot's .gitignore file, then Poetry Core will exclude all of the package's files[1]. This exports GIT_CEILING_DIRECTORIES for both package and host builds so that git will not traverse beyond $(BUILD_DIR)/$(BUILD_DIR_HOST). [1]: python-poetry/poetry#5547 Signed-off-by: Jeffery To <jeffery.to@gmail.com> (cherry picked from commit f597f34)
A package may run git as part of its build process, and if the package source code is not from a git checkout, then git may traverse up the directory tree to find buildroot's repository directory (.git). For instance, Poetry Core, a Python build backend, will read the contents of .gitignore for paths to exclude when creating a Python package. If it finds buildroot's .gitignore file, then Poetry Core will exclude all of the package's files[1]. This exports GIT_CEILING_DIRECTORIES for both package and host builds so that git will not traverse beyond $(BUILD_DIR)/$(BUILD_DIR_HOST). [1]: python-poetry/poetry#5547 Signed-off-by: Jeffery To <jeffery.to@gmail.com> (cherry picked from commit f597f34)
A package may run git as part of its build process, and if the package source code is not from a git checkout, then git may traverse up the directory tree to find buildroot's repository directory (.git). For instance, Poetry Core, a Python build backend, will read the contents of .gitignore for paths to exclude when creating a Python package. If it finds buildroot's .gitignore file, then Poetry Core will exclude all of the package's files[1]. This exports GIT_CEILING_DIRECTORIES for both package and host builds so that git will not traverse beyond $(BUILD_DIR)/$(BUILD_DIR_HOST). [1]: python-poetry/poetry#5547 Signed-off-by: Jeffery To <jeffery.to@gmail.com>
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. |
Closest issue I found to this is #4800.
Issue
I'm trying to package up
poetry-core-1.0.8
at work but when building it I end up with an empty install (apart for some metadata).At work we are using a proprietary package manager, closest open source equivalent would probably be rez.
Each recipe to build a package is its own git repo, which we call a port. The source of a package is extracted to a subdirectory called
private/build
then the resulting artifact is installed to another subdirectoryprivate/dist
which then can be installed to its final destination. To keep the repo clean we listprivate
in.gitignore
.I did some code spelunking in the source code for
poetry-core
and discovered that the issue is how it uses the VCS's ignore list (.gitignore
for git) to pre-seed the exclude field. Since I'm downloading the release tarball, the source code does not contain any VCS info. But given that the tarball is extracted in a subdirectory (private/build
) of the port which is a git repo,poetry-core
picks up the.gitignore
from that. And as stated earlier that ignores the whole source directory.I patched the
get_vcs(…)
function to check that the path returned by git is located inside thedirectory
given toget_vcs
. And that seems to fix my issue:But I have very little knowledge of the code so this might not be the desired fix.
Repro
Using guix (with commit f49b1a10f3d13ee9597b8ef230828606f7cac99f if you want to reproduce the exact environment)
Here follows the commands to reproduce my issue. Note that
guix
isn't necessary if you have all the dependencies needed to buildpoetry-core
Or as a oneliner:
guix shell -D python-poetry-core python-pypa-build unzip git wget --pure -- sh -c "mkdir /tmp/poetry-core-port && cd /tmp/poetry-core-port && git init && echo private > .gitignore && wget https://github.com/python-poetry/poetry-core/archive/refs/tags/1.0.8.tar.gz && mkdir -p private/build && tar -xf /tmp/poetry-core-port/1.0.8.tar.gz -C private/build && cd private/build/poetry-core-1.0.8 && python -m build -wn && unzip -l dist/poetry_core-1.0.8-py2.py3-none-any.whl"
The last output will be:
If you remove
git
from the environment it will successfully package up all files.I have also tested this with
poetry-core-1.1.0a7
and that exhibits the same issue.The text was updated successfully, but these errors were encountered: