-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-38112: Compileall improvements #16012
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
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). CLA MissingOur records indicate the following people have not signed the CLA: For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. If you have recently signed the CLA, please wait at least one business day You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
CLA signed. |
@frenzymadness Thank you, unfortunately, we need to wait for the confirmation. |
We also need to update documentation. |
I'm also missing tests (and examples) for |
Doc/library/compileall.rst
Outdated
@@ -107,6 +124,12 @@ compile Python sources. | |||
.. versionchanged:: 3.7 | |||
Added the ``--invalidation-mode`` option. | |||
|
|||
.. versionchanged:: 3.9 | |||
Added the ``-s``, ``-p``, ``-e`` options. | |||
Raised the default default recursion limit from 10 to |
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.
Word "default" two times
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.
Raised the default default recursion limit from 10 to | |
Raised the default recursion limit from 10 to |
Yes, you are right, it's a bug. I'd prefer to keep I'm gonna fix it and prepare also a test for a combination of all three options used at once. |
See the last two commits. If you'd prefer to break backward compatibility and remove Tested combinations: ddir only, stripdir only, prependdir only, stripdir and prependdir, all three at once |
I'm still not sure if " What's the expected behavior of: ddir and prependdir, ddir and stripdir? |
If
|
But now, if you use Since combining |
I don't think so. At leat, I did some tests and from results it seems to me that if you use ddir, prependdir is ignored. For example:
This is btw covered by the latest test where it checks that the content of prependdir is not in the error output. Am I missing something?
Yes, I can imagine something like |
d7a076d
to
337cc4e
Compare
The latest commit adds ValueError in case If you are okay with this form, I'll rework conditions related to |
Looks good |
Now, you can: - Strip a part of path from a beggining of path into compiled file example "-s /test /test/build/real/test.py" → "build/real/test.py" - Append some new path to a beggining of path into compiled file example "-p /boo real/test.py" → "/boo/real/test.py" You can also use both options in the same time. In that case, striping is done before appending.
Each optimization level then leads to separated compiled file. Use `action='append'` instead of `nargs='+'` for the -o option. Instead of `-o 0 1 2`, specify `-o 0 -o 1 -o 2`. It's more to type, but much more explicit.
This feature allows us to limit byte-compilation of symbolic links if they are pointing outside specified dir (build root for example).
337cc4e
to
0783a29
Compare
Rebased, squashed, added news entry, all green. From my point of view, unless I forgot to change something, it's ready. |
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.
Looks good now, except the CLI interface should raise CLI error instead of showing a traceback. I added a commit for that, let's merge if it's green.
Workflow nitpick: we squash all changes when we merge, so rebasing is unnecessary. After you rebase, the commits need to be reviewed again, in case something changed.
Looks good. Thank you! |
|
I'm looking into it. |
|
* Raise the limit of maximum path depth to actual recursion limit * Add posibilities to adjust a path compiled in .pyc file. Now, you can: - Strip a part of path from a beggining of path into compiled file example "-s /test /test/build/real/test.py" → "build/real/test.py" - Append some new path to a beggining of path into compiled file example "-p /boo real/test.py" → "/boo/real/test.py" You can also use both options in the same time. In that case, striping is done before appending. * Add a possibility to specify multiple optimization levels Each optimization level then leads to separated compiled file. Use `action='append'` instead of `nargs='+'` for the -o option. Instead of `-o 0 1 2`, specify `-o 0 -o 1 -o 2`. It's more to type, but much more explicit. * Add a symlinks limitation feature This feature allows us to limit byte-compilation of symbolic links if they are pointing outside specified dir (build root for example).
Fix compileall.compile_dir() ddir= behavior on sub-packages. Fixes compileall.compile_dir's ddir parameter and compileall command line flag `-d` to no longer write the wrong pathname to the generated pyc file for submodules beneath the root of the directory tree being compiled. This fixes a regression introduced with Python 3.5. Also marks the _new_ in 3.9 from PR #16012 parameters to compile_dir as keyword only (as that is the only way they will be used) and fixes an omission of them in one place from the docs.
Improvements of compileall module (released as compileall2 on PyPI|GitHub) which makes the module better for Linux distributions where some manipulation with a baked path into a byte-compiled file is necessary. This patchset contains tests but needs to add documentation.
https://bugs.python.org/issue38112