我最近自己发现了这一点。“paster create”采用 --config 命令行参数。这可以是包含要使用的变量的文件。
例如:
我将从名为 bobsetup.cfg 的配置中创建一个名为 bob 的包。配置文件将包含:
[pastescript]
created = 2011-09-07T14:47:27
egg_plugins__eval__ = []
plus = +
egg = bob
dot = .
description = Bob's magic code
license_name =
zip_safe__eval__ = False
keywords = Python
long_description = Bob's super useful code base
author = Fred Sprocket
author_email = fred.sprocket@example.com
url = http://example.com
version = 1.0.0
然后我可以按如下方式使用它:
$ paster create -t basic_package --config=bobsetup.cfg bob
Selected and implied templates:
PasteScript#basic_package A basic setuptools-enabled package
Variables:
author: Fred Sprocket
author_email: fred.sprocket@example.com
created: 2011-09-07T14:47:27
description: Bob's magic code
dot: .
egg: bob
egg_plugins: []
keywords: Python
license_name:
long_description: Bob's super useful code base
package: bob
plus: +
project: bob
url: http://example.com
version: 1.0
zip_safe: False
Creating template basic_package
Creating directory ./bob
Recursing into +package+
Creating ./bob/bob/
Copying __init__.py to ./bob/bob/__init__.py
Copying setup.cfg to ./bob/setup.cfg
Copying setup.py_tmpl to ./bob/setup.py
Running /Users/omul/.virtualenvs/im.analytics/bin/python setup.py egg_info
$
如果我检查 bob/setup.py 你可以看到这已经设置了变量。猫设置.py:
from setuptools import setup, find_packages
import sys, os
version = '1.0'
setup(name='bob',
version=version,
description="Bob's magic code",
long_description="""\
Bob's super useful code base""",
classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
keywords='Python',
author='Fred Sprocket',
author_email='fred.sprocket@example.com',
url='http://example.com',
license='',
packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
include_package_data=True,
zip_safe=False,
install_requires=[
# -*- Extra requirements: -*-
],
entry_points="""
# -*- Entry points: -*-
""",
)