Deployment-specific scripts
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).
Metadata
Release files for zc.recipe.script 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| zc.recipe.script-1.0.2.tar.gz | 4.7 kB | Without provenance | Details for zc.recipe.script-1.0.2.tar.gz |
Release files / zc.recipe.script-1.0.2.tar.gz
| Download URL | zc.recipe.script-1.0.2.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
01ee94a770cef64acdb656dc88cba7432620a7ab1270a72fc23658e474b33dba
|
|
BLAKE2b-256 checksum How to use checksums |
57e1d723eef806293f4576321c97c9fbd0123abac781c33297787683458459c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for zc.recipe.script 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.