0

I am encountering an issue while uploading my Python package to PyPI. I have followed the standard steps for creating a distribution package using python setup.py sdist and python setup.py bdist_wheel, but the resulting package on PyPI has an unexpected directory structure.

I have a Python project with the following structure:

my_project/
|-- setup.py
|-- my_module/
    |-- __init__.py
    |-- ...

After running python setup.py sdist and python setup.py bdist_wheel, the dist directory contains both a .tar.gz file and a .whl file.

Upon uploading to PyPI using twine upload dist/*, the package is successfully uploaded, but when users download and install it, they find an unexpected directory structure in their site-packages:

site-packages/
|-- my_project-1.0.0.dist-info/
    |-- ...

What should i do?

Edit:

my_project/
|-- setup.py
|-- my_module/
    |-- __init__.py
    |-- screen.py
    |-- test.txt
    |-- my_module/
        |-- dependency_links.txt
        |-- PKG-INFO
        |-- requires.txt
        |-- SOURCES.txt
        |-- top_level.txt
|-- dist/
    |-- my_module-1.1.5-py3-none-any.whl
    |-- my_module-1.1.5.tar.gz
|-- build/
    |-- bdist.win-amd64
    |-- lib/
        |-- __init__.py
        |-- screen.py
site-packages/
|-- my_project-1.0.0.dist-info/
    |-- INSTALLER
    |-- METADATA
    |-- RECORD
    |-- REQUESTED
    |-- top_level.txt
    |-- WHEEL
6
  • 1
    There's nothing you can do about it - it's part of the process of the installation - packaging.python.org/en/latest/specifications/… Commented Jan 28, 2024 at 19:04
  • @AnyaShenanigans There are none of my scripts inside of my project. Is this normal? Commented Jan 28, 2024 at 19:08
  • I'm not understanding the comment - are you saying that the folder structure isn't in your project and you're wondering where it comes from, or are you missing the various .py package files from your package? Commented Jan 28, 2024 at 19:48
  • Your code is installed under the my_module directory not in my_project. Former is import package, latter is distribution package. See glossary: packaging.python.org/en/latest/glossary Commented Jan 28, 2024 at 19:48
  • 1
    This last edit you made does not bring much useful information. -- I recommend you rewrite the question to show the content of setup.py (no need to write an "edit" paragraph at the end, we can look at the history ourselves). -- I also recommend you study this tutorial thoroughly: packaging.python.org/en/latest/tutorials/packaging-projects Commented Jan 28, 2024 at 22:01

1 Answer 1

-1

I figured it out. I had to include this in my setup.py file:

    package_data={
        'my_module': ['__init__.py', 'screen.py'],
    },
Sign up to request clarification or add additional context in comments.

1 Comment

That seems like a very incorrect way to go about it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.