Building a python egg, first letter is incorrectly removed from root file/folder name

Viewed 327

I'm trying to build an egg for my python project using setuptools, however, whenever I build an egg all of the contents are built with the first letter if each file/folder removed.

For example, my parent folder is called dp which gets renamed to p. I.e. when I unzip the egg file, I see a parent folder named p and another folder named GG-INFO (these should be named dp and EGG-INFO respectively). All of the other folders inside folder p are named correctly.

This is an issue because I reference functions in modules within that folder - e.g. from dp.module import function which doesn't work because it complains about not finding the folder dp (which is true since for some reason it's been renamed p).

My setup.py file looks like this:

from setuptools import setup, find_packages
setup(
    name="dp",
    version="1.0",
    author="XXXX",
    author_email="XXXX",
    description="Data pipeline for XXX algorithm.",
    long_description_content_type="text/markdown",
    url="XXXX",
    packages=find_packages(),
    package_data={'': ['*.sql', '*.json', '*.txt']},
    include_package_data=True,
    classifiers=[
        "Programming Language :: Python :: 3"
    ],
    python_requires='>=3.6',
    install_requires=['argparse', 'boto3', 'datetime', 'mmlspark', 'pandas', 'pyspark', 'pypandoc', 'scikit-learn',
                      'numpy', 'googleads', 'mlflow']
)

I've tried renaming the parent directory and the same thing happens. I'm running this via PyCharm (updated to the latest version) on Mac OS Mojave.

Would appreciate any ideas on how to fix this.

File Structure

Renamed folders

Update: I used a different method to generate the egg which unblocked me, but the issue still remains with the initial method.

Steps to reproduce

  • Create a new project in Pycharm
  • Add a setup.py file to root, see above.
  • Tools -> Run setup.py task -> bdist.egg
  • Generates an egg. Rename the extension to file_name.zip, unzip the file, check the contents of the folder.
  • I found that the first letter of the folder names was always missing (i changed the names of the folder and it consistently removed the first letter).

Workaround

  • Instead of building an egg via Pycharm, i used the command python setup.py bdist_egg in the terminal which created an egg without any issues.
  • I think this confirms it is a Pycharm bug(?). A colleague managed to intermittently reproduce this bug using Pycharm.
1 Answers

Give the wheel a try.

pip install wheel setuptools pip -U
pip wheel --no-deps --wheel-dir=build .
Related