Reputation: 78
I have created a python library whose structure looks like this.
|/library_name
| |__init__.py
| |/subpackage
| | |__init__.py
| | |
|setup.py
|setup.cfg
|LICENSE
Now when i published in pypi, I couldn't see the inner subpackages installed along with it. What should I do? What should be in outer __init__.py
. Assume inner __init__.py
has classes which I have written. Somebody please help how to add subpackages to the python library.
Here's the setup.py format
setup(
name = 'package',
packages = ['package'],
version = '1.0.1',
license='GNU General Public Version 3',
description = 'Package is the open source Python Library for solving various AI needs',
long_description = long_description,
long_description_content_type = "text/markdown",
author = ['Vigneshwar K R'],
author_email = '[email protected]',
url = 'https://github.com/ToastCoder/repo',
download_url = 'https://github.com/ToastCoder/repo/archive/master.zip',
keywords = ['ARTIFICIAL INTELLIGENCE', 'TENSORFLOW'],
install_requires=['tensorflow'],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'Intended Audience :: Education',
'Topic :: Software Development :: Build Tools',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9'
],
)
Upvotes: 0
Views: 1648
Reputation: 320
Could you share said setup.py
& __init__.py
codes please ?
I see two ways to deal with this :
make the content from lib/submodule
available from the top level : in lib/__init__.py
add from submodule import *
, then add every imported name in __all__
. As far as i know, this is bad practice everywhere BUT inside of __init__.py
s
add the submodule directory to setup.py's packages
parameter : packages=["lib", "lib.submodule"]
edit: as i expected, submodule
is missing from the packages
parameter, so it is not considered needed.
the find_packages
option commented about has the same effect as adding lib.submodule
to the packages list, it is mainly used in large libraries where adding every single module manually would be a pain.
Upvotes: 2