-
Notifications
You must be signed in to change notification settings - Fork 36
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
Add ability to control path inside PEX file #42
Open
mouadino
wants to merge
1
commit into
benley:master
Choose a base branch
from
mouadino:change-dest-path
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think you have the same bug here that I had: a path can match two prefixes.
Consider strip_prefixes set to:
['aaa', 'bbb']
If the files are the following:
aaa/bbb/foo
(expect to strip aaa and producebbb/foo
)bbb/aaa/bar
(expect to strip bbb and produceaaa/bar
)However, depending on the order the prefixes are applied, you will probably get one of
foo
orbar
as an output, since it strips both.To fix it, in my version I strip the LONGEST prefix match, which is a bit annoying but makes in unambiguous, and works when there are "overlapping" strip prefixes (e.g. strip
root1
androot1/foo/bar/subroot
)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 am unsure if it's less unambiguous then stripping by the first matched prefix which is what this patch does.
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.
Ah crap I missed the
break
on the next line. Silly me, sorry.Which one will be first though? It will depend on the order
deps
are specified in BUILD files. I guess that could actually be useful in some cases.At any rate: Not matching more than one prefix is really the important part.
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.
Not
deps
but first in thestrip_pex_path_prefixes
list, the stripping afterall apply to all files inrunfiles
which can be eitherdeps
,srcs
or evendata
attribute, if I recall well.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.
Ah! I see: This adds the attribute to
pex_binary
. I see! I added it topex_library
since we wanted to have somepex_library
make the python packagewhatever
, no matter where it lives in the Bazel workspace.Anyway: Great minds think alike! I agree that something like this should end up as part of these rules.
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.
What would be the benefit of adding this to
pex_library
versuspex_binary
?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.
It might be useful to have it apply to
data
from pex_library rules; otherwise you would have to manually propagate that information along to the final pex_binary in some situations.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.
Hmm... Now that you mention it: I'm pretty sure my version of this does not actually consider the
data
attribute, and only applies it to thesrcs
attribute. I think the internal code where I'm using this doesn't use any data files.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.
So I've been playing with this and I definitely think that applying it to the
pex_library
(bothsrcs
anddata
) makes the most sense as it removes the need for duplicating code. In my case I have two binaries that make use of the same library and I'd have to strip the same prefix in both binaries. In Buck this is calledbase_module
maybe we can adopt the same name (see: https://buckbuild.com/rule/python_library.html#base_module).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.
A counter-argument will be that you wouldn’t include test data in the
pex_library
? B/c if I understood correctly having this attribute inpex_library
only requires that you will need to define anything thateligible to striping in the
pex_library
rule, correct?On the other hand, having it in
pex_binary
andpex_test
have direct effecton the resulting Pex since this later are the rules that create them, and
yes, I agree that interface wise it's not DRY (and personally I don't like it too :)) however IMHO it gives users more control.