我想做的是编译多个文件,并且它们的输出是一个模块。
项目:
ModuleA
|
+--file1.py
|
+--file2.py
|
+--setup.py
setup.py
from setuptools import setup
setup(
name='example',
version='1.0',
url='',
license='MIT',
author='Francisco',
author_email='',
description='',
package_dir={'ModuleA':'./*'},
py_modules=['file1','file2'],
zip_safe=False,
include_package_data=True,
platforms='any',
)
我需要的输出是 python setup.py install
site-packages
|
+--ModuleA
|
+--file1.py
+--file2.py
答案 0 :(得分:0)
ModuleA
从技术上讲是package。我建议您使用setuptools中的find_packages
实用工具:
from setuptools import setup, find_packages
setup(
name='example',
version='1.0',
url='',
license='MIT',
author='Francisco',
author_email='',
description='',
packages=find_packages(),
zip_safe=False,
include_package_data=True,
platforms='any',
)
目录结构:
$ tree
.
...
├── ModuleA
│ ├── file1.py
│ ├── file2.py
│ └── __init__.py
└── setup.py
现在构建软件包:
$ python setup.py bdist_wheel
....
$ unzip -l dist/example-1.0-py2-none-any.whl
Archive: dist/example-1.0-py2-none-any.whl
Length Date Time Name
--------- ---------- ----- ----
0 2018-09-27 21:53 ModuleA/file2.py
0 2018-09-27 21:53 ModuleA/file1.py
0 2018-09-27 21:53 ModuleA/__init__.py
10 2018-09-27 21:53 example-1.0.dist-info/DESCRIPTION.rst
305 2018-09-27 21:53 example-1.0.dist-info/metadata.json
8 2018-09-27 21:53 example-1.0.dist-info/top_level.txt
92 2018-09-27 21:53 example-1.0.dist-info/WHEEL
163 2018-09-27 21:53 example-1.0.dist-info/METADATA
693 2018-09-27 21:53 example-1.0.dist-info/RECORD
--------- -------
1271 9 files