如何在PyPI中包含非.py文件?
我刚接触PyPI,所以我想先说明这一点。我正在尝试把一个包上传到PyPI,但在用pip安装时遇到了一些麻烦。当我把文件上传到PyPI时,系统给了我一个警告(不过setup.py脚本没有致命错误,并且状态是200):
'my_package/static/my_folder' not a regular file -- skipping
然后当我用pip安装时,出现了一个错误:
"error: can't copy 'my_package/static/my_folder': doesn't exist or not a regular file.
根据其他人在StackOverflow上的回答,我尝试修改我的MANIFEST.in和setup.py文件,但没有成功。以下是我当前的MANIFEST.in:
recursive-include my_package *.css *.js *.jinja2
还有setup.py:
try:
from setuptools import setup, find_packages
except ImportError:
from distutils.core import setup, find_packages
setup(
name='my_package',
packages=find_packages(),
include_package_data=True,
platforms='any',
version='1.0',
description='my_description',
license='MIT',
author='Me',
author_email='me@example.com',
install_requires=[
'Flask',
'Jinja2',
'requests',
],
url='http://www.example.com',
download_url='https://github.com/me/my_package/tarball/1.0',
classifiers=[
'License :: OSI Approved :: MIT License',
],
)
补充:我还尝试过不使用MANIFEST.in文件,看看是不是这个文件出了问题,但结果还是一样。
1 个回答
2
(根据请求重新发布的评论。)
你的设置脚本和 MANIFEST.in
应该是可以正常工作的。为了用一个简单的例子来证明这一点:
my_project/
my_package/
static/
a.css
__init__.py
MANIFEST.in
setup.py
运行 python setup.py sdist
,你会发现 static/a.css
和 __init__.py
都被打包进了 tar.gz
文件里。