egg_info comand fails parsing manifest template with Python 3 and SVN working dir
I have a project (python-rtmidi), which uses setuptools in the
setup.py file and I build in a SVN checkout. I have a
MANIFEST.in template to include examples and gererated files in the source distribution.
python setup.py sdist fails at the
egg_info command step with this exception:
reading manifest template 'MANIFEST.in' Traceback (most recent call last): File "setup.py", line 151, in <module> **setup_opts File "/usr/lib64/python3.3/distutils/core.py", line 148, in setup dist.run_commands() File "/usr/lib64/python3.3/distutils/dist.py", line 929, in run_commands self.run_command(cmd) File "/usr/lib64/python3.3/distutils/dist.py", line 948, in run_command cmd_obj.run() File "/home/chris/lib/virtualenvs/rtmidi33/lib/python3.3/site-packages/setuptools/command/sdist.py", line 86, in run self.run_command('egg_info') File "/usr/lib64/python3.3/distutils/cmd.py", line 313, in run_command self.distribution.run_command(command) File "/usr/lib64/python3.3/distutils/dist.py", line 948, in run_command cmd_obj.run() File "/home/chris/lib/virtualenvs/rtmidi33/lib/python3.3/site-packages/setuptools/command/egg_info.py", line 188, in run self.find_sources() File "/home/chris/lib/virtualenvs/rtmidi33/lib/python3.3/site-packages/setuptools/command/egg_info.py", line 231, in find_sources mm.run() File "/home/chris/lib/virtualenvs/rtmidi33/lib/python3.3/site-packages/setuptools/command/egg_info.py", line 301, in run self.read_template() File "/usr/lib64/python3.3/distutils/command/sdist.py", line 308, in read_template self.filelist.process_template_line(line) File "/usr/lib64/python3.3/distutils/filelist.py", line 124, in process_template_line if not self.exclude_pattern(pattern, anchor=1): File "/usr/lib64/python3.3/distutils/filelist.py", line 236, in exclude_pattern if pattern_re.search(self.files[i]): TypeError: can't use a string pattern on a bytes-like object
After quite some time spent tracking this down, I noticed that the file list generated by
setuptools.commands.egg_info.find_sources() contains paths as
bytes objects, which makes the
exclude_pattern method (see traceback) choke. These entries in the filelist are produced by the
setuptools.svn_utils.svn_finder function, which calls
fsencode on every path it yields.
fsencode encodes the unicode (Python 2) ressp. str (Python 3) path entries with the default encoding, turning them into str (Python 2) resp. bytes (Python 3) objects. I'm not exactly sure why it does that, but the result is clearly wrong for Python 3 and cuases the above error.
on line 426 (and
yield fsencode(sub_path) to
yield sub_path a few lines below in
setuptools.svn_utils.svn_finder fixed the issue for me. Probably breaks things on other systems though, so probably
fsencode/fsdecode should be fixed somehow.