如何将脚本添加到构建项目?

发布于 2024-09-19 01:59:55 字数 575 浏览 5 评论 0原文

我在构建项目中有 setup.py

from distutils.core import setup
setup(name='',
  version='1.0',
  author='Denis Kolodin',
  author_email='...',
  url='...',
  scripts = ['scripts/myscript.py'], # The script I want to add to 'bin/' dir
)

为什么构建不将该脚本添加到“bin/”? 我可以使用构建来开发脚本(不是鸡蛋)吗?

我的buildout.cfg

[buildout]
develop = .
parts = python scripts

[python]
recipe = zc.recipe.egg
interpreter = python
eggs = marketwizard > 0.2.0
       jinja2

[scripts]
recipe = z3c.recipe.scripts

I have setup.py in a buildout project:

from distutils.core import setup
setup(name='',
  version='1.0',
  author='Denis Kolodin',
  author_email='...',
  url='...',
  scripts = ['scripts/myscript.py'], # The script I want to add to 'bin/' dir
)

Why buildout don't add that script to 'bin/'?
Can I develop scripts (not eggs) with buildout?

My buildout.cfg:

[buildout]
develop = .
parts = python scripts

[python]
recipe = zc.recipe.egg
interpreter = python
eggs = marketwizard > 0.2.0
       jinja2

[scripts]
recipe = z3c.recipe.scripts

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

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

发布评论

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

评论(2

灼痛 2024-09-26 01:59:55

目前,这是一个构建限制:它无法理解 setup.py 中的“script=”。它确实理解setuptools中的“console_scripts=”所谓的“入口点”。谷歌搜索它或查看具有它的现有项目。

我已经修复了构建,使其支持“scripts=”,但尚未被接受包含。

At the moment, this is a buildout limitation: it does not understand the "script=" from your setup.py. It does understand the "console_scripts=" so-called "entry point" from setuptools. Google for it or look at an existing project that has it.

I've got a fix for buildout to make it support "scripts=", but that hasn't been accepted for inclusion yet.

沉溺在你眼里的海 2024-09-26 01:59:55

我只是举一个真实的例子。

示例 setup.py

setup(name='',
  version='1.0',
  author='Denis Kolodin',
  author_email='...',
  url='...',
  entry_points={
    "console_scripts": [
        'myscript = scripts.myscript:main_function',
    ]
  }
)

示例 buildout.cfg

[buildout]
develop = .
parts = python scripts

[python]
recipe = zc.recipe.egg
interpreter = python
eggs = marketwizard > 0.2.0
   jinja2

[scripts]
recipe = zc.recipe.egg:scripts
# to be available in your script
eggs = ${python:eggs}
scripts = myscript

注意:main_function 这是脚本模块中的函数名称(可以是任何名称)。

I just make a real example.

Example setup.py

setup(name='',
  version='1.0',
  author='Denis Kolodin',
  author_email='...',
  url='...',
  entry_points={
    "console_scripts": [
        'myscript = scripts.myscript:main_function',
    ]
  }
)

Example buildout.cfg

[buildout]
develop = .
parts = python scripts

[python]
recipe = zc.recipe.egg
interpreter = python
eggs = marketwizard > 0.2.0
   jinja2

[scripts]
recipe = zc.recipe.egg:scripts
# to be available in your script
eggs = ${python:eggs}
scripts = myscript

Note: main_function this is function name (could any name) from your script module.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文