Skip to content
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

Make pip wheel cache what it built #7285

Merged
merged 1 commit into from
Nov 3, 2019

Conversation

sbidoul
Copy link
Member

@sbidoul sbidoul commented Nov 2, 2019

This PR make pip wheel behave like pip install wrt caching of wheels it built locally.

This particularly helps performance in workflows where pip wheel is used for building before installing as documented here.

Closes #6852

@sbidoul sbidoul changed the title Make pip wheel cache what it builts Make pip wheel cache what it built Nov 2, 2019
@sbidoul sbidoul force-pushed the pip-wheel-cache-like-pip-install-sbi branch from e8d3b01 to a8395f0 Compare November 2, 2019 18:19
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.

Just a few comments. I'm OK with the purpose of the change, especially since the old behavior is possible by adding a flag.

I this this could be cleaner if the logic was extracted into the individual calling locations, but I don't think it's worth making that approach a prereq of this functional change.

news/6852.feature Show resolved Hide resolved
src/pip/_internal/wheel.py Show resolved Hide resolved
src/pip/_internal/wheel.py Show resolved Hide resolved
@sbidoul
Copy link
Member Author

sbidoul commented Nov 2, 2019

this could be cleaner if the logic was extracted into the individual calling locations

I wanted to keep the diff small, but yes, I fully agree this build method needs more refactoring love. I'd be happy to do some in a followup PR - although I admit I lack inspiration on how to do it right now.

@sbidoul
Copy link
Member Author

sbidoul commented Nov 2, 2019

I've no clue as to why these macOS checks fail...

@chrahunt
Copy link
Member

chrahunt commented Nov 2, 2019

_______________ test_force_reinstall_with_same_version_specifier _______________
[gw3] darwin -- Python 2.7.16 /Users/runner/runners/2.159.2/work/1/s/.tox/py/bin/python

script = <tests.lib.PipTestEnvironment object at 0x1095b7390>

    def test_force_reinstall_with_same_version_specifier(script):
        """
        Check --force-reinstall when the version specifier equals the installed
        version and the installed version is not the newest version.
        """
>       check_force_reinstall(script, 'simplewheel==1.0', '1.0')

tests/functional/test_install_force_reinstall.py:46: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

script = <tests.lib.PipTestEnvironment object at 0x1095b7390>
specifier = 'simplewheel==1.0', expected = '1.0'

    def check_force_reinstall(script, specifier, expected):
        """
        Args:
          specifier: the requirement specifier to force-reinstall.
          expected: the expected version after force-reinstalling.
        """
        result = script.pip_install_local('simplewheel==1.0')
        check_installed_version(script, 'simplewheel', '1.0')
    
        result2 = script.pip_install_local('--force-reinstall', specifier)
>       assert result2.files_updated, 'force-reinstall failed'
E       AssertionError: force-reinstall failed
E       assert {}
E        +  where {} = <tests.lib.TestPipResult object at 0x10ad47e50>.files_updated

tests/functional/test_install_force_reinstall.py:26: AssertionError

Also not sure - it doesn't seem like something that would be environment-dependent or related to the current change. The set of files updated in a normal run are venv/lib/pythonX.Y/site-packages, venv/lib/pythonX.Y/site-packages/simplewheel, and venv/lib/pythonX.Y/site-packages/simplewheel/__init__.py.

@sbidoul sbidoul force-pushed the pip-wheel-cache-like-pip-install-sbi branch from 83836fb to 30f2740 Compare November 3, 2019 09:15
@sbidoul
Copy link
Member Author

sbidoul commented Nov 3, 2019

I forced a new check and it's green now. Looks like it was a transient error.

@sbidoul
Copy link
Member Author

sbidoul commented Nov 3, 2019

Here is a commit with some minor refactoring of WheelBuilder.build. Let me know if you want it in this PR or another one.

@chrahunt
Copy link
Member

chrahunt commented Nov 3, 2019

I would have comments on that (like minimizing the scope of the try: ... except: ...) so in the interest of getting this in probably best to leave it out. :)

src/pip/_internal/wheel.py Outdated Show resolved Hide resolved
@sbidoul sbidoul force-pushed the pip-wheel-cache-like-pip-install-sbi branch from 2a9b77a to 978d9de Compare November 3, 2019 20:25
@chrahunt
Copy link
Member

chrahunt commented Nov 3, 2019

I think if you rebase on master it should fix the packaging issues - Azure Pipelines is using the pre-merge pipeline but the post-merge code which has updates from #7286 which removes generate_authors.

Just like pip install.
@sbidoul sbidoul force-pushed the pip-wheel-cache-like-pip-install-sbi branch from 978d9de to ba60397 Compare November 3, 2019 21:08
@sbidoul
Copy link
Member Author

sbidoul commented Nov 3, 2019

Rebased, squashed and green.

@chrahunt chrahunt merged commit 44c8cac into pypa:master Nov 3, 2019
@sbidoul sbidoul deleted the pip-wheel-cache-like-pip-install-sbi branch November 3, 2019 21:52
@sbidoul
Copy link
Member Author

sbidoul commented Nov 3, 2019

Many thanks!

@pradyunsg pradyunsg added C: cache Dealing with cache and files in it C: wheel The wheel format and 'pip wheel' command type: enhancement Improvements to functionality labels Nov 4, 2019
@sbidoul
Copy link
Member Author

sbidoul commented Nov 4, 2019

Do you want me to open a PR with the small refactoring mentioned in #7285 (comment) ?

In truth, the more I think of it the more I think the unpacking operation seem out of place in WheelBuilder.build this method and should be moved to a higher level caller (after all unpacking is not building).

@xavfernandez
Copy link
Member

In truth, the more I think of it the more I think the unpacking operation seem out of place in WheelBuilder.build this method and should be moved to a higher level caller (after all unpacking is not building).

👍

@chrahunt
Copy link
Member

chrahunt commented Nov 4, 2019

Yes, that's a great idea. Some hints after having looked at the code:

  • If we could have standalone functions that, when called with basic required arguments (e.g. a source directory and desired output directory instead of an InstallRequirement) and returning the path to the wheel, then everything should follow from that. One for legacy and one for PEP 517.
  • WheelBuilder.build could either return a list of BuildResults or be a generator for BuildResults, or we could elevate the execution to the caller.
  • I would start by seeing what makes the most sense at each call site individually vs trying to satisfy both use cases at the same time.

Also smaller changes are easier, if you see some couple-line refactoring that is non-controversial and would reduce the scope of your overall change don't hesitate to submit it!

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Dec 4, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Dec 4, 2019
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 C: cache Dealing with cache and files in it C: wheel The wheel format and 'pip wheel' command type: enhancement Improvements to functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pip wheel does not cache wheels it built locally
4 participants