Skip to main content

Paster Template for new Python Modules

Paster is a command line tool that aims to be able to do many things, often related to web frameworks, but we are specifically using its template creation abilities. It supports externally developed templates and that is what this project is.

This project defines a paster template for Python modules that I would consider a “standard” layout. Once you the paster template installed, you are able to run:

paster create -t standard [ProjectName]

That will guide you through a few questions about the name of your project, your email, etc and then creates the skeleton Python module setup for you. The rest of this help is about other developers contributing to updating this template.

Development Work

For development, we recommend you setup a virtualenv and use the requirements.txt file for installing necessary modules. I have also found that I’ll need to uninstall any system wide copy of the this package before doing my development work. While I’m using a virtualenv, it still seems to find the template:

python setup.py develop

For most modifications, you’ll just be concerned with updating the structure down the python_template/templates/ directory. That is the directory structure that is used as the template basis for what we install. E.g. If you need to tweak how a default setup.py looks, you would edit python_template/templates/setup.py_tmpl

The files ending with a _tmpl extension are templates that are implemented via the cheetah template engine. Variables are substituted inside of those files via a ${variable} syntax. If a file does not have a _tmpl extension, then it will be treated as a static file and copied verbatim.

Sometimes you need to actually name a file or a directory after a variable and to do that, you end up putting plus signs around the variable name. That is why you see a +package+ directory there because we want to create a directory named after the package name you’ve picked.

If you need to introduce new variables to be prompted to the user, which you intend to use in template files, then you need to update the python_template/newmodule.py file. To prompt the person invoking the script, add your variable to the vars list whereas if you need to define a non-prompted variable, you can update the vars dictionary within the PyTemplate.pre function.

Testing

Testing can be a bit complicated with this package. While other modules you can issue a python setup.py develop this seems to have a bit of magic going on in that the new template is still only seen if you are sitting in the base directory. As a result, I’ve found the following routine to be helpful:

python setup.py sdist
P="$(pwd)/dist/python_template-$(python setup.py --version).tar.gz"
mktmpenv -i $P

Then you can try creating a new project:

paster create -t standard NewProject

Metadata

Release files for standard.paster 1.0

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

Source distribution (sdist)

Source distribution for standard.paster 1.0
File Size Uploaded Provenance Actions
standard.paster-1.0.tar.gz 13.1 kB Without provenance Details for standard.paster-1.0.tar.gz

Release files / standard.paster-1.0.tar.gz

Download URL standard.paster-1.0.tar.gz
Size 13.1 kB
Tags Source
SHA-256 checksum
How to use checksums
89a35041f641badd55be06a77507b09fd08440160085f551c35170ebb186086d
BLAKE2b-256 checksum
How to use checksums
2c5a5c2a1c0f571c2df6e469feb8409e33bb9c55367ada8b86728d0bf5cfcbd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for standard.paster 1.0

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.

Release history Release notifications | RSS feed

This release

1.0 This release

1 release file No provenance

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