pypa / setuptools

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

ignores include_package_data if package_dir is also used #287

Open ghost opened 10 years ago

ghost commented 10 years ago

Originally reported by: dwt (Bitbucket: dwt, GitHub: dwt)


Hi all,

debugging our installer has brought to my attention that setuptools might have a bug where include_package_data=True is ignored if a directive like package_dir = {'demonstrator': '.'}, is used to mark the root folder of the repository as being the root package of the repository.

Please see https://github.com/dwt/sdist_ignores_include_package_data/ for a demonstration of this problem.

To reproduce try:

$ mktmpenv
$ cd /wherever/you/like
$ svn co https://github.com/dwt/sdist_ignores_include_package_data/trunk sdist_ignores_include_package_data
$ cd sdist_ignores_include_package_data
$ ./setup.py install
$ ls data # compare
$ cdsitepackages
$ ls sdist_ignores_include_package_data-0.1-py2.7.egg/demonstrator # against this

As far as I understand setup tools this should result in data/data.txt being inside the demonstrator package - but it is not.

From fiddling with this, it seems that this might be caused by an interact of the package_dir = {'demonstrator': '.'}, rule, as changing the repo layout to have a real demonstrator package (i.e. moving init.py and data into a demonstrator folder and leaving out that setup directive) it the data directory gets installed correctly.

One workaround that I found is to generate a package_data rule that forces inclusion of the data files in question - but that defeats the whole purpose of include_package_data.

Is package_dir the culprit here? Or is this caused by something else?

Companion pip bug: https://github.com/pypa/pip/issues/2127


ghost commented 10 years ago

Original comment by dwt (Bitbucket: dwt, GitHub: dwt):


I have to say that I quite like that. I really do not like it if packages have a different layout on disk than they have when installed.

That being said: does this mean that package source trees cannot have their packages in a src directory or something similar anymore?

ghost commented 10 years ago

Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco):


I suspect this comment is relevant: https://bitbucket.org/pypa/setuptools/src/8fcfefbe42a5e1c758a1406d916dd1b6268b3296/setuptools/command/sdist.py?at=default#cl-175

If one trusts that comment, the include_package_data is incompatible with inclusion of build_py.data_files.

I invite someone to investigate and determine if that comment still holds. If it does, this issue won't have an easy fix. In any case, there is only one mention of 'package_dir' in setuptools and it's not relevant, so any investigation is going to have to involve distutils as well.

I'm slightly tempted to deprecate package_dir altogether.

ghost commented 10 years ago

Original comment by rbuchholz (Bitbucket: rbuchholz, GitHub: rbuchholz):


pip closes their issue as they only call into setuptools, so this needs a fix here.

ghost commented 10 years ago

Original comment by dwt (Bitbucket: dwt, GitHub: dwt):


Hi there,

I'd love to get a reaction to this! Do you need any more details to handle this issue? Anything?

Regards!