Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python configures broken symlinks for idle and 2to3 #54154

Open
o-alquimista opened this issue Jan 30, 2025 · 5 comments · May be fixed by #54161
Open

Python configures broken symlinks for idle and 2to3 #54154

o-alquimista opened this issue Jan 30, 2025 · 5 comments · May be fixed by #54161
Labels
bug Something isn't working needs-testing Testing a PR or reproducing an issue needed

Comments

@o-alquimista
Copy link
Contributor

o-alquimista commented Jan 30, 2025

Is this a new report?

Yes

System Info

Void 6.12.11_1 x86_64 GenuineIntel uptodate rrmFFFFF

Package(s) Affected

python3-3.13.1_1

Does a report exist for this bug with the project's home (upstream) and/or another distro?

No response

Description

The python3 package configures, through the "alternatives" system, the executables idle and 2to3:

$ xbps-alternatives --list
python
 - python3 (current)
  - idle:/usr/bin/idle3.13
  - 2to3:/usr/bin/2to3-3.13
  - pydoc:/usr/bin/pydoc3.13
  - python:/usr/bin/python3.13
  - python.1:/usr/share/man/man1/python3.13.1

This happens even if you don't have these tools installed:

$ idle
bash: idle: command not found
$ 2to3
bash: 2to3: command not found
$ ls -l /usr/bin/idle
lrwxrwxrwx 1 root root 8 Jan 29 18:53 /usr/bin/idle -> idle3.13
$ ls -l /usr/bin/2to3
lrwxrwxrwx 1 root root 9 Jan 29 18:53 /usr/bin/2to3 -> 2to3-3.13

This results in the creation of broken symlinks in your PATH, which generates a lot of warnings when you run a program launcher like Fuzzel.

Fuzzel maintainer dnkl told me there's nothing they can do to fix this on their end, and that this is a Void problem.

Since the alternatives system is responsible for creating the symlinks every time the package is updated, I need to figure out how to disable these symlinks:

  - idle:/usr/bin/idle3.13
  - 2to3:/usr/bin/2to3-3.13

I could also install these executables. While there is a package that provides IDLE (idle-python3), I could not find any package for 2to3 in the repository.

After reading the xbps-alternatives manpage and help info, it doesn't seem to be possible to change these specific entries. Any ideas on how to solve this?

@o-alquimista o-alquimista added bug Something isn't working needs-testing Testing a PR or reproducing an issue needed labels Jan 30, 2025
@Vinfall
Copy link
Contributor

Vinfall commented Jan 31, 2025

This is placed in the wrong place:

alternatives="
python:idle:/usr/bin/idle${version%.*}
python:2to3:/usr/bin/2to3-${version%.*}

idle-python3 is just a symlink to python3-tkinter, but it has no alternatives set here. So actually /usr/bin/idle ALWAYS does NOT work, whether you have installed python3 and python3-tkinter.

AFAIK 2to3 isused to be a standard library, but is deprecated in Python3.11 and removed in Python3.13, so maybe remove it and move idle to python3-tkinter? Did not test it myself:

diff --git a/srcpkgs/python3-tkinter/template b/srcpkgs/python3-tkinter/template
index 73cc637cd..650f271cb 100644
--- a/srcpkgs/python3-tkinter/template
+++ b/srcpkgs/python3-tkinter/template
@@ -30,6 +30,8 @@ license="Python-2.0"
 distfiles="https://www.python.org/ftp/python/${version%rc*}/Python-${version}.tar.xz"
 checksum=9cf9427bee9e2242e3877dd0f6b641c1853ca461f39d6503ce260a59c80bf0d9
 
+alternatives="python:idle:/usr/bin/idle${version%.*}"
+
 if [ "$XBPS_TARGET_LIBC" = "glibc" ]; then
        makedepends+=" libxcrypt-devel"
 fi
diff --git a/srcpkgs/python3/template b/srcpkgs/python3/template
index b4f2829f0..1b974c759 100644
--- a/srcpkgs/python3/template
+++ b/srcpkgs/python3/template
@@ -32,8 +32,6 @@ checksum="9cf9427bee9e2242e3877dd0f6b641c1853ca461f39d6503ce260a59c80bf0d9
 skip_extraction="${_bluez}.tar.xz"
 
 alternatives="
- python:idle:/usr/bin/idle${version%.*}
- python:2to3:/usr/bin/2to3-${version%.*}
  python:pydoc:/usr/bin/pydoc${version%.*}
  python:python:/usr/bin/python${version%.*}
  python:python.1:/usr/share/man/man1/python${version%.*}.1"

Can you confirm this? @ahesford

@Vinfall
Copy link
Contributor

Vinfall commented Jan 31, 2025

Temporary solution:
If you are lazy or don't know how to recompile python3 with the patch above, you can also just delete the broken symlink, although it would appear next time python3 is upgraded or when you run commands like xbps-alternatives/xbps-reconfigure.

sudo rm /usr/bin/idle /usr/bin/2to3

@ahesford
Copy link
Member

We can certainly drop the dead 2to3 link.

Handling idle is a bit trickier. We can't just move the alternative to the subpackage without giving the new alternative a different name. That requires a corresponding change in python2 to avoid conflicts, and a manual conflict with prior versions of python2 (and python<3) to avoid conflicts with existing installations.

I suggest we just drop both symlinks from the alternative group and, rather than make a new group just for idle, we eliminate the uncredited symlink from python2 altogether and add it unconditionally in python3-tkinter, which would still need the aforementioned conflicts. This means it is still possible to swap python back to python2 with an alternative , but idle only ever points to the py3 version.

Eventually, we should drop the whole alternative group and force py2 users to use versioned executables exclusively. This probably breaks some ancient workflow and would merit an INSTALL.msg warning of the coming change.

@classabbyamp
Copy link
Member

is it necessary to split the python2 tkinter packages anymore?

@ahesford
Copy link
Member

Probably not. We can just have an omnibus py2 that omits the idle symlink.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-testing Testing a PR or reproducing an issue needed
Projects
None yet
4 participants