Confused about the package_dir and packages settings in setup.py

杀马特。学长 韩版系。学妹 提交于 2019-12-03 19:19:30

问题


Here is my project directory structure, which includes the project folder, plus a "framework" folder containing packages and modules shared amongst several projects which resides at the same level in the hierarchy as the project folders:

--------------------------------------------------------------
Framework/
    package1/
        __init__.py
        mod1.py
        mod2.py
    package2/
        __init__.py
        moda.py
        modb.py

My_Project/
    src/
        main_package/
             __init__.py
             main_module.py
    setup.py
    README.txt
--------------------------------------------------------------

Here is a partial listing of the contents of my setup.py file:

--------------------------------------------------------------
from distutils.core import setup

setup(packages=['package1',
        'package2.moda',
        'main_package'],
    package_dir={'package1': '../Framework/package1', 
        'package2.moda': '../Framework/package2', 
        'main_package': 'src/main_package'})

--------------------------------------------------------------

Here are the issues:

  1. No dist or build directories are created

  2. Manifest file is created, but all modules in package2 are listed, not just the "moda.py" module

  3. The build terminates with an error: README.txt: Incorrect function

I don't know if I have a single issue (possibly related to my directory struture) or if I have multiple issues but I've read everything I can find on distribution of Python applications, and I'm stumped.


回答1:


IIUC correctly the paths in package_dir should stop at the parent directory of the directories which are Python packages. IOW try this:

package_dir={'package1': '../Framework', 
             'package2': '../Framework', 
             'main_package': 'src'})


来源:https://stackoverflow.com/questions/17155804/confused-about-the-package-dir-and-packages-settings-in-setup-py

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!