https://github.com/rickstaa/stand_alone_sub_package_folder_example
Example repository for including stand alone subpackages into other python packages.
https://github.com/rickstaa/stand_alone_sub_package_folder_example
Last synced: about 1 month ago
JSON representation
Example repository for including stand alone subpackages into other python packages.
- Host: GitHub
- URL: https://github.com/rickstaa/stand_alone_sub_package_folder_example
- Owner: rickstaa
- Created: 2020-12-07T12:58:52.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-06-12T16:23:42.000Z (almost 5 years ago)
- Last Synced: 2025-01-14T07:28:51.042Z (over 1 year ago)
- Language: Python
- Size: 17.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Stand alone sub package folder example
This is a small example repository you can use when you want to ship a stand-alone python package inside another python package. It was created as a simple test repository when I for one of my products needed a meta package that contained multiple packages that could also be installed individually. While doing so I wanted to make sure I did not have redundant folders in the package import name_space of the meta package. For example I want users to have the ability to import the `PythonClass` found under the `main_package.stand_alone_subpackage.stand_alone_subpackage.subpackage_module.python_module` under a shortened namespace `main_package.stand_alone_subpackage.subpackage_module.python_module`. Meaning I want to get rid of the redundant `stand_alone_subpackage` namespace that was created because the subpackage also has to work as a stand alone [pypi](https://pypi.org/) package.
## Current working methods
After asking [a question on stackoverflow](https://stackoverflow.com/questions/63464555/create-name-space-package-that-contains-standalone-installable-sub-package/63465830#63465830) I came up with a setup that allows getting rid of the redundant folder. The code for this is found in the `setup.py` file. Using this setup.py file you can install the package with the shortened namespace package using the `pip install .` command. I also looked for a way to put all this logic inside the setup.cfg file [see this issue on setuptools](https://github.com/pypa/setuptools/issues/2467). This however is not yet possible without converting all the sub packages to [name_space packages](https://packaging.python.org/guides/packaging-namespace-packages/) and using the [recommended name_space packages folder structure](https://github.com/pypa/sample-namespace-packages/tree/master/native). For my solution I did not want to do this since this makes the folder structure more complicated.