zc.buildout recipe for scripts in Unix deployments
Project description
Many deployments provide scripts that tie the configurations into the software. This is often done to make it easier to work with specific deployments of the software.
The conventional Unix file hierarchy doesn’t really provide a good shared place for such scripts; the zc.recipe.deployment:script recipe generates these scripts in the deployment’s bin-directory, but we’d rather have the resulting scripts associated with the deployment itself.
The options for the recipe are the same as those for the zc.recipe.egg:script recipe, with the addition of a required deployment setting. The etc-directory from the deployment is used instead of the buildout’s bin-directory. This allows deployment-specific information to be embedded in the script via the initialization setting.
Let’s take a look at a simple case. We’ll need a package with a console_script entry point:
>>> write('setup.py', '''\ ... from setuptools import setup ... setup( ... name="testpkg", ... package_dir={"": "src"}, ... py_modules=["testmodule"], ... zip_safe=False, ... entry_points={ ... "console_scripts": [ ... "myscript=testmodule:main", ... ], ... }, ... ) ... ''')>>> mkdir('src') >>> write('src', 'testmodule.py', '''\ ... some_setting = "42" ... def main(): ... print some_setting ... ''')>>> write('buildout.cfg', ... ''' ... [buildout] ... develop = . ... parts = somescript ... ... [mydep] ... recipe = zc.recipe.deployment ... prefix = %s ... user = %s ... etc-user = %s ... ... [somescript] ... recipe = zc.recipe.script ... deployment = mydep ... eggs = testpkg ... scripts = myscript ... initialization = ... import testmodule ... testmodule.some_setting = "24" ... ''' % (sample_buildout, user, user))>>> print system(join('bin', 'buildout')), # doctest: +NORMALIZE_WHITESPACE Develop: 'PREFIX/.' Installing mydep. zc.recipe.deployment: Creating 'PREFIX/etc/mydep', mode 755, user 'USER', group 'GROUP' zc.recipe.deployment: Creating 'PREFIX/var/cache/mydep', mode 755, user 'USER', group 'GROUP' zc.recipe.deployment: Creating 'PREFIX/var/lib/mydep', mode 755, user 'USER', group 'GROUP' zc.recipe.deployment: Creating 'PREFIX/var/log/mydep', mode 755, user 'USER', group 'GROUP' zc.recipe.deployment: Creating 'PREFIX/var/run/mydep', mode 750, user 'USER', group 'GROUP' zc.recipe.deployment: Creating 'PREFIX/etc/cron.d', mode 755, user 'USER', group 'GROUP' zc.recipe.deployment: Creating 'PREFIX/etc/init.d', mode 755, user 'USER', group 'GROUP' zc.recipe.deployment: Creating 'PREFIX/etc/logrotate.d', mode 755, user 'USER', group 'GROUP' Installing somescript. Generated script 'PREFIX/etc/mydep/myscript'.>>> print ls("etc/mydep") drwxr-xr-x USER GROUP etc/mydep>>> cat("etc/mydep/myscript") # doctest: +NORMALIZE_WHITESPACE #!/usr/bin/python <BLANKLINE> import sys sys.path[0:0] = [ 'PREFIX/src', ] <BLANKLINE> import testmodule testmodule.some_setting = "24" <BLANKLINE> import testmodule <BLANKLINE> if __name__ == '__main__': sys.exit(testmodule.main())
Release history
1.0.2 (2014-08-19)
Fix packaging bug (include src/zc/recipe/script/README.txt).
1.0.1 (2014-08-19)
Initial public release.
1.0.0 (2011-12-29)
Initial release (ZC internal).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file zc.recipe.script-1.0.2.tar.gz
.
File metadata
- Download URL: zc.recipe.script-1.0.2.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01ee94a770cef64acdb656dc88cba7432620a7ab1270a72fc23658e474b33dba |
|
MD5 | 9c35cb84ac844ba545a02528552a5bdd |
|
BLAKE2b-256 | 57e1d723eef806293f4576321c97c9fbd0123abac781c33297787683458459c6 |