Search code examples
pythonpython-3.xpython-wheel

Python wheel does not contain project after using bdist_wheel while __init__.py is in root


I have a project that I want to distribute using a whl. I have a project tree that looks like this:

ProjectName
    ModuleFolder
       some_modules.py
    ModuleFolder2
        more_modules.py
    __init__.py
    main.py
    requirements.txt
    setup.py

My setup.py looks like this:

from setuptools import setup, find_packages

setup(
    name='ProjectName',
    version='1.0',
    author='Menno Manheim',
    author_email='[email protected]',
    description='Project description',
    packages=find_packages()
)

Now I am trying to create a wheel package like this:

python setup.py bdist_wheel

There is a whl package created, but it only contains one folder. It is named "ProjectName-1.0.dist.info" and in this folder I can see only these 1KB files:

MEDADATA
RECORD
top_level.txt
WHEEL

I expected that the whl file would contain the complete ProjectName tree including the root files.

What have I missed?

Btw. I am working in PyCharm and I am using a venv.


Solution

  • the find_packages() function, does not find your packages because you did not declared your ModuleFolder and ModuleFolder as such.

    You should insert __init__.py to both folders.

    In addition, please note that the root folder is not a package so the __init__ there is redundant.

    Edit: Formal sample project structure from the python packaging Authority (PyPA) can be found here.