Skip to content

Some more trivial refactorings in WheelBuilder #7476

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

Merged
merged 6 commits into from
Dec 14, 2019

Conversation

sbidoul
Copy link
Member

@sbidoul sbidoul commented Dec 13, 2019

Towards disentangling the pip wheel and pip install cases in WheelBuilder.

The individual commits should be easy to follow. Let me know if you prefer smaller PRs.

The third commit may require more reviewer attention, as it removes an os.path.join that is useless if I see correctly.

Towards splitting the build method in two
for pip wheel and pip install cases.
@chrahunt chrahunt added skip news Does not need a NEWS file entry (eg: trivial changes) type: refactor Refactoring code labels Dec 13, 2019
Copy link
Member

@xavfernandez xavfernandez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine but as you pointed out, the 3rd commit is odd and even if your change seems correct, I don't how shutil.copy(wheel_file, self._wheel_dir) and shutil.copy(os.path.join(cache_dir, wheel_file), self._wheel_dir) could be equivalent.
And since the tests pass in both case, there is likely a hole in the (test) racket 😛

@sbidoul
Copy link
Member Author

sbidoul commented Dec 13, 2019

wheelfile and os.path.join(cache_dir, wheelfile) are actually equivalent if wheelfile is an absolute path. It apparently is absolute, because the join is done in _build_on_inside_env.

I actually noticed it because there is no equivalent os.path.join in the should_cache code path, which indicated it was either not necessary or there was a bug in the other path. So I concluded it is not necessary.

@sbidoul sbidoul force-pushed the wheel-builder-disentangle-2-sbi branch from 24c9dd5 to 7aa4b8f Compare December 13, 2019 22:28
Copy link
Member

@chrahunt chrahunt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

A few small things may have made it a little easier to review:

  • For the extraction of _collect_buildset, it may have been clearer to set up a local need_wheel first that looks like you want, then do the extraction in a separate step.
  • For the "Remove useless os.path.join in WheelBuilder" commit, maybe draw attention to why it is useless (i.e. the return value of _build_one_inside_env is already joined with the output directory). The commit message is a good place to put justification.

@xavfernandez
Copy link
Member

wheelfile and os.path.join(cache_dir, wheelfile) are only equivalent if wheelfile is an absolute path.

Indeed, you're right ^^ Thanks for the pointer.

But this is not always true currently as options.cache_dir is not normalized :-/

@xavfernandez
Copy link
Member

xavfernandez commented Dec 13, 2019

With current pip master:

$ pip wheel zbarlight --no-deps -w . --cache-dir toto
Collecting zbarlight
  Downloading zbarlight-2.3.tar.gz (6.9 kB)
Building wheels for collected packages: zbarlight
  Building wheel for zbarlight (setup.py) ... done
  Created wheel for zbarlight: filename=zbarlight-2.3-cp38-cp38-linux_x86_64.whl size=22965 sha256=f3bb202fb0490c6b6dab67a734c0b1323cf8d0301489c97c927e8e14eb43c122
  Stored in directory: toto/wheels/0f/10/fb/72368c70eeb4a795ec30116b7d9376a98a41e4be67d710e059
  WARNING: Building wheel for zbarlight failed: [Errno 2] No such file or directory: 'toto/wheels/0f/10/fb/72368c70eeb4a795ec30116b7d9376a98a41e4be67d710e059/toto/wheels/0f/10/fb/72368c70eeb4a795ec30116b7d9376a98a41e4be67d710e059/zbarlight-2.3-cp38-cp38-linux_x86_64.whl'
Failed to build zbarlight
ERROR: Failed to build one or more wheels
$ rm -rf toto/
$ pip wheel zbarlight --no-deps -w . --cache-dir /tmp/toto
Collecting zbarlight
  Downloading zbarlight-2.3.tar.gz (6.9 kB)
Building wheels for collected packages: zbarlight
  Building wheel for zbarlight (setup.py) ... done
  Created wheel for zbarlight: filename=zbarlight-2.3-cp38-cp38-linux_x86_64.whl size=22965 sha256=f7c3f161c4dc4863804c30e06e21428f569ae7c53febf85ab62e3061aa06ef79
  Stored in directory: /tmp/toto/wheels/0f/10/fb/72368c70eeb4a795ec30116b7d9376a98a41e4be67d710e059
Successfully built zbarlight

So there are definitely missing tests :)

@sbidoul
Copy link
Member Author

sbidoul commented Dec 13, 2019

@xavfernandez you beat me to the reproducer :) So it looks like I actually fixed a previously unknown bug?

@xavfernandez
Copy link
Member

xavfernandez commented Dec 13, 2019

So it looks like I actually fixed a previously unknown bug?

It looks like it :) And found a missing test with a non-absolute --cache-dir option ^^

@sbidoul
Copy link
Member Author

sbidoul commented Dec 13, 2019

Hm. It might be I introduced it myself in #7285. i'll add a test for the non-absolute --cache-dir option.

@xavfernandez
Copy link
Member

We might want to handle --cache-dir like in #7467
So an assert to check that the path is absolute might be enough here ?

The join is done in _build_one_inside_env.
The bug as undetected because the cache directory is absolute most of
the time.
Remnant of a reverted feature.
@sbidoul sbidoul force-pushed the wheel-builder-disentangle-2-sbi branch from 7aa4b8f to 5109709 Compare December 14, 2019 11:49
@sbidoul
Copy link
Member Author

sbidoul commented Dec 14, 2019

I added the test for non-absolute cache directory, and reworded the commit message.

@pradyunsg
Copy link
Member

Travis CI failed for some reason. Restarted the job.

@chrahunt chrahunt merged commit 9573c2b into pypa:master Dec 14, 2019
@sbidoul sbidoul deleted the wheel-builder-disentangle-2-sbi branch December 14, 2019 22:00
@chrahunt chrahunt mentioned this pull request Dec 28, 2019
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jan 13, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Jan 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation skip news Does not need a NEWS file entry (eg: trivial changes) type: refactor Refactoring code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants