从 Python PasteScript 自动生成 Python Egg

发布于 2024-11-25 16:36:35 字数 305 浏览 4 评论 0原文

所以我正在使用 PasteScript 的粘贴器,并且我正在尝试自动化鸡蛋创建。我的第一步是获取 Python Egg 的模板。我注意到 PasteScript 的粘贴器有一​​个内置的,所以我一直从命令行创建我的模板:

$paster create -t basic_package

但是,这会以一系列提示的形式询问我问题(项目名称、作者、版本等)。调用 PasteScript 时是否可以使用配置文件或将参数直接传递到命令行?

我的目标是拥有一个可以运行的命令来生成鸡蛋模板。

感谢您的帮助!

So I'm using PasteScript's paster, and I'm trying to automate egg creation. My first step is to get a template of a Python egg. I noticed that PasteScript's paster has one built in, so I've been creating my template from the command line:

$paster create -t basic_package

However, this asks me the questions as a series of prompts (Project Name, Author, Version, etc). Is it possible to use a configuration file or a pass the argument directly into the command line when invoking PasteScript?

My goal is to have one command that I can run to generate an egg template.

Thanks for the help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

醉南桥 2024-12-02 16:36:35

我最近自己发现了这一点。 “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 = [email protected]
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:      [email protected]
  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='[email protected]',
      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: -*-
      """,
      )

I recently discovered this myself. The "paster create" takes a --config command line argument. This can be a file which contains the variable to use.

For example:

I will create a package called bob from config called bobsetup.cfg. The configuration file will contain:

[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 = [email protected]
url = http://example.com
version = 1.0.0

I can then use this as follows:

$ 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:      [email protected]
  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

$

If I check the bob/setup.py you can see this has set up the variables. cat setup.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='[email protected]',
      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: -*-
      """,
      )
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文