【问题标题】:What difference between "pip install" and "setup.py install" for static files静态文件的“pip install”和“setup.py install”有什么区别
【发布时间】:2012-07-24 10:37:01
【问题描述】:

我对 pip && setuptools 有疑问。我这里有一个简单的项目:https://github.com/rmuslimov/rapidlog

如果我发出这些命令:

mkvirtualenv rtests
pip install git+file:///%path_to_this_project%
rapidagent # This my app in this project

它可以正常工作并创建模板和静态文件。

如果我这样做:

mkvirtualenv rtests
cd %path_to_this_project%
python setup.py install
rapidagent

它无法安装我的模板和静态文件数据。所以我无法启动我的应用程序。

这里是我的 setup.py 文件的结尾:

entry_points={
    'console_scripts': [
        'rapidagent = rapidlog.web.webagent:main'
        ],
    },
include_package_data=True,
data_files=[('rapidlog/web/templates', ['rapidlog/web/templates/index.html']),
            ('rapidlog/web/static/css', glob('rapidlog/web/static/css/*')),
            ('rapidlog/web/static/images', glob('rapidlog/web/static/images/*')),
            ('rapidlog/web/static/js', glob('rapidlog/web/static/js/*')),
            ],
install_requires=[
    'pika>=0.9.5',
    'tornado>=2.3',
    'wsgiref>=0.1.2',
],
classifiers=[
    'License :: OSI Approved :: BSD License',
    'Programming Language :: Python'
    ]

pip 调用了什么特殊命令?有什么更好的方法来解决这个问题?

【问题讨论】:

  • 我只是按照你说的做了,在这里一切正常。检查我的输出:gist.github.com/3185285
  • 你可以在浏览器localhost:6673 - 在 rapidagent 启动后检查吗?
  • 哦,对不起。它说找不到模板等。我查看了站点包,您的包是.egg zip 文件。我认为首先要尝试将zip_safe=False 添加到您的setup 电话中。接下来是创建一个MANIFEST.in 文件而不是使用data_files

标签: python pip setuptools


【解决方案1】:

我发现您的 os.path.join 调用与调用 python 的当前目录相关。所以,第一件事是:

web/webagent.py: Change os.path.join('templates') and os.path.join('static') to be absolute

我刚刚给你发了一个pull request with this change

告诉我你接下来的步骤。

【讨论】:

    猜你喜欢
    • 2013-03-21
    • 1970-01-01
    • 1970-01-01
    • 2019-06-14
    • 2019-06-09
    • 2015-12-08
    相关资源
    最近更新 更多