0

I would like to upload my package to PyPI using setuptools. Unfortunately only __init__.py gets packaged, and files it imports are not packaged. As a result my package is distributed incomplete and fails on import. My file structure is as following:

./
./mypkg/__init__.py
./mypkg/folder1/class_a.py
./setup.py
./upload.sh

I am using following setup.py:

import setuptools

setuptools.setup(
    name="mypkg",
    version="0.0.2",
    packages=['mypkg'],
    classifiers=[
        "Programming Language :: Python :: 3",
        "License :: OSI Approved :: MIT License",
        "Operating System :: OS Independent",
    ],
)

Edit: The question is different from Why do I need to include sub-packages in setup.py in that it looks for any solutions to the problem, and linked question discusses the technical reasons for one of the possible solutions.

ikamen
  • 3,175
  • 1
  • 25
  • 47
  • 3
    Possible duplicate of [Why do I need to include sub-packages in setup.py](https://stackoverflow.com/questions/50083553/why-do-i-need-to-include-sub-packages-in-setup-py) – Dustin Ingram Apr 19 '19 at 15:18
  • This explains the matter, but answers a different (related) question. – ikamen Apr 19 '19 at 16:27

1 Answers1

1

solution was to list the needed directories like:

import setuptools

setuptools.setup(
    ...
    packages=['mypkg', 'mypkg.folder1'],
    ...
)

Further reading: Why do I need to include sub-packages in setup.py

ikamen
  • 3,175
  • 1
  • 25
  • 47