pypa / setuptools

Official project repository for the Setuptools build system
https://pypi.org/project/setuptools/
MIT License
2.53k stars 1.19k forks source link

Installing, Building a package - generates unnecessary files? .egg-info/ build/ #4198

Open VladimirFokow opened 9 months ago

VladimirFokow commented 9 months ago

Discussed in https://github.com/pypa/setuptools/discussions/4197

See the discussion - it has several references to people having this issue (including an upvoted stackoverflow question that has the old api: python setup.py sdist)

The issue #1347 dealt with the same problem but with the now deprecated api. The api has changed but the issue remains. The current issue is concerned with pip install ., pip install -e ., python -m build (and possibly, other commands which lead to this behavior which I could just miss now).


Description of the issue:

Assuming the src-layout:

These auto-generated folders seem completely unnecessary, yet they pollute the source code repository, and not all beginner users would know how to best deal with them.


Suggested solutions:

  1. At the very least, this behavior should be acknowledged in the Docs, and there should be advice to add the appropriate patterns for each command to .gitignore, e.g.: *.egg-info/, build/, dist/ -- done

  2. Moreover, this issue:

    • needs investigation of the origins of this mechanism; is this behavior actually needed for something, or it is truly a "historical artifact nobody thought of addressing" and should be cleaned up.
    • if it's needed and should stay - then it definitely should be described in the documentation: good introduction, rationale, as well as advice and a good example how to deal with it, or how people usually deal with it.
abravalheri commented 9 months ago

Hi @VladimirFokow please note that things are not very simple when it comes to .egg-info. The .egg-info folders contain entry_points.txt, which in turn is used by importlib.metadata.

Packages may need to rely on that mechanism to bootstrap plugins during build time. Setuptools itself currently uses that mechanism.

Regarding your comments:

Suggested solutions:

  1. At the very least, this behavior should be acknowledged in the Docs, and there should be advice to add the appropriate patterns for each command to .gitignore, e.g.: *.egg-info/, build/, dist/
  2. Moreover, this issue:
  • needs investigation of the origins of this mechanism; is this behavior actually needed for something, or it is truly a "historical artifact nobody thought of addressing" and should be cleaned up.
  • if it's needed and should stay - then it definitely should be described in the documentation: good introduction, rationale, as well as advice and a good example how to deal with it, or how people usually deal with it.

For this we need all the help we can get. Please feel free to proceed with the investigation and/or submit pull requests (we can iteratively find what is the best wording for the docs, but in general it is good to assume that there is no clear cut recommendation that will fit everyone, and that different workflows/usages will entail different "good practices").

VladimirFokow commented 9 months ago