Skip to content Skip to sidebar Skip to footer

How Can I Include The Parent Folder Structure On A Library Distribution In Python 3.6 Using Setuptools?

I am using setuptools to distribute a Python library. I have the following directory structure: /src /production setup.py /prod-library /package1

Solution 1:

I found the solution to the problem. It has to do with how the package_dir was configured:

package_dir={'': '.'}

Although the above package_dir built the files and included all subfolders as expected, the egg-info file's SOURCES.txt was incorrect and showing as follows:

    ./prod-library/__init__.py
    ./prod-library/package1/__init__.py
    etc...

When the package was imported into another API, the imports could not be found when attempting import prod-libary.package1.file.py

After changing the package_dir as follows, I was able to use the library normally:

package_dir={'.': ''}

The above effectively removed the ./ prefix in the SOURCES.txt file which was breaking the imports. Now the egg-info's SOURCES.txt looks correct:

    prod-library/__init__.py
    prod-library/package1/__init__.py
    etc...

Post a Comment for "How Can I Include The Parent Folder Structure On A Library Distribution In Python 3.6 Using Setuptools?"