对setup.py中的package_dir和程序包设置感到困惑 [英] Confused about the package_dir and packages settings in setup.py

查看:556
本文介绍了对setup.py中的package_dir和程序包设置感到困惑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的项目目录结构,其中包括项目文件夹,以及
a框架文件夹,其中包含在多个项目
之间共享的包和模块,这些项目位于与项目文件夹相同的层次结构中:

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
--------------------------------------------------------------

这里是部分内容清单我的setup.py文件:

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

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

这是问题所在:


  1. 未创建dist或构建目录

  1. No dist or build directories are created

已创建清单文件,但未列出package2中的所有模块只是 moda.py模块

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

构建因以下错误终止:
README.txt:函数不正确

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.

推荐答案

如果我正确理解的话,package_dir中的路径s应该停在Python软件包目录的父目录中。换句话说,请尝试以下操作:

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

这篇关于对setup.py中的package_dir和程序包设置感到困惑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆