summaryrefslogtreecommitdiffstats
path: root/Lib/compileall.py
Commit message (Collapse)AuthorAgeFilesLines
* GH-84559: Deprecate fork being the multiprocessing default. (#100618)Gregory P. Smith2023-02-021-1/+7
| | | | | | | | This starts the process. Users who don't specify their own start method and use the default on platforms where it is 'fork' will see a DeprecationWarning upon multiprocessing.Pool() construction or upon multiprocessing.Process.start() or concurrent.futures.ProcessPool use. See the related issue and documentation within this change for details.
* bpo-40447: accept all path-like objects in compileall.compile_file (#19883)Filipe Laíns2022-12-231-2/+2
| | | | | | Signed-off-by: Filipe Laíns <lains@archlinux.org> Signed-off-by: Filipe Laíns <lains@riseup.net> Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
* Fixed documentation typo in compileall.py (GH-29912)Vishal Pandey2021-12-041-1/+1
|
* Fix missing space with help for `-m compileall -o` (GH-27591)Daniel Hahler2021-09-171-3/+3
|
* bpo-34990: Treat the pyc header's mtime in compileall as an unsigned int ↵Ammar Askar2021-08-241-2/+2
| | | | | | (GH-19708) Co-authored-by: Stéphane Wirtel <stephane@wirtel.be>
* bpo-44666: Use default encoding as fallback for compile_file (GH-27236)Stefan Hoelzl2021-07-301-3/+2
| | | | | | | When sys.stdout.encoding is None compile_file will fall back to sys.getdefaultencoding to encode/decode error messages. Co-authored-by: Stefan Hoelzl <stefan.hoelzl@posteo.de> Co-authored-by: Mickaël Schoentgen <contact@tiger-222.fr>
* bpo-43651: Fix test_compileall with PEP 597 (GH-25128)Inada Naoki2021-04-021-1/+2
|
* bpo-40692: Run more test_concurrent_futures tests (GH-20239)Asheesh Laroia2021-02-081-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | In the case of multiprocessing.synchronize() being missing, the test_concurrent_futures test suite now skips only the tests that require multiprocessing.synchronize(). Validate that multiprocessing.synchronize exists as part of _check_system_limits(), allowing ProcessPoolExecutor to raise NotImplementedError during __init__, rather than crashing with ImportError during __init__ when creating a lock imported from multiprocessing.synchronize. Use _check_system_limits() to disable tests of ProcessPoolExecutor on systems without multiprocessing.synchronize. Running the test suite without multiprocessing.synchronize reveals that Lib/compileall.py crashes when it uses a ProcessPoolExecutor. Therefore, change Lib/compileall.py to call _check_system_limits() before creating the ProcessPoolExecutor. Note that both Lib/compileall.py and Lib/test/test_compileall.py were attempting to sanity-check ProcessPoolExecutor by expecting ImportError. In multiprocessing.resource_tracker, sem_unlink() is also absent on platforms where POSIX semaphores aren't available. Avoid using sem_unlink() if it, too, does not exist. Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-40495: compileall option to hardlink duplicate pyc files (GH-19901)Lumír 'Frenzy' Balhar2020-05-141-7/+35
| | | | | | | compileall is now able to use hardlinks to prevent duplicates in a case when .pyc files for different optimization levels have the same content. Co-authored-by: Miro Hrončok <miro@hroncok.cz> Co-authored-by: Victor Stinner <vstinner@python.org>
* compileall: Fix typos in docstring (GH-19810)Jelle Zijlstra2020-04-301-2/+2
|
* bpo-39769: Fix compileall ddir for subpkgs. (GH-18676)Gregory P. Smith2020-02-291-2/+9
| | | | | | | | | | 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.
* bpo-38470: Fix test_compileall.test_compile_dir_maxlevels() (GH-16789)Victor Stinner2019-10-151-5/+5
| | | | | | | | | Fix test_compile_dir_maxlevels() on Windows without long path support: only create 3 subdirectories instead of between 20 and 100 subdirectories. Fix also compile_dir() to use the current sys.getrecursionlimit() value as the default maxlevels value, rather than using sys.getrecursionlimit() value read at startup.
* bpo-38112: Compileall improvements (GH-16012)Lumír 'Frenzy' Balhar2019-09-261-38/+136
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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).
* bpo-36786: Run compileall in parallel during "make install" (GH-13078)Antoine Pitrou2019-05-151-14/+11
|
* bpo-29877: compileall: import ProcessPoolExecutor only when needed (GH-4856)Dustin Spicuzza2018-11-231-7/+11
| | | | | | | Importing ProcessPoolExecutor may hang or cause an error when the import accesses urandom on a low resource platform https://bugs.python.org/issue29877
* bpo-34022: Stop forcing of hash-based invalidation with SOURCE_DATE_EPOCH ↵Elvis Pranskevichus2018-10-101-7/+13
| | | | | | | | | | | | | | | | | | | | (GH-9607) Unconditional forcing of ``CHECKED_HASH`` invalidation was introduced in 3.7.0 in bpo-29708. The change is bad, as it unconditionally overrides *invalidation_mode*, even if it was passed as an explicit argument to ``py_compile.compile()`` or ``compileall``. An environment variable should *never* override an explicit argument to a library function. That change leads to multiple test failures if the ``SOURCE_DATE_EPOCH`` environment variable is set. This changes ``py_compile.compile()`` to only look at ``SOURCE_DATE_EPOCH`` if no explicit *invalidation_mode* was specified. I also made various relevant tests run with explicit control over the value of ``SOURCE_DATE_EPOCH``. While looking at this, I noticed that ``zipimport`` does not work with hash-based .pycs _at all_, though I left the fixes for subsequent commits.
* closes bpo-31650: PEP 552 (Deterministic pycs) implementation (#4575)Benjamin Peterson2017-12-091-15/+41
| | | | | | | | | | | | | | | | | | | | | | | | | Python now supports checking bytecode cache up-to-dateness with a hash of the source contents rather than volatile source metadata. See the PEP for details. While a fairly straightforward idea, quite a lot of code had to be modified due to the pervasiveness of pyc implementation details in the codebase. Changes in this commit include: - The core changes to importlib to understand how to read, validate, and regenerate hash-based pycs. - Support for generating hash-based pycs in py_compile and compileall. - Modifications to our siphash implementation to support passing a custom key. We then expose it to importlib through _imp. - Updates to all places in the interpreter, standard library, and tests that manually generate or parse pyc files to grok the new format. - Support in the interpreter command line code for long options like --check-hash-based-pycs. - Tests and documentation for all of the above.
* Issue #28485: Merge single-threading fix from 3.5 into 3.6Martin Panter2016-11-051-3/+3
|\
| * Issue #28485: Check for negative workers even without ProcessPoolExecutorMartin Panter2016-11-051-3/+3
| | | | | | | | | | This matches the documentation, and passes the test suite when multithreading is disabled.
* | Issue #28226: compileall now supports pathlibBerker Peksag2016-09-301-0/+4
| |
* | Issue #25768: Make compileall functions return booleans and documentBrett Cannon2015-12-271-8/+8
|/ | | | | | the return values as well as test them. Thanks to Nicholas Chammas for the bug report and initial patch.
* Merge: #24903: Remove misleading error message to fix regression.R David Murray2015-12-051-3/+0
|\
| * #24903: Remove misleading error message to fix regression.R David Murray2015-12-051-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | Before the argparse conversion, compileall would (sometimes) accept multiple paths when -d was specified. Afterward, it does not. The corresponding check in the original code claimed to prevent multiple *directories* from being specified...but it didn't really work even to do that. So this patch fixes the regression by invoking the consenting adults rule: if you specify a combination of arguments to compileall that produces files with inconsistent destdirs (which you could do before), it is on you. Patch by Jake Garver.
* | Issue #23917: Fall back to sequential compilation when ProcessPoolExecutor ↵Berker Peksag2015-04-221-3/+1
| | | | | | | | | | | | doesn't exist. Patch by Claudiu Popa.
* | Issue #23731: Implement PEP 488.Brett Cannon2015-04-131-3/+4
| | | | | | | | | | | | The concept of .pyo files no longer exists. Now .pyc files have an optional `opt-` tag which specifies if any extra optimizations beyond the peepholer were applied.
* | Issue #21338: Add silent mode for compileall.Berker Peksag2014-10-151-17/+28
| | | | | | | | | | | | | | | | | | quiet parameters of compile_{dir, file, path} functions now have a multilevel value. Also, -q option of the CLI now have a multilevel value. Patch by Thomas Kluyver.
* | Issue #16104: Allow compileall to do parallel bytecode compilation.Brett Cannon2014-09-121-23/+56
| | | | | | | | | | | | | | Both compileall.compile_dir() and the CLI for compileall now allow for specifying how many workers to use (or 0 to use all CPUs). Thanks to Claudiu Popa for the patch.
* | allow recursion depth to be specified (closes #19628)Benjamin Peterson2014-08-191-1/+11
|/ | | | Patch from Claudiu Popa.
* Issue #20976: pyflakes: Remove unused importsVictor Stinner2014-03-201-1/+0
|
* Merge: #19532: make compileall with no file/dir args respect -f and -q.R David Murray2013-12-161-1/+2
|\
| * #19532: make compileall with no file/dir args respect -f and -q.R David Murray2013-12-161-1/+2
| | | | | | | | Patch by Vajrasky Kok.
* | Issue #17177: stop using imp for compileall.Brett Cannon2013-06-151-5/+6
| |
* | Replace IOError with OSError (#16715)Andrew Svetlov2012-12-251-2/+2
| |
* | Issue #16706: get rid of os.errorAndrew Svetlov2012-12-181-1/+1
| |
* | Get rig of EnvironmentError (#16705)Andrew Svetlov2012-12-171-1/+1
|/
* #10454: a few edits to compileall help messagesÉric Araujo2011-09-011-7/+7
|
* Issue #11169: compileall module uses repr() to format filenames and paths toVictor Stinner2011-05-101-5/+5
| | | | escape surrogate characters and show spaces.
* #11132: pass optimize parameter to recursive call in ↵Georg Brandl2011-02-071-1/+1
| | | | compileall.compile_dir(). Reviewed by Eric A.
* Nits: use a real boolean, make one docstring more similar to the other onesÉric Araujo2010-12-231-2/+5
|
* #10454: clarify the compileall docs and help messages.R. David Murray2010-12-171-15/+22
|
* #10719: restore messages generated on invalid compileall argsR. David Murray2010-12-161-5/+5
| | | | | | | | Before the introduction of filename arguments to compileall it gave semi useful messages about not being able to 'list' names that weren't valid directories. This fix restores that behavior. In addition to the test for this case, the patch also adds a test for the default behavior of compileall when no arguments are provided, and fixes a bug in one of the previously added tests.
* More comprehensive compileall cli tests, and fixes.R. David Murray2010-12-141-14/+20
|
* Add an "optimize" parameter to compile() to control the optimization level, ↵Georg Brandl2010-12-041-8/+17
| | | | and provide an interface to it in py_compile, compileall and PyZipFile.
* Fix typos and style in compileall.Éric Araujo2010-11-201-18/+12
|
* #10453: compileall now uses argparse instead of getopt, so -h works.R. David Murray2010-11-201-77/+55
| | | | Patch by Michele Orrù.
* Create __pycache__ dir when the pyc path is explicitly givenBenjamin Peterson2010-05-081-6/+0
| | | | Patch from Arfrever Frehtes Taifersar Arahesis.
* Bug 8563 - compileall.compile_file() creates empty __pycache__ directories inBarry Warsaw2010-04-291-5/+6
| | | | | | | data directories where there is no source. Fix by: Arfrever Frehtes Taifersar Arahesis (Arfrever) Test by: Barry
* Bug 8527 - multiple compileall calls produce cascading __pycache__ directories.Barry Warsaw2010-04-261-0/+2
| | | | | | | | * Patch contributed by Arfrever Frehtes Taifersar Arahesis. * Test added by Barry Also, improve Makefile's deletion of __pycache__ directories so e.g. 'make distclean' doesn't fail if no __pycache__ directories exist.
* PEP 3147Barry Warsaw2010-04-171-26/+48
|
* Merged revisions ↵Benjamin Peterson2010-03-211-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 78966,78970,79018,79026-79027,79055,79156,79159,79163-79164,79173,79176,79194,79208,79212 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78966 | florent.xicluna | 2010-03-14 10:20:59 -0500 (Sun, 14 Mar 2010) | 2 lines Do not hardcode Expat version. It's possible to build Python with --with-system-expat option. ........ r78970 | benjamin.peterson | 2010-03-14 21:58:24 -0500 (Sun, 14 Mar 2010) | 1 line this little exception dance is pointless ........ r79018 | collin.winter | 2010-03-16 22:04:01 -0500 (Tue, 16 Mar 2010) | 1 line Delete unused import. ........ r79026 | vinay.sajip | 2010-03-17 10:05:57 -0500 (Wed, 17 Mar 2010) | 1 line Issue #8162: logging: Clarified docstring and documentation for disable function. ........ r79027 | collin.winter | 2010-03-17 12:36:16 -0500 (Wed, 17 Mar 2010) | 1 line Avoid hardcoding refcounts in tests. ........ r79055 | benjamin.peterson | 2010-03-18 16:30:48 -0500 (Thu, 18 Mar 2010) | 1 line remove installation of deleted test/output dir ........ r79156 | florent.xicluna | 2010-03-20 17:21:02 -0500 (Sat, 20 Mar 2010) | 2 lines Cleanup test_struct using check_warnings. ........ r79159 | florent.xicluna | 2010-03-20 17:26:42 -0500 (Sat, 20 Mar 2010) | 2 lines Cleanup test_tarfile, and use check_warnings. ........ r79163 | michael.foord | 2010-03-20 19:53:39 -0500 (Sat, 20 Mar 2010) | 1 line A faulty load_tests in a test module no longer halts test discovery. A placeholder test, that reports the failure, is created instead. ........ r79164 | michael.foord | 2010-03-20 19:55:58 -0500 (Sat, 20 Mar 2010) | 1 line Change order of arguments in a unittest function. ........ r79173 | georg.brandl | 2010-03-21 04:09:38 -0500 (Sun, 21 Mar 2010) | 1 line Document that GzipFile supports iteration. ........ r79176 | georg.brandl | 2010-03-21 04:17:41 -0500 (Sun, 21 Mar 2010) | 1 line Introduce copy by slicing, used in later chapters. ........ r79194 | florent.xicluna | 2010-03-21 06:58:11 -0500 (Sun, 21 Mar 2010) | 2 lines Use assertRaises and add a specific warning filter. ........ r79208 | andrew.kuchling | 2010-03-21 13:47:12 -0500 (Sun, 21 Mar 2010) | 1 line Add items ........ r79212 | georg.brandl | 2010-03-21 14:01:38 -0500 (Sun, 21 Mar 2010) | 1 line Fix plural. ........