简体   繁体   中英

How to exclude git-untracked files with setup.py sdist

I am trying to release a package which is tracked by git, and I assumed setuptools would help me with that. But if I run

python3 sdist

I can see that it also copies untracked files (files that I have not added to git) from the package into the archive (which are temp-scripts I use for testing but are not needed for the package itself). Can I somehow ignore them, as I don't want to always remove them before packaging?

I use packages=find_packages() in the setup() and apart from packing too many files, everything seems to be working fine.

An hour of googling did only reveal a lot of people trying to exclude certain folders/packages.. which is not what I want. And I don't want to specify these files manually. I just want to say "please only pack git-versioned files, thank you".

Thanks for any help!

Cheers, Joschua

Edit: Changed the title to make clear, that I did not expect this to be default behavior.

setuptools is a python package. git is a completely separate software package for version control. The two don't even know about each other. However...

There is a setuptools-git package in PyPi that might help you do what you want to do:

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