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 tox -evendor idempotent. #651

Merged
merged 2 commits into from
Jan 23, 2019
Merged

Make tox -evendor idempotent. #651

merged 2 commits into from
Jan 23, 2019

Conversation

jsirois
Copy link
Member

@jsirois jsirois commented Jan 22, 2019

This affords adding a CI check to ensure we never commit vendored code
with modifications beyond import re-writes.

Fixes #649
Fixes #650

This affords adding a CI check to ensure we never commit vendored code
with modifications beyond import re-writes.

Fixes pex-tool#649
Fixes pex-tool#650
if result != 0:
raise VendorizeError('Failed to vendor {!r}'.format(vendor_spec))

# We know we can get these as a by-product of a pip install but never need them.
safe_rmtree(os.path.join(vendor_spec.target_dir, 'bin'))
# We know we can get this as a by-product of a pip install but never need it.
Copy link
Member Author

Choose a reason for hiding this comment

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

NB: Instead of deleting bin/ post-install, we now instruct install to use a tmp dir for bin now. This is because the scripts wheel writes to bin/ form part of the checked-in RECORD file digests and their contents can change (namely the #!/path/to/python shebang). Using a tempdir - a dir outside the --target install root - eliminates the bin/ scripts from being enteed into the RECORD.

Copy link
Member Author

Choose a reason for hiding this comment

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

Upon further review had to go a different route to deal with this robustly; thus: 7a72d65

We now have the vendor-check / git as the stand-in for the RECORD, so
this is ok.
Copy link
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

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

Code looks good to me. However, I can't get tox to complain for improperly changing a file.

I pulled this down, modified /pex/vendor/_vendored/wheel/wheel/metadata.py like I had originally done, ran tox, and everything passed. It should have failed on the vendor-check stage, right?

Here's the diff to repro, followed by tox

diff --git a/pex/vendor/_vendored/wheel/wheel/metadata.py b/pex/vendor/_vendored/wheel/wheel/metadata.py
index eca49bc..7afdf78 100644
--- a/pex/vendor/_vendored/wheel/wheel/metadata.py
+++ b/pex/vendor/_vendored/wheel/wheel/metadata.py
@@ -13,7 +13,7 @@ from .pkginfo import read_pkg_info

 # Wheel itself is probably the only program that uses non-extras markers
 # in METADATA/PKG-INFO. Support its syntax with the extra at the end only.
-EXTRA_RE = re.compile("""^(?P<package>.*?)(;\s*(?P<condition>.*?)(extra == '(?P<extra>.*?)')?)$""")
+EXTRA_RE = re.compile(r"^(?P<package>.*?)(;\s*(?P<condition>.*?)(extra == '(?P<extra>.*?)')?)$")

 MayRequiresKey = namedtuple('MayRequiresKey', ('condition', 'extra'))

One further consideration: originally I thought you were going to change the file permissions for _vendored files to be -r--r--r-- only. How come you kept it at -rw--r--r--? Necessary for us to rewrite the imports, it sounds like?

--

One change I'd request is to mention in the squashed commit message that this reverts 16cfd97.

@jsirois
Copy link
Member Author

jsirois commented Jan 23, 2019

@Eric-Arellano did you run tox -e vendor-check after committing the edit? Running tox alone does not run all of the environments configured in tox.ini and to get an error there must be a diff. If you edit, do not commit and run, the edit just gets undone.

As to perms, the idea was malformed. Git only differentiates the executable bit - you can't store read-only.

@jsirois
Copy link
Member Author

jsirois commented Jan 23, 2019

I'll mention the (partial) revert.

@Eric-Arellano
Copy link
Contributor

Ah that's it. I was running tox, not tox -e vendor-check (my first time using Tox).

Is this expected? I had the file pex/vendor/_vendored/wheel/wheel/metadata.py modified, ran tox -e vendor-check, and the test overwrote the file and then said vendor: commands succeeded...congratulations :). With Travis, this doesn't seem acceptable to overwrite the file, because that overwrite won't be brought up to the PR and will be overwritten silently. I would have expected this command to have failed.

@jsirois
Copy link
Member Author

jsirois commented Jan 23, 2019

It's not a with-travis thing, it's an idempotency against the committed state thing. You should repro on your machine if you 1st commit your edit.

Copy link
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

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

Ah that's it, thanks John for clarifying.

I was able to reproduce that this would have caught my original mistake from #651. Both the behavior and the code look good.

@jsirois jsirois merged commit dfbc5db into pex-tool:master Jan 23, 2019
@jsirois jsirois deleted the issues/649 branch January 23, 2019 03:02
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.

2 participants