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

Fix race condition when installing 2+ editable non-VCS pkgs at once #3237

Merged
merged 7 commits into from
Nov 18, 2018

Conversation

christek91
Copy link
Contributor

@christek91 christek91 commented Nov 16, 2018

This regression was recently introduced, and only affects non-vcs
packages. The effect of the race is that installations of multiple
editable non-VCS sourced packages at once may cause some of them to be
un-importable.

The fix is to make editable package installs Blocking just like VCS
installs are.

Thank you for contributing to Pipenv!

The issue

This fixes a race condition that is hit when installing multiple local editable packages at once. There was a regression because editable installations used to be blocking, but a change in the recent release changed it so that only VCS installations are blocking.

While most VCS installations are probably editable, not all editable` installations are VCS ones. So that change inadvertently brought back #919.

I've also created a new Issue for the new regression as the PR template suggests. It is: #3236

The fix

My fix makes sure that all editable installations are blocking, regardless of if they are VCS installs or not.

The test I wrote for this is a little janky to setup since I couldn't use git to install the test packages since VCS installations don't hit the race. I put a comment in the code explaining the context.

The checklist

  • Associated issue
  • A news fragment in the news/ directory to describe this fix with the extension .bugfix, .feature, .behavior, .doc. .vendor. or .trivial (this will appear in the release changelog). Use semantic line breaks and name the file after the issue number or the PR #.

@@ -8,6 +8,7 @@
import pytest

from flaky import flaky
import delegator
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this line can be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, good point. That was left over from an earlier iteration. I'll fix that.



@pytest.mark.files
@pytest.mark.needs_internet
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it really need internet? You are using the mocked pypi test server in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, you're right it does not in the final iteration. Will fix that.

"""
pkgs = {
"requests-2.19.1": "requests/requests-2.19.1.tar.gz",
"flask-0.12.2": "flask/flask-0.12.2.tar.gz",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"flask-0.12.2": "flask/flask-0.12.2.tar.gz",
"flask-0.12.2": "flask/Flask-0.12.2.tar.gz",

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, updated in new commit!

"requests-2.19.1": "requests/requests-2.19.1.tar.gz",
"flask-0.12.2": "flask/flask-0.12.2.tar.gz",
"six-1.11.0": "six/six-1.11.0.tar.gz",
"jinja2-2.10": "jinja2/jinja2-2.10.tar.gz",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"jinja2-2.10": "jinja2/jinja2-2.10.tar.gz",
"jinja2-2.10": "jinja2/Jinja2-2.10.tar.gz",

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, updated in new commit!

This regression was recently introduced, and only affects non-vcs
packages. The effect of the race is that installations of multiple
editable non-VCS sourced packages at once may cause some of them to be
un-importable.

The fix is to make editable package installs Blocking just like VCS
installs are.
pipfile_string += "'{0}' = {{path = '{1}', editable = true}}\n".format(pkg_name, unzip_path)

with PipenvInstance(pypi=pypi, chdir=True) as p:
print(pipfile_string)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove the debugging prints.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 will do!

@techalchemy
Copy link
Member

once the debug line is gone im good to merge this, i didn't think about adding editable as a conditional there but i'm glad you were able to find that. Hopefully the code cleanup efforts will make contributing easier

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants