LinuxCNC / linuxcnc

LinuxCNC controls CNC machines. It can drive milling machines, lathes, 3d printers, laser cutters, plasma cutters, robot arms, hexapods, and more.
http://linuxcnc.org/
GNU General Public License v2.0
1.81k stars 1.16k forks source link

Dropped use of depricated python3-setuptools / distutils. #3158

Closed petterreinholdtsen closed 1 month ago

petterreinholdtsen commented 1 month ago

Make sure sysconfig.get_path("platlib") return correct path on Debian systems, where /usr/lib/ should be used over /usr/local/lib.

Based on e2c10a8ac20c37c231367d3731c79846082b3a53 by Andy Pugh,

Fixes Debian issue #1080668.

petterreinholdtsen commented 1 month ago

See also #3154 and https://bugs.debian.org/1080668 .

petterreinholdtsen commented 1 month ago

I do not understand why configure still report "checking for site-package location... /usr/lib/python3.9/dist-packages" on bullseye, when it should be reporting /usr/lib/python3/dist-packages after my regex rewrite. When running the code in question manually on bullseye, the correct path show up.

petterreinholdtsen commented 1 month ago

[andypugh]

Bullseye is not supported by the master branch any more, anyway. Though arguably this fix needs to go into 2.9 to get tinto Trixie if Trixie is to lose distutils.

Good point. I'll try to remember to rebase on 2.9 when I am happy with the change. I do not like that I have no idea why the python oneliner still fail on bullseye, and am thus reluctant to merge it anywhere.

-- Happy hacking Petter Reinholdtsen

andypugh commented 1 month ago

[andypugh] Bullseye is not supported by the master branch Good point.

It wasn't a good point, I deleted it, but not fast enough.

Buster is not supported, Bullseye is still supported (and, in fact, current?) http://wiki.linuxcnc.org/cgi-bin/wiki.pl?MinimumSoftwareVersions

Eckeneckepen commented 1 month ago

Configure has the following result: 2024-10-20T14:44:57.8858950Z checking for Python site-packages path... /usr/lib/python3.9/site-packages instead of the required /usr/lib/python3/dist-packages

If you call your python statement, you get 3 rows. The last one is correct. Configure seems to consider the first row only: python3 -c 'import sysconfig; import re; p1=sysconfig.get_path("platlib"); print(p1); p2=p1.replace("/site-packages", "/dist-packages"); print(p2); print(re.sub("/python3[^/]+/","/python3/", p2))' =>

/usr/lib/python3.9/site-packages
/usr/lib/python3.9/dist-packages
/usr/lib/python3/dist-packages

If you remove the unnecessary print()s it should work on Bullseye: python3 -c 'import sysconfig; import re; p1=sysconfig.get_path("platlib"); p2=p1.replace("/site-packages", "/dist-packages"); print(re.sub("/python3[^/]+/","/python3/", p2))' => /usr/lib/python3/dist-packages

But it won't work on Bookworm due to an additional "local": python3 -c 'import sysconfig; import re; p1=sysconfig.get_path("platlib"); p2=p1.replace("/site-packages", "/dist-packages"); print(re.sub("/python3[^/]+/","/python3/", p2))' => /usr/local/lib/python3/dist-packages

Possible solution, but then you can also hardcode it directly: python3 -c 'import sysconfig; import re; p1=sysconfig.get_path("platlib"); p2=p1.replace("/site-packages", "/dist-packages"); p3=re.sub("/python3[^/]+/","/python3/", p2); print(p3.replace("local/", ""))'

dist-packages is only used by Debian and its derivates and not by other distributions. This solution is incompatible to non-Debian distributions.

Why not using my proposal? https://github.com/LinuxCNC/linuxcnc/pull/3155

It hard codes the old Bullseye only. This could be replaced by python3 -c 'import sysconfig; import re; p1=sysconfig.get_path("platlib"); p2=p1.replace("/site-packages", "/dist-packages"); print(re.sub("/python3[^/]+/","/python3/", p2))'

petterreinholdtsen commented 1 month ago

See #3159 for new upstream editions of the ax_python*.m4 files.