Bug 256504 - games/pysolfc 2.6.4 needs update due to python 3.8 incompatibility.
Summary: games/pysolfc 2.6.4 needs update due to python 3.8 incompatibility.
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Kai Knoblich
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-09 16:33 UTC by sven.a.jonsson
Modified: 2021-06-30 09:14 UTC (History)
2 users (show)

See Also:
kai: maintainer-feedback+
kai: merge-quarterly+


Attachments
pysolfc-fix-runtime-with-py38.patch (1.21 KB, patch)
2021-06-10 05:08 UTC, Kai Knoblich
kai: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description sven.a.jonsson 2021-06-09 16:33:50 UTC
The current 2.6.4 version of pysolfc crashes at startup on new install of FreeBSD 13.0 with

pysolfc
Traceback (most recent call last):
  File "/usr/local/bin/pysolfc", line 36, in <module>
    from pysollib.main import main  # noqa: E402,I202
  File "/usr/local/lib/python3.8/site-packages/pysollib/main.py", line 30, in <module>
    from pysollib.app import Application
  File "/usr/local/lib/python3.8/site-packages/pysollib/app.py", line 31, in <module>
    from pysollib.gamedb import GAME_DB, GI, loadGame
  File "/usr/local/lib/python3.8/site-packages/pysollib/gamedb.py", line 28, in <module>
    from pysollib.mfxutil import Struct, print_err
  File "/usr/local/lib/python3.8/site-packages/pysollib/mfxutil.py", line 146, in <module>
    uclock = time.clock
AttributeError: module 'time' has no attribute 'clock'

This was reported to upstream in "https://github.com/shlomif/PySolFC/issues/145" as an incompatibility with python 3.8 and is fixed in newer versions.
Comment 1 Kai Knoblich freebsd_committer freebsd_triage 2021-06-10 05:08:32 UTC
Created attachment 225684 [details]
pysolfc-fix-runtime-with-py38.patch

(In reply to sven.a.jonsson from comment #0)

Hi, 

thank you for the report!

Can you please try the attached patch? It should fix the issue with
"clock.time", that was removed in Python 3.8.

An update to 3.10.1 is not entirely trivial and requires more work than I
currently have time because.
Comment 2 Kai Knoblich freebsd_committer freebsd_triage 2021-06-10 05:13:24 UTC
^ Triage: Set maintainer-feedback and merge-quarterly (version in 2021Q2 branch is also affected) flags accordingly, adding external reference from comment #0 to "See also".
Comment 3 sven.a.jonsson 2021-06-10 06:12:01 UTC
Thank you so much for your quick response!
I have just applied the attached patch and built and installed pysolfc using synth, and I can verify that it appears to be fully functional.
Comment 4 Christopher 2021-06-26 02:28:28 UTC
I am experiencing the exact same issue.  I applied the patch and reinstalled the port and still the problem remains.

I checked the file /usr/local/lib/python3.8/site-packages/pysollib/mfxutil.py and the patch changes do seem to be there...

This is how the changed section of mfxutil.py looks now, after patching...

# high resolution clock() and sleep()
uclock = time.clock
usleep = time.sleep
if os.name == "posix":
    uclock = time.time

But, I still get the same errors as before patching.  So, I am not sure if there's a problem with the patch or perhaps I've done something wrong....

I am running FreeBSD 13.0-RELEASE-p2 (amd64) and pysolfc 2.6.4_1

Any thoughts or suggestions of what I could try next?
Comment 5 sven.a.jonsson 2021-06-26 06:22:09 UTC
(In reply to Christopher from comment #4)
It seems you are still running the old version.
The updated version should be 2.6.4_2.
Comment 6 commit-hook freebsd_committer freebsd_triage 2021-06-30 08:43:40 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=91cf30435554dda6bf71dc566f91352dd469d816

commit 91cf30435554dda6bf71dc566f91352dd469d816
Author:     Kai Knoblich <kai@FreeBSD.org>
AuthorDate: 2021-06-30 08:31:41 +0000
Commit:     Kai Knoblich <kai@FreeBSD.org>
CommitDate: 2021-06-30 08:41:15 +0000

    games/pysolfc: Fix runtime issues with Python 3.8+

    * The deprecated function "time.clock()" has been removed in Python 3.8
      and "time.perf_counter()" should be used instead.

      Because updating to a newer version of PySolFC requires a bit more
      work, use a backport for now to remedy the runtime issues.

    * Bump PORTREVISION due changed package contents.

    PR:             256504
    Reported by:    <sven.a.jonsson@bahnhof.se>
    MFH:            2021Q2

 games/pysolfc/Makefile                              |  2 +-
 games/pysolfc/files/patch-pysollib_mfxutil.py (new) | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)
Comment 7 commit-hook freebsd_committer freebsd_triage 2021-06-30 08:58:43 UTC
A commit in branch 2021Q2 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=cb3b365038fcaee997eb9e4006a7e2bfed6e5ab0

commit cb3b365038fcaee997eb9e4006a7e2bfed6e5ab0
Author:     Kai Knoblich <kai@FreeBSD.org>
AuthorDate: 2021-06-30 08:31:41 +0000
Commit:     Kai Knoblich <kai@FreeBSD.org>
CommitDate: 2021-06-30 08:56:01 +0000

    games/pysolfc: Fix runtime issues with Python 3.8+

    * The deprecated function "time.clock()" has been removed in Python 3.8
      and "time.perf_counter()" should be used instead.

      Because updating to a newer version of PySolFC requires a bit more
      work, use a backport for now to remedy the runtime issues.

    * Bump PORTREVISION due changed package contents.

    PR:             256504
    Reported by:    <sven.a.jonsson@bahnhof.se>
    MFH:            2021Q2

    (cherry picked from commit 91cf30435554dda6bf71dc566f91352dd469d816)

 games/pysolfc/Makefile                              |  2 +-
 games/pysolfc/files/patch-pysollib_mfxutil.py (new) | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)
Comment 8 Kai Knoblich freebsd_committer freebsd_triage 2021-06-30 09:12:05 UTC
(In reply to Christopher from comment #4)

> This is how the changed section of mfxutil.py looks now, after patching...
>
> # high resolution clock() and sleep()
> uclock = time.clock
> usleep = time.sleep
> if os.name == "posix":
>     uclock = time.time

The mfxutil.py file seems unchanged. It should contain the following lines if succesfully patched:

> try:
>     uclock = time.perf_counter
> except Exception:
>     uclock = time.clock

Anyway, the attached patch has been committed and was merged into the 2021Q2 branch as well and games/pysolfc should work as usual. Please let me know, if there are still issues.
Comment 9 Kai Knoblich freebsd_committer freebsd_triage 2021-06-30 09:14:02 UTC
(In reply to sven.a.jonsson from comment #3)

The runtime fix has been committed and was merged into the 2021Q2 branch as well. 

Thank you for the report and the quick feedback!