Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
gh-105931: Fix surprising compileall stripdir behaviour#108671
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This resolves issuepython#105931. Currently the '-s STRIPDIR' option oncompileall can lead to some surprising results as it only strips awaypath components that match, but leaves alone the non-matching onesinterspersed in between.For example, with: python -m compileall -s/path/to/another/src/path/to/build/src/file.pyThe resulting written path will be: build/file.pyThis fix only strips directories that are a fully matching prefix of thesource path. If a stripdir is provided that is not a valid prefix, awarning will be displayed (which can be silenced with '-qq').
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 like the simplicity of the solution and I have just one suggestion. I'm not a core developer so we'll need someone to approve and merge this, Cc:@encukou (helped with the original implementation so he has the necessary context).
Uh oh!
There was an error while loading.Please reload this page.
@encukou could you please help us to move this forward? |
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.
The original behaviour is clearly wrong.
IMO, we don't need a deprecation period to change it: the filename is essentially debug information.
I don't plan to backport to this to previous versions (at least initially): new warnings/outputs tend to cause trouble for users.
…GH-108671)Before, the '-s STRIPDIR' option oncompileall lead to some surprising results as it only strips awaypath components that match, but leaves alone the non-matching onesinterspersed in between.For example, with: python -m compileall -s/path/to/another/src/path/to/build/src/file.pyThe resulting written path will be: build/file.pyThis fix only strips directories that are a fully matching prefix of thesource path. If a stripdir is provided that is not a valid prefix, awarning will be displayed (which can be silenced with '-qq').
…GH-108671)Before, the '-s STRIPDIR' option oncompileall lead to some surprising results as it only strips awaypath components that match, but leaves alone the non-matching onesinterspersed in between.For example, with: python -m compileall -s/path/to/another/src/path/to/build/src/file.pyThe resulting written path will be: build/file.pyThis fix only strips directories that are a fully matching prefix of thesource path. If a stripdir is provided that is not a valid prefix, awarning will be displayed (which can be silenced with '-qq').
Uh oh!
There was an error while loading.Please reload this page.
This resolves issue#105931. Currently the '-s STRIPDIR' option on compileall can lead to some surprising results as it only strips away path components that match, but leaves alone the non-matching ones interspersed in between.
For example, with: python -m compileall -s/path/to/another/src /path/to/build/src/file.py
The resulting written path will be: build/file.py
This fix only strips directories that are a fully matching prefix of the source path. If a stripdir is provided that is not a valid prefix, a warning will be displayed (which can be silenced with '-qq').