阅读python文档后,我仍然很难搞清楚。如何使用setup.py将我的python脚本安装到/ bin文件夹以使用CLI?
setup.py and adding file to /bin/
而且我也读了帖子里面并没有帮助澄清我的情况
因此,首先这里是我的文件结构,只是给你的什么,我试图做
一个清晰的概念,setup.py
setup.cfg
MANIFEST.in
README.md
requirements.txt
graphite/
- generate_report.py
- capture.js
- templates/
- - pretty much a bunch of JS/HTML/CSS files that get used by generate_report.py
所以,你可以看到,generate_report.py是我唯一的python文件,当用户使用我的软件包运行“pip install”时,我试图将它链接到/ bin文件夹。然而,generate_report需要有(我可以在代码中进行更改)capture.js(只是一个phantomjs文件,我使用python子进程来运行文件)和模板文件夹放在同一个目录中运行(我假设最好将文件链接到一个/ bin文件夹,我也假设setup.py为你做了这些)。
这里是我的setup.py代码
from distutils.core import setup
setup(
name = 'graphite-analytics',
packages = ['graphite'],
version = '0.1.1',
description = 'Create a print-out template for your google analytics data',
author = 'NAME REDACTED',
author_email = 'EMAIL-REDACTED',
url = 'https://github.com/ARM-open/Graphite',
download_url = 'https://github.com/ARM-open/Graphite/archive/0.1.1.tar.gz',
keywords = ['Google analytics', 'analytics', 'templates'],
classifiers = [],
install_requires=['Click', 'google-api-python-client', 'jinja2'],
entry_points={'console_scripts': [
'graphite-analytics=graphite.generate_report:main'
]}
)
,并在这里只是在情况需要它的
recursive-include graphite/templates *
include graphite/capture.js
我明白我在setup.py运行console_scripts我MANIFEST.in文件,但我对如何使用它很困惑(不确定我是否正确使用它)。我读过python文档,我的主要功能几乎处理了大部分。
这是否帮助? https://chriswarrick.com/blog/2014/09/15/python-apps-the-right-way-entry_points-and-scripts/ –
@FilipAllberg所以这实际上是我遵循的指南之一。如果你看看我的入口点并与他进行比较,他们的设置也是一样 – adriam