Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
508 views
in Technique[技术] by (71.8m points)

python - Confused about the package_dir and packages settings in setup.py

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If I understand correctly, the paths in package_dir should stop at the parent directory of the directories which are Python packages. In other words, try this:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...