setuptools:找不到文件dynamic_dynamodb.py(对于模块dynamic_dynamodb)

时间:2013-03-25 19:51:40

标签: python setuptools

我正在尝试构建我相当简单的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

有没有人能指引我朝正确的方向发展?

1 个答案:

答案 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'
    ]
)