Skip to main content

Buildout recipe to precompiles Python and locale files in an egg list.

Why precompilation?

Python ordinarily compiles .py files into .pyc or .pyo byte code files on demand. Likewise, applications like Plone often compile .po locale files into .mo representations when needed.

However, if you are running a Python application as a daemon and wish to prevent write access to code directories, you want to do these compilations at buildout-time, not run-time. That’s where this recipe comes in. Passed an egg list, it will pick up all the eggs in the buildout working set for the list and find and compile .py and .mo files in place.

.mo file compilation is optional, and must be turned on.

Usage

Please note that usage changed with release 0.5. If you need the old options, use 0.4

Common usage:

[buildout]
parts =
    ...
    precompile
eggs = ...


[precompile]
recipe = plone.recipe.precompiler
eggs = ${buildout:eggs}
compile-mo-files = true

This recipe may return harmless warnings regarding the inability to compile skin layer scripts, which typically have “return” outside of a function. While these warnings are harmless, you may suppress them by tuning the skip list.

Options

recipe = plone.recipe.precompiler

eggs = required: list of eggs

compile-mo-files = true/false; default is false

extra-paths = optional list of additional paths
    that would not be found from eggs
    in multiple
    indented lines

quiet = true/false; if true, common errors are only shown when buildout's
    verbose flag is set.

Notes

This recipe was created for use in Plone installers, but is hopefully useful in many buildout contexts.

Change history

Changelog for plone.recipe.precompiler.

0.7.2 (2020-06-26)

Bug fixes:

  • Small packaging updates. [gforcada, jensens, maurits]

0.7.1 (2018-11-11)

Bug fixes:

  • Rerelease to fix Python 3 issue in 0.7 [esteele]

0.7 (2018-11-07)

Bug fixes:

  • Fix reversion in 0.6, displaying too many .po compile errors.

0.6 (2012-12-17)

  • Use python_gettext rather than msgfmt to compile .po files. Removes dependence on gettext. (smcmahon)

0.5

  • Suck up error messages and filter them to hide .po compile errors and .py “return outside function” errors when quiet option is true (default). (smcmahon)

  • Make the extra-paths work with the new working set method for finding eggs. (smcmahon)

  • Removed BBB code. The new way of finding eggs introduced by chaoflow is much better than my original. (smcmahon)

  • removed the functionality to automatically extract products directories from parts with the zope2instance recipe. This resulted in buildouts that always installed ALL parts. If you need the products dir, you must declare it explicitly like so: dirs = ${instance:products} (do3cc - 2012-07-12)

0.4 (2010-08-12)

  • support for walking eggs dependencies, without skip/rx, manually tested. (chaoflow - 2010-08-12)

  • support for compiling mo files in those egg dirs, manually tested. (chaoflow - 2010-08-12)

  • kept old syntax and code, just don’t specify eggs (untested)

0.3

  • support to recursively compile list of dirs, with subdir blacklist and file blacklist regex. (Steve McMahon)

Contributors

Metadata

Release files for plone.recipe.precompiler 0.7.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for plone.recipe.precompiler 0.7.2
File Size Uploaded
plone.recipe.precompiler-0.7.2.zip 13.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for plone.recipe.precompiler 0.7.2
File Interpreter ABI Platform
plone.recipe.precompiler-0.7.2-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 19.0 kB

Release files / plone.recipe.precompiler-0.7.2.zip

Download URL plone.recipe.precompiler-0.7.2.zip
Size 13.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4121e7c467922fc011801ea2e4813b1a41248970a7ce21ad84e1be34c4bc1405
BLAKE2b-256 checksum
How to use checksums
7bb00fc452cf35d2bb3ee738cd246fd033d598bd8c8735ffd217f8ad309f2be8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/2.7.17

Release files / plone.recipe.precompiler-0.7.2-py2.py3-none-any.whl

Download URL plone.recipe.precompiler-0.7.2-py2.py3-none-any.whl
Size 5.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
e289466b11aa2425cf7599baefb166793116737adef1bfc5fe1e57d288ee35aa
BLAKE2b-256 checksum
How to use checksums
2c7d11270d72940d3dea109f721abd7abc3a01a7b31196b991d517f9460b2500
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/2.7.17

Release history Release notifications | RSS feed

This release

0.7.2 This release

2 release files

0.7.1

1 release file

0.7

1 release file

0.6

1 release file

0.5

1 release file

0.4

1 release file

0.3

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page