-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
_build: fix dynamic version when building from sdist #20
Conversation
c1a340a
to
0475d76
Compare
tests/conftest.py
Outdated
try: | ||
shutil.rmtree(path) | ||
except PermissionError: # pragma: no cover | ||
pass # this sometimes fails on windows :/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually this means there's a missing close somewhere, say a file opened without a context manager, etc. Only Windows cares about files being closed before deletion, so it only shows up on Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In trampolim/_sdist.py, there are two manual calls to .close()
without context managers. Context managers should be used, or they should be in a try:
/finally:
block. The files might not be closed if an error is thrown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes the code slightly harder to read, as it introduces two indentation levels. However, we are not handling the closing in case of an exception, so we can use https://docs.python.org/3/library/contextlib.html#contextlib.closing to fix that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use contextlib.ExitStack to avoid nested exceptions, like I did in #21 (though I didn't realize that the source context manager didn't cover the whole function, so it does need one extra indentation level).
You don't need to wrap tar file.TarFile in a closing context manager, it already has one since Python 3.2. GzipFile does seem to be missing a context manager, so it does a closing wrapper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This try/except needs to be reverted to the version on main. It's hiding potential valid errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is 3.10 passing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Session test-3.10 skipped: Python interpreter 3.10 not found.
Oh. That's why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup. If you want to fix that...
I don't know where the issue is, it errors out as
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\trampolim-test-s_oya_bn\\no-version-1.0.0+custom'
Which is a directory. I don't have time to track it down right now, so this will have to be on hold for a little while.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try to turn on my Windows box and see if I can debug locally soonish.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you 🙏
c4c8212
to
1372861
Compare
1372861
to
b4db6ab
Compare
Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
b4db6ab
to
1634a23
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Signed-off-by: Filipe Laíns lains@riseup.net