Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
519 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 Answer

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'})

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...