pypa / pypa/setuptools

ignores include_package_data if package_dir is also used

Open
#287 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug major
Dominant language
Python
Stars
2.9k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
1

Description

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


Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the behavior in the linked sdist_ignores_include_package_data example by running ./setup.py install, then compare data with the installed egg contents. Start by inspecting the setup.py configuration using package_dir and include_package_data. Done means package data is included when both directives are used, with the reported installation comparison passing.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.