Syncplay / syncplay

Client/server to synchronize media playback on mpv/VLC/MPC-HC/MPC-BE on many computers
http://syncplay.pl/
Apache License 2.0
2.12k stars 215 forks source link

Syncplay doesn't start on Python 3.12 #633

Closed Mikaela closed 1 week ago

Mikaela commented 1 year ago

Describe the bug

I am on Fedora 39 beta which ships with Python 3.12 and unable to ./syncplayClient.py.

└┌(%:~/src/github.com/syncplay/syncplay)┌- ./syncplayClient.py --help  
Traceback (most recent call last):
  File "/home/aminda/src/github.com/syncplay/syncplay/./syncplayClient.py", line 14, in <module>
    from syncplay import ep_client
  File "/home/aminda/src/github.com/syncplay/syncplay/syncplay/ep_client.py", line 3, in <module>
    from syncplay.clientManager import SyncplayClientManager
  File "/home/aminda/src/github.com/syncplay/syncplay/syncplay/clientManager.py", line 4, in <module>
    from syncplay.ui.ConfigurationGetter import ConfigurationGetter
  File "/home/aminda/src/github.com/syncplay/syncplay/syncplay/ui/ConfigurationGetter.py", line 8, in <module>
    from configparser import SafeConfigParser, DEFAULTSECT
ImportError: cannot import name 'SafeConfigParser' from 'configparser' (/usr/lib64/python3.12/configparser.py). Did you mean: 'RawConfigParser'?

To Reproduce Steps to reproduce the behavior:

  1. git clone ...
  2. mkdir venv
  3. python3 -m venv venv
  4. . venv/bin/activate
  5. python3 -m pip install requirements.txt
  6. ./syncplayClient.py

Expected behavior

Syncplay won't traceback

Screenshots

N/A

Version and platform:

Additional context

if I attempt to run ./syncplayClient.py without venv, I get more errors:


/home/aminda/src/github.com/syncplay/syncplay/syncplay/constants.py:115: SyntaxWarning: invalid escape sequence '\.'
  FILENAME_STRIP_REGEX = "[-~_\.\[\](): ]"
/home/aminda/src/github.com/syncplay/syncplay/syncplay/constants.py:116: SyntaxWarning: invalid escape sequence '\-'
  CONTROL_PASSWORD_STRIP_REGEX = "[^a-zA-Z0-9\-]"
/home/aminda/src/github.com/syncplay/syncplay/syncplay/constants.py:117: SyntaxWarning: invalid escape sequence '\+'
  ROOM_NAME_STRIP_REGEX = "^(\+)(?P<roomnamebase>.*)(:)(\w{12})$"
/home/aminda/src/github.com/syncplay/syncplay/syncplay/constants.py:165: SyntaxWarning: invalid escape sequence '\m'
  MPC64_EXECUTABLES = ["mpc-hc64.exe", "mpc-hc64_nvo.exe", "x64\mpc-hc\shoukaku.exe"]
/home/aminda/src/github.com/syncplay/syncplay/syncplay/constants.py:303: SyntaxWarning: invalid escape sequence '\.'
  MPLAYER_ANSWER_REGEX = "^ANS_([a-zA-Z_-]+)=(.+)$|^(Exiting)\.\.\. \((.+)\)$"
/home/aminda/src/github.com/syncplay/syncplay/syncplay/utils.py:278: SyntaxWarning: invalid escape sequence '\g'
  return re.sub(constants.ROOM_NAME_STRIP_REGEX, "\g<roomnamebase>", RoomName)
/home/aminda/src/github.com/syncplay/syncplay/syncplay/utils.py:456: SyntaxWarning: invalid escape sequence '\+'
  CONTROLLED_ROOM_REGEX = re.compile("^\+(.*):(\w{12})$")
/home/aminda/src/github.com/syncplay/syncplay/syncplay/utils.py:457: SyntaxWarning: invalid escape sequence '\d'
  PASSWORD_REGEX = re.compile("[A-Z]{2}-\d{3}-\d{3}")
Traceback (most recent call last):
  File "/home/aminda/src/github.com/syncplay/syncplay/./syncplayClient.py", line 14, in <module>
    from syncplay import ep_client
  File "/home/aminda/src/github.com/syncplay/syncplay/syncplay/ep_client.py", line 3, in <module>
    from syncplay.clientManager import SyncplayClientManager
  File "/home/aminda/src/github.com/syncplay/syncplay/syncplay/clientManager.py", line 4, in <module>
    from syncplay.ui.ConfigurationGetter import ConfigurationGetter
  File "/home/aminda/src/github.com/syncplay/syncplay/syncplay/ui/ConfigurationGetter.py", line 8, in <module>
    from configparser import SafeConfigParser, DEFAULTSECT
ImportError: cannot import name 'SafeConfigParser' from 'configparser' (/usr/lib64/python3.12/configparser.py). Did you mean: 'RawConfigParser'?

If I use python3.10 or python3.11, it will work, same with pypy3 which is 3.10.2. I haven't tried 3.11 which didn't work on another project (https://github.com/editorconfig-checker/editorconfig-checker.python/issues/28).

EchedelleLR commented 1 year ago

Tested recently with Python 3.11.

Sadly, GUI does not work there, because PySide2 is not ported to Python3.11 yet (https://pypi.org/project/PySide2/):

 Requires: Python >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <3.11 

Dependencies are installed properly for both no-gui and gui requirements but it fails to launch in GUI. I get the following errors trying it:

(.venv) echedey@echedey-devuan-pc:~/Applications/syncplay-1.7.0$ python syncplayClient.py
Attribute Qt::AA_EnableHighDpiScaling must be set before QCoreApplication is created.
Traceback (most recent call last):
  File "/home/echedey/Applications/syncplay-1.7.0/syncplayClient.py", line 17, in <module>
    ep_client.main()
  File "/home/echedey/Applications/syncplay-1.7.0/syncplay/ep_client.py", line 8, in main
    SyncplayClientManager().run()
  File "/home/echedey/Applications/syncplay-1.7.0/syncplay/clientManager.py", line 9, in run
    config = ConfigurationGetter().getConfiguration()
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/echedey/Applications/syncplay-1.7.0/syncplay/ui/ConfigurationGetter.py", line 553, in getConfiguration
    self._forceGuiPrompt()
  File "/home/echedey/Applications/syncplay-1.7.0/syncplay/ui/ConfigurationGetter.py", line 455, in _forceGuiPrompt
    for key, value in list(self._promptForMissingArguments().items()):
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/echedey/Applications/syncplay-1.7.0/syncplay/ui/ConfigurationGetter.py", line 420, in _promptForMissingArguments
    gc.run()
  File "/home/echedey/Applications/syncplay-1.7.0/syncplay/ui/GuiConfiguration.py", line 42, in run
    dialog = ConfigDialog(self.config, self._availablePlayerPaths, self.error, self.defaultConfig)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/echedey/Applications/syncplay-1.7.0/syncplay/ui/GuiConfiguration.py", line 1430, in __init__
    self.setWindowFlags(self.windowFlags() & Qt.WindowCloseButtonHint & ~Qt.WindowContextHelpButtonHint)
TypeError: 'PySide2.QtCore.Qt.WindowFlags' object cannot be interpreted as an integer

No GUI mode, works:

.venv) echedey@echedey-devuan-pc:~/Applications/syncplay-1.7.0$ python syncplayClient.py --no-gui
[14:04:52] Attempting to connect to [REDACTED]
ERROR:  Could not find media directory '/media/sdb1/Multimedia/Series/She-Ra and the Princesses of the Power (2018)/Season 1'. To update your list of media directories please select File->Set Media Directories from the menu bar and specify where Syncplay should look to find media files.
[14:04:55] Attempting secure connection
[14:04:55] Successfully reached [REDACTED] ([REDACTED])
[14:04:55] Secure connection established (TLSv1.3)
[14:04:55] Successfully connected to server
In room '[REDACTED]':
*<Echedey>* is not playing a file

MPV is launched and everything.

albertosottile commented 1 year ago

Tested recently with Python 3.11.

Sadly, GUI does not work there, because PySide2 is not ported to Python3.11 yet (https://pypi.org/project/PySide2/):

You can try with PySide6. We recently updated our vendor copy of Qt.py to support it and we already use it as binding on macOS.

EchedelleLR commented 1 year ago

I guess the requirements_gui.txt will have to be modified.

I will test in a while. Just that won't work with stable 1.7.0 since it is referencing PySide2.

EchedelleLR commented 1 year ago

Okay, tested.

It starts with PySide6.

Just had to edit requirements_gui.txt file, remove the first line referencing PySide2 and then remove the darwin marker for PySide6 and proceed to install them.

I tested the main GUI only as the room GUI returns the following error:

(venv) echedey@echedey-devuan-pc:~/Applications/syncplay-1.7.0$ ./syncplayClient.py
Traceback (most recent call last):
  File "/home/echedey/Applications/syncplay-1.7.0/./syncplayClient.py", line 17, in <module>
    ep_client.main()
  File "/home/echedey/Applications/syncplay-1.7.0/syncplay/ep_client.py", line 8, in main
    SyncplayClientManager().run()
  File "/home/echedey/Applications/syncplay-1.7.0/syncplay/clientManager.py", line 12, in run
    interface = ui.getUi(graphical=not config["noGui"], passedBar=menuBar)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/echedey/Applications/syncplay-1.7.0/syncplay/ui/__init__.py", line 17, in getUi
    ui = GraphicalUI(passedBar=passedBar)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/echedey/Applications/syncplay-1.7.0/syncplay/ui/gui.py", line 2109, in __init__
    self.setWindowFlags(self.windowFlags() & Qt.AA_DontUseNativeMenuBar)
                        ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for &: 'WindowType' and 'ApplicationAttribute'

This is after I press any of the buttons related to either run Syncplay or store config and run Syncplay.

EchedelleLR commented 1 year ago

I also tested to restore the defaults and try again in one of the main servers with the same error.

Et0h commented 1 year ago

@EchedeyLR Does changing the & operator to a | operator fix the operand error(s)?

EchedelleLR commented 1 year ago

Invalid too.

Maybe this operator was deprecated and end removed in this version?

EchedelleLR commented 1 year ago

Okay, these operators are called bitwise operators.

I will check for some change in Python 3.11.

EchedelleLR commented 1 year ago

Well, the documentation says that both arguments must be either integers or one of them must be a custom object overriding __and__() or __rand__().

I guess it is a point to start.

kilmanio commented 12 months ago

https://github.com/Syncplay/syncplay/pull/636 updates to 3.12

EchedelleLR commented 12 months ago

@kilmanio how is about GUI?

The issue is another way deep inside after this first issue.

kilmanio commented 12 months ago

@EchedeyLR runs fine for me

EchedelleLR commented 12 months ago

@kilmanio yes but on master or the stable release?

And with Python 3.11 and ensuring everything was changed to PySide6.

kilmanio commented 12 months ago

@EchedeyLR I forked master. Python 3.12 pyside2-5.15

I don't have pyside6 installed

EchedelleLR commented 12 months ago

PySide6 is needed for the GUI as it is supposed that PySide2 does not support the rest. I mean the Qt GUI.

kilmanio commented 12 months ago

I don't know what you want me to tell you; I am running syncplay with the gui, the only version of pyside I have is PySide2-5.15. I fixed the original issue, I have no problems with the gui.

EchedelleLR commented 12 months ago

But PySide2 is not supposed to be ported yet to Python 3.12 and it does not work with 3.11.

I think I will have to test master version or so to check again.

If you could read properly the history of this very same thread you would understand what I mean.

EchedelleLR commented 12 months ago

What I want to understand is why is working for you and not for me in a complete clean environment.

That is why I asked the info initially. I guess that if 3.12 works for you, 3.11 should work too, at least on master even if the other issue (GUI) was there as it was fixed somehow in master making it working for you.

Et0h commented 12 months ago

For the avoidance of doubt, my understanding is that the master @kilmanio is referring is their own master, i.e. https://github.com/kilmanio/syncplay which is the basis of the pull request at https://github.com/Syncplay/syncplay/pull/636 - you can get this version in tarball form at https://github.com/kilmanio/syncplay/archive/refs/heads/master.tar.gz

I can't speak for Python 3.11/12 as I've not used them yet, but having worked on compatibility issues in the past I can say that it does seem plausible on the face of it for something complicated to work with 3.12 but not with 3.11 as there might have been some sort of change that caused problems and was reverted, or a compatibility feature added.

teohhanhui commented 11 months ago

FWIW PySide2 is retired in Fedora 39 and Fedora 40: https://bugzilla.redhat.com/show_bug.cgi?id=2220452

Unfortunately, PySide6 is also not packaged for Fedora.

EDIT: Fortunately PyPI has an aarch64 build of PySide6: https://pypi.org/project/PySide6/#files

This leaves Fedora Asahi Remix users in limbo as there's no aarch64 build for the AppImage: https://github.com/Syncplay/syncplay/issues/368#issuecomment-1503008313

Et0h commented 9 months ago

Is this issue resolved by https://github.com/Syncplay/syncplay/commit/fc0d2c5268a74fa4e195a6058488f13410678f42 (included in Synclay 1.7.1 stable)?

teohhanhui commented 9 months ago

Seems to build fine for me without overriding anything.