Why does “python setup.py sdist” create unwanted “PROJECT-egg.info” in project root directory?

前端 未结 4 826
我在风中等你
我在风中等你 2020-12-15 02:57

When I run

  python setup.py sdist

it creates an sdist in my ./dist directory. This includes a \"PROJECT-egg.info\" file in the zip inside

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-15 03:17

    Pythons packaging and build system is broken imho. So there are many hacks and workarounds for things that one would belive work out of the box.

    However, the "cleanest" hack I found for deleting the *.egg-info is using the normal clean --all switch along with the egg_info to place the *.egg-info file in a subfolder that will be cleaned by the clean command. Here an example:

    In your setup.cfg use something like this:

    [egg_info]
    egg_base = ./build/lib
    

    where ./build/lib is a folder that clean --all will delete. Then when building your project with setuptools use the clean command with the --all flag, e.g.

    python setup.py bdist_wheel clean --all

    if you want to build a source bundle as well just make sure to build bdist_wheel before sdist so the build/lib folder exists, e.g.:

    python setup.py bdist_wheel sdist clean --all

提交回复
热议问题