Skip to content

[Needs review] Fix python site-packages dir#3916

Open
NTULINUX wants to merge 1 commit intoLinuxCNC:masterfrom
NTULINUX:fix-site-packages
Open

[Needs review] Fix python site-packages dir#3916
NTULINUX wants to merge 1 commit intoLinuxCNC:masterfrom
NTULINUX:fix-site-packages

Conversation

@NTULINUX
Copy link
Copy Markdown
Contributor

@NTULINUX NTULINUX commented Apr 9, 2026

Fixes the need for PYTHONPATH on Gentoo

@NTULINUX
Copy link
Copy Markdown
Contributor Author

NTULINUX commented Apr 9, 2026

Looks like this needs to be fixed to account for Debian..

dh_install: error: missing files, aborting

Ah, looks like various parts of the tree are also hard-coded to use /usr/lib/python3/dist-packages

docs/src/plasma/qtplasmac.adoc:/usr/lib/python3/dist-packages/qtvcp/designer/install_script
lib/python/qtvcp/designer/install_script:    if [ -f /usr/lib/python3/dist-packages/qtvcp/plugins/qtvcp_plugin.py ]; then
lib/python/qtvcp/designer/install_script:        pifile=/usr/lib/python3/dist-packages/qtvcp/plugins/qtvcp_plugin.py
lib/python/qtvcp/designer/install_script:        echo -e '\n'"$pifile "'not found in /usr/lib/python3/dist-packages/qtvcp/plugins/'
scripts/setup_designer.in:    if [ -f /usr/lib/python3/dist-packages/qtvcp/plugins/qtvcp_plugin.py ]; then
scripts/setup_designer.in:        pifile=/usr/lib/python3/dist-packages/qtvcp/plugins/qtvcp_plugin.py
scripts/setup_designer.in:        echo -e '\n'"$pifile"' not found in /usr/lib/python3/dist-packages/qtvcp/plugins/'

Did not see these. Any tips? The issue is that depending on the exact version of python that debian uses will affect the installation path, which will vary from each debian release, that's the tricky part to make this work across all versions. Not sure on a clean way to avoid the hard-coded variables either, as those will also change.

@NTULINUX NTULINUX changed the title Fix python site-packages dir [needs fixing] Fix python site-packages dir Apr 9, 2026
@BsAtHome
Copy link
Copy Markdown
Contributor

BsAtHome commented Apr 9, 2026

Is there a distro independent way to find out where python packages need to be installed?

@NTULINUX
Copy link
Copy Markdown
Contributor Author

NTULINUX commented Apr 9, 2026

Well that's what this should do:

https://github.com/LinuxCNC/linuxcnc/blob/master/src/m4/ax_python_devel.m4#L340

That's where I got PYTHON_SITE_PKG from. There's also python -c "import site; print(site.getsitepackages())"

That's going to change though distro to distro... The commands themselves are universal, the result is not.

PYTHON_SITE_PKG works but debian/linuxcnc.install.in needs to account for it. It is hard-coded to usr/lib/python3 as well as other parts of the tree.

git grep -e "usr/lib/python3"

Using PYTHON_SITE_PKG works for both a system-wide install though, and run-in-place.

I just checked in my Trixie VM and PYTHON_SITE_PKG is working as intended (both rip and system-wide install.)

Another problem is accounting for Fedora. PYTHON_SITE_PKG works there too but the hard-codes need to be fixed with a simple one-linger, not some 10 line script from autotools. Luckily, this works:

python3 -c "import site; print([p for p in site.getsitepackages() if p.startswith('/usr/lib') and '/local/' not in p and '/lib64/' not in p][0])"

Now I need to fix the other hard-codes but the upcoming code might be wrong..

@NTULINUX NTULINUX force-pushed the fix-site-packages branch from 9fc2a6c to b9b3f0a Compare April 10, 2026 17:35
@NTULINUX NTULINUX changed the title [needs fixing] Fix python site-packages dir [WIP] Fix python site-packages dir Apr 10, 2026
@NTULINUX NTULINUX force-pushed the fix-site-packages branch from b9b3f0a to 6146ae4 Compare April 10, 2026 18:23
@NTULINUX
Copy link
Copy Markdown
Contributor Author

This might be ready now. Not 100% certain.

@NTULINUX NTULINUX changed the title [WIP] Fix python site-packages dir [Needs review] Fix python site-packages dir Apr 10, 2026
@NTULINUX NTULINUX force-pushed the fix-site-packages branch from 6146ae4 to d4304da Compare April 13, 2026 14:36
@NTULINUX
Copy link
Copy Markdown
Contributor Author

NTULINUX commented Apr 13, 2026

Fixed typo, trimmed SITEPY a little. Fixed echo lines as $SITEPY was literal.

Fixes the need for PYTHONPATH on Gentoo

Signed-off-by: Alec Ari <neotheuser@ymail.com>
@NTULINUX NTULINUX force-pushed the fix-site-packages branch from d4304da to 3aac8b9 Compare April 13, 2026 14:43
AC_MSG_RESULT([$PYTHON_TK_VERSION])

AC_MSG_CHECKING(for site-package location)
SITEPY="$($PYTHON -c 'import sysconfig; s = sysconfig.get_scheme_names(); m=list(set(("deb_system", "rpm_prefix")) & set(s)); print(sysconfig.get_path("platlib", m.__getitem__(0))) if m else print("/usr/lib/python3/dist-packages");')"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Fedora 43, this returns:
/usr/lib64/python3.14/site-packages.
The other instances, in install_script and setup_designer.in, using import site; print([p for p in site.getsitepackages() if p.startswith('/usr/lib') and '/lib64/' not in p][0]) returns:
/usr/lib/python3.14/site-packages.

lib/lib64 difference... very strange.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As ugly as it may be, I can copy the logic from m4 and put it in install_script and setup_designer.in

I was just trying to avoid that..

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, you're talking about the old one, not PYTHON_SITE_PKG. I misunderstood. Currently, on fedora with my latest forced push, PYTHON_SITE_PKG and SITEPY in those files match.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I look in those two directories, then both are populated, but with different packages. I have no clue what goes into where. Maybe fedora docs can help?

Copy link
Copy Markdown
Contributor Author

@NTULINUX NTULINUX Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I noticed that too, I figured since PYTHON_SITE_PKG uses /lib instead of /lib64 to use that, plus /lib is more heavily populated.

fedora@fedora:~/dev/linuxcnc/src$ ls /usr/lib64/python3.14/site-packages | wc -l
120
fedora@fedora:~/dev/linuxcnc/src$ ls /usr/lib/python3.14/site-packages | wc -l
200

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There must be some documentation which distro wants what where. Better do it right than guess wrong?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/usr/lib64/python3.14/site-packages/: This directory is used for architecture-specific (binary) packages.

/usr/lib/python3.14/site-packages/: This directory is used for architecture-independent (pure Python) packages. These "noarch" packages consist only of .py files and byte-compiled .pyc files, which are not tied to a specific hardware architecture.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And that applies to Debian, Ubuntu, Gentoo and other distros too?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debian uses /usr/lib/python3/dist-packages for everything

Gentoo uses /usr/lib/python3.14/site-packages for everything

Fedora... :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants