我正在尝试构建我相当简单的Python项目,以便:
dynamic-dynamodb
dynamic_dynamodb.main:main
我的项目如下:
.
├── LICENSE
├── MANIFEST.in
├── Makefile
├── README -> README.md
├── README.md
├── dynamic_dynamodb
│ ├── __init__.py
│ ├── dynamic_dynamodb.py
│ └── main.py
├── example-dynamic-dynamodb.conf
├── requirements.txt
└── setup.py
当我在根文件夹中只有一个Python文件时,我可以正常工作。但是当项目增长时,我不得不拆分代码并将其放入模块(即文件夹dynamic_dynamodb
)。现在我的setup.py
看起来像这样:
""" Setup script for PyPI """
from setuptools import setup, find_packages
setup(name='dynamic-dynamodb',
version='0.3.0-SNAPSHOT',
license='Apache License, Version 2.0',
description='Automatic provisioning for AWS DynamoDB tables',
author='Sebastian Dahlgren',
author_email='sebastian.dahlgren@gmail.com',
url='http://sebdah.github.com/dynamic-dynamodb/',
keywords="dynamodb aws provisioning amazon web services",
platforms=['Any'],
py_modules=['dynamic_dynamodb'],
packages=find_packages('dynamic_dynamodb'),
include_package_data=True,
zip_safe=False,
install_requires=[
'boto >= 2.6.0'
],
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Console',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python'
],
entry_points={
'console_scripts': [
'dynamic-dynamodb = dynamic_dynamodb.main:main',
]
}
)
问题在于,当我使用python setup.py sdist
构建时,我看到以下错误:
file dynamic_dynamodb.py (for module dynamic_dynamodb) not found
有没有人能指引我朝正确的方向发展?
答案 0 :(得分:3)
我按照本指南解决了这个问题:http://wiki.python.org/moin/Distutils/Tutorial
重点是:
py_modules
中使用setup.py
。只需使用包裹。distutils
,因为我不需要任何setuptools
功能我的新setup.py
:
""" Setup script for PyPI """
from distutils.core import setup
setup(name='dynamic-dynamodb',
version='0.3.0-SNAPSHOT',
license='Apache License, Version 2.0',
description='Automatic provisioning for AWS DynamoDB tables',
author='Sebastian Dahlgren',
author_email='sebastian.dahlgren@gmail.com',
url='http://sebdah.github.com/dynamic-dynamodb/',
keywords="dynamodb aws provisioning amazon web services",
platforms=['Any'],
packages=['dynamic_dynamodb'],
scripts=['dynamic-dynamodb'],
include_package_data=True,
zip_safe=False,
install_requires=[
'boto >= 2.6.0'
],
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Console',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python'
]
)