Package: dh-python
Version: 6.20231025
Severity: important
X-Debbugs-Cc: stephanlach...@debian.org

A recent change in dh-python [1] causes an FTBFS in reuse [2].

In particular, this is the error that causes the FTBFS:
```
   dh_python3 -O--buildsystem=pybuild
Traceback (most recent call last):
  File "/usr/bin/dh_python3", line 292, in <module>
    main()
  File "/usr/bin/dh_python3", line 218, in main
    fix_locations(package, interpreter, SUPPORTED, options)
  File "/usr/share/dh-python/dhpython/fs.py", line 51, in fix_locations
    share_files(srcdir, dstdir, interpreter, options)
  File "/usr/share/dh-python/dhpython/fs.py", line 117, in share_files
    share_files(fpath1, fpath2, interpreter, options)
  File "/usr/share/dh-python/dhpython/fs.py", line 100, in share_files
    os.remove(fpath1)
IsADirectoryError: [Errno 21] Is a directory:
'debian/reuse/usr/lib/python3.11/dist-packages/reuse-2.1.0.dist-info/LICENSES'
```

The following lines cause this bug:
```python3
if i.startswith(('LICENCE', 'LICENSE', 'COPYING', 'NOTICE', 'AUTHORS')):
  os.remove(fpath1)
```

Instead of just blindly removing `fpath1`, it should be checked if this is a
file or a folder, and if it is a folder then `rmtree(fpath1)` should be called.
Alternatively a better file matching could be done (e.g. by checking the
filename before the file extension properly using pathlib).

Regards,
Stephan

[1]: https://salsa.debian.org/python-team/tools/dh-
python/-/commit/87907e588d1fc1ed52c5af4b9a7bded66666327d
[2]: https://bugs.debian.org/1054750


-- System Information:
Debian Release: trixie/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.5.9-x64v3-xanmod1 (SMP w/8 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, 
TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages dh-python depends on:
ii  python3             3.11.4-5+b1
ii  python3-distutils   3.11.5-1
ii  python3-setuptools  68.1.2-2

dh-python recommends no packages.

Versions of packages dh-python suggests:
ii  dpkg-dev           1.22.0
pn  flit               <none>
ii  libdpkg-perl       1.22.0
pn  python3-build      <none>
pn  python3-installer  <none>
ii  python3-wheel      0.41.2-1

-- no debconf information

Reply via email to