@@ -126,23 +126,31 @@ def _add_defaults_python(self):
126
126
if self .distribution .has_pure_modules ():
127
127
build_py = self .get_finalized_command ('build_py' )
128
128
self .filelist .extend (build_py .get_source_files ())
129
+ self ._add_data_files (self ._safe_data_files (build_py ))
129
130
130
- # This functionality is incompatible with include_package_data, and
131
- # will in fact create an infinite recursion if include_package_data
132
- # is True. Use of include_package_data will imply that
133
- # distutils-style automatic handling of package_data is disabled
134
-
135
- if self .distribution .include_package_data :
136
- self .warn (
137
- "Either specify package_data manually, or use "
138
- "include_package_data=True, but not both. Proceeding as if "
139
- "package_data was not specified."
140
- )
131
+ def _safe_data_files (self , build_py ):
132
+ """
133
+ Extracting data_files from build_py is known to cause
134
+ infinite recursion errors when `include_package_data`
135
+ is enabled, so suppress it in that case.
136
+ """
137
+ if self .distribution .include_package_data :
138
+ self .warn (
139
+ "Distutils 'package_data' ignored due to "
140
+ "'include_package_data'."
141
+ )
142
+ return ()
143
+ return build_py .data_files
141
144
142
- else :
143
- for _ , src_dir , _ , filenames in build_py .data_files :
144
- self .filelist .extend ([os .path .join (src_dir , filename )
145
- for filename in filenames ])
145
+ def _add_data_files (self , data_files ):
146
+ """
147
+ Add data files as found in build_py.data_files.
148
+ """
149
+ self .filelist .extend (
150
+ os .path .join (src_dir , name )
151
+ for _ , src_dir , _ , filenames in data_files
152
+ for name in filenames
153
+ )
146
154
147
155
def _add_defaults_data_files (self ):
148
156
try :
0 commit comments