我使用https://github.com/pypa/sampleproject的示例setup.py
创建了这个最小setup.py
。这是我第一次遇到setup.py系统。最终结果是:
with open(path.join(here, 'README'), encoding='utf-8') as f:
long_description = f.read()
setup(
name='mkbib',
version='0.1',
description='BibTeX Creator',
author='Rudra Banerjee',
author_email='bnrj.rudra@gmail.com',
license='GPLv3',
keywords='BibTeX',
packages=find_packages(exclude=['contrib', 'docs', 'tests']),
install_requires=['bibtexparser'],
entry_points={
'gui_scripts': [
'mkbib=src:main',
],
},
)
我的目录结构是:
tree setup.py src/
setup.py [error opening dir]
src/
├── main.py
├── menubar.ui
├── menu.py
├── pybib.py
└── view.py
我运行(如果我不构建它)代码为:
python3 main.py
现在,如果我正在运行setup.py --install --prefix = / var / tmp(我已经添加了所需的PYTHONPATH等以将其安装在/ var / tmp中),它的出现没有任何错误:
Installing mkbib script to /var/tmp/bin
Installed /var/tmp/lib/python3.4/site-packages/mkbib-0.1-py3.4.egg
Processing dependencies for mkbib==0.1
Searching for bibtexparser==0.6.2
Best match: bibtexparser 0.6.2
Adding bibtexparser 0.6.2 to easy-install.pth file
Using /usr/lib/python3.4/site-packages
但是,运行/ var / tmp / bin / mkbib会出错:
Traceback (most recent call last):
File "./mkbib", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 3084, in <module>
@_call_aside
File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 3070, in _call_aside
f(*args, **kwargs)
File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 3097, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 651, in _build_master
ws.require(__requires__)
File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 952, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 839, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'mkbib==0.1' distribution was not found and is required by the application
正如我之前所说,这是我的第一个setup.py
,所以,不明白这里出了什么问题。