简体   繁体   中英

Why find_packages(exclude=xxx) does not work when doing setup.py sdist?

I am packaging my source code, but I do not want to include tests and docs because it will be too big.

To do that I include in my setup.py:

setup(...
      packages=find_packages(exclude=['tests.*','tests','docs.*','docs']),
      ...
)

When doing a

python setup.py sdist

I can see that my root tests/ and docs/ dirs and everything inside are still included in the generated distribution.

It seems that only

python setup.py bdist

is sensible to the exclude parameter.

Why? is it possible to exclude dirs for 'setup.py sdist'?

我通过删除* .egg-info /目录解决了这个问题:似乎这个目录记住了一些较旧的设置......

I had the same problem, but I was being dumb and misusing the exclude parameter.

If you have

packages=setuptools.find_packages(exclude="tests")

You will be excluding the directories "t", "e", "s", "t", "s"

What you should have is this:

packages=setuptools.find_packages(exclude=["tests"])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM