Basically my python package is setup like:
module \_examples \_folder1 \_file1.py \_file2.py \_folder2 \_file1.py \_file2.py
Basically I want to just use:
package_data = { 'module': ['examples/*'], },
because my project always has people adding examples and I want it to be easy to list them from within my application. I can get it work for any FILE within examples, but not re-curse down through sub-directories. Is this possible?
Place the files that you want to include in the package directory (in our case, the data has to reside in the roman/ directory). Add the field include_package_data=True in setup.py. Add the field package_data={'': [... patterns for files you want to include, relative to package dir...]} in setup.py .
To build a source distribution, use the command line to navigate to the directory containing setup.py, and run the command python setup.py sdist.
Installing Python Packages with Setup.py To install a package that includes a setup.py file, open a command or terminal window and: cd into the root directory where setup.py is located. Enter: python setup.py install.
I believe what you're looking for is something like this for you setup.py
, which will recursively find any packages in the project, also be sure and include __init__.py
files to subdirectories for each package you want.
from setuptools import setup, find_packages setup(name='MySoftware', packages=find_packages() )
I came across this post and spent some time figuring out how to add specific sub-modules to my package, so I will post my solution here.
In my package root folder, I have a setup.py
file see doc
In this file, I have the following code:
from setuptools import setup with open("README.md", "r") as fh: long_description = fh.read() setup( name='package name', version='0.4.1', description='short description', long_description=long_description, long_description_content_type="text/markdown", url='repository url', author='My name', author_email='[email protected]', license='MIT', packages=['PackageName','PackageName.SubModule'], zip_safe=False, install_requires=[ 'dependecy1', ], classifiers=[ 'Development Status :: 3 - Alpha', 'License :: OSI Approved :: MIT License', 'Programming Language :: Python :: 3.7' ] )
The interesting part to answer the question, here is : packages=['PackageName','PackageName.SubModule'],
By following this syntax, you can include sub-modules to your main package distribution.
More info about all the others arguments can be found in the doc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With