创建包含多个python文件的软件包

时间:2020-01-15 17:21:02

标签: python package setuptools

我有一个文件夹结构:

setup_seplot.py
seplot/
        __init__.py      (empty)
        seplot.py
        kw_dictionaries.py

在seplot.py中,我有:

import kw_dictionaries as kd

如果我运行seplot.py,一切正常。

但是,当我使用setup_seplot.py时出现问题:

python setup_seplot.py sdist bdist_wheel
Traceback (most recent call last):
  File "setup_seplot.py", line 2, in <module>
    from seplot import seplot as sep
  File "/home/XXXXX/code/Python-Tools/seplot/seplot.py", line 14, in <module>
    import kw_dictionaries as kd
ModuleNotFoundError: No module named 'kw_dictionaries'

此问题似乎是由于在setup_seplot中,我导入了seplot以获取版本:

setup_seplot.py:

from setuptools import setup, Extension, find_packages
from seplot import seplot as sep

version=sep.__VERSION__
setup(
     name='seplot',
     version=version,
     description="A front-end for Python PyX",
     install_requires=[ 'pyx', ],
     packages=find_packages(),
     scripts=['seplot/bin/seplot','seplot/seplot.py',
        'seplot/kw_dictionaries.py','seplot/style_dictionaries.py']
 )

如果在seplot.py中,我替换

import kw_dictionaries as kd

作者:

from . import kw_dictionaries as kd

然后,安装程序可以正常运行,但是代码(setup.py)不能正常运行。 我在这里很迷路。

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:-1)

根据another topic的建议,在Gocht中找到了解决方案。

感觉很笨拙,我似乎不明白为什么,但这可行:

<item name="android:windowFullscreen">true</item>