Skip to main content

ZC Buildout recipe for precompiling .py files

Project description

zc.buildout recipe to precompile python- and po-files.

Why precompilation?

There are .py and .po files. For .py files it is sane and for .po files it is essential to be compiled for zope to make use of. In case you run zope under a user that has no write access to the code directories, you have a problem and you’d like the precompiling to happen before zope is started.

Usage

for example:

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


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

old, but should still work

ZC Buildout recipe for precompiling Python in product directories

This recipe searches for Python scripts with .py filename extensions and compiles them into .pyc bytecode files.

It will compile all the files in specified directories and their descendents. A “skip” list of directory names will be bypassed.

This recipe will probably usually be used in a Zope or Plone buildout using plone.recipe.* recipes. When it is, it will automatically use the product directories specified in plone.recipe.zope2instance recipes. Skip directories will be those required to produce an error-free build in that environment.

Precompiling Python code files to bytecode can prevent the Zope process from writing out .pyc files as it operates – which requires that the daemon process be able to write into program directories.

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.

Usage (old)

When used in a typical Plone install, usage is as simple as:

[precompile]
recipe = plone.recipe.precompiler

When used in a different type of install, or with a need for manual tuning::

[precompile]
recipe = plone.recipe.precompiler
dirs = list of dirs
    in multiple
    indented lines
skip = list of skip
    directories
    in multiple
    indented lines
rx = individual file exclusion regular expression

Default usage is equivalent to:

[instance]
...
[precompile]
recipe = plone.recipe.precompiler
dirs = ${instance:products}
skip =
    tests
    skins
    doc
    kupu_plone_layer
    Extensions
    .svn
rx = /\.

Change history

Changelog for plone.recipe.precompiler.

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)

TODO

  • merge blacklisting into new code, where sane

  • support extra-paths (more commonly used, than dirs)

Contributors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plone.recipe.precompiler-0.4.tar.gz (5.3 kB view details)

Uploaded Source

File details

Details for the file plone.recipe.precompiler-0.4.tar.gz.

File metadata

File hashes

Hashes for plone.recipe.precompiler-0.4.tar.gz
Algorithm Hash digest
SHA256 ee3dcd617bd42fbde5ce42561e539d8a71f4a02e100b441980e519bdfc6f8760
MD5 c40c7d7dbc0b245473eebeccc6289336
BLAKE2b-256 1fc5d8a02e03230e8d37b8bb833aada565a0c1c63b845a3be644c02fd4347271

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page