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

Core, CI: Add Python 3.12 support #3290

Merged
merged 10 commits into from
Sep 2, 2024
Merged

Conversation

black-sliver
Copy link
Member

@black-sliver black-sliver commented May 12, 2024

What is this fixing or adding?

Add/fix Python 3.12 support. and use 3.12 in CI

  • Use a pony fork that works with 3.12 (Unit tests there look all good)
  • Need to fix Stardew's use of deprecated assertEquals since it's now gone
  • Slight change to ModuleUpdate.py because Python 3.12's ensure_pip does not ship pkg_resources anymore and some tests would fail because they import ModuleUpdate without --yes.

Stardew and ModuleUpdate could be cherry-picked if we want to give upstream pony more time.

How was this tested?

  • Unit tests
  • Generate of one multi
  • Upload of one game to an empty WebHost and checked user-content - I did not check for DB "upgrade" since I deleted my local DB recently.

@github-actions github-actions bot added affects: core Issues/PRs that touch core and may need additional validation. affects: webhost Issues/PRs that touch webhost and may need additional validation. waiting-on: peer-review Issue/PR has not been reviewed by enough people yet. labels May 12, 2024
@black-sliver black-sliver requested a review from agilbert1412 May 12, 2024 23:06
Copy link
Collaborator

@agilbert1412 agilbert1412 left a comment

Choose a reason for hiding this comment

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

Stardew changes are totally fine.
Other changes look okay, but my expertise is low so I wouldn't put much weight on that approval

Copy link
Collaborator

@remyjette remyjette left a comment

Choose a reason for hiding this comment

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

Created a Python 3.12.3 venv in Windows, tested

  • Webhost: launching the webhost which didn't work before sending a location, making sure the tracker updated, closing and relaunching the server to validate the load from the savefile. Didn't see any errors in the log, no warnings other than options deprecations
  • Generate: Just did a simple clique generate and looked for errors in the log. Didn't see any. Only warnings were again options deprecations.
  • Kivy: Ran the launcher, checked the logs for any Kivy errors, didn't see any. Opened the text client, connected to a slot, still didn't see any errors.

@Exempt-Medic Exempt-Medic added the is: maintenance Regular updates to requirements and utilities that do not fix bugs or change/add features. label May 14, 2024
@beauxq
Copy link
Collaborator

beauxq commented May 15, 2024

docs/running from source.md has some lines that say "Python 3.12 is currently unsupported"
I don't know if we want to remove them or change them or change them to 3.13
I don't like the idea of having to change more things in more places with every version change, so I think probably remove.

@black-sliver
Copy link
Member Author

I think it is still undecided how we are going to handle this exactly once we drop 3.8, but kivy sometimes being slow to update might be a problem regardless of our plans, so I think the versions should be mentioned explicitly. We had a bunch of people that were on unsupported python versions and didn't know.

My personal preference would be to roughly follow github ubuntu-latest python for the oldest, which changes around the time when the latest Ubuntu LTS gets its point 1 release. And bleeding edge for the newest. I use arch btw. This is hard to put into words if we don't know when our dependencies will update.

docs/running from source.md Outdated Show resolved Hide resolved
@LegendaryLinux
Copy link
Member

LegendaryLinux commented Jun 8, 2024

When running in Python 3.12.4 on Windows 10, I get the following errors. I don't know enough about them to suggest fixes, but hopefully they prove useful. They seem to be coming from Pony, which I know was a pain point for a while. I saw your requirement file directs the installer to grab a version from your GitHub. Is it possible your build of Pony is the problem? I have not deleted my local database for a while, so that could be causing the problem as well.

Exception in thread AP_Autohost:
Traceback (most recent call last):
  File "C:\Python312\Lib\threading.py", line 1073, in _bootstrap_inner
    self.run()
  File "C:\Python312\Lib\threading.py", line 1010, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\Chris\Desktop\gits\ArchipelagoMW\Archipelago\WebHostLib\autolauncher.py", line 70, in keep_running
    rooms = Room.select(lambda room: room.owner == UUID(int=0)).delete(bulk=True)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Chris\Desktop\gits\ArchipelagoMW\Archipelago\venv\Lib\site-packages\pony\orm\core.py", line 4027, in select
    if args: query = entity._query_from_args_(args, kwargs, frame_depth=cut_traceback_depth+1)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Chris\Desktop\gits\ArchipelagoMW\Archipelago\venv\Lib\site-packages\pony\orm\core.py", line 4379, in _query_from_args_
    cond_expr, external_names, cells = decompile(func)
                                       ^^^^^^^^^^^^^^^
  File "C:\Users\Chris\Desktop\gits\ArchipelagoMW\Archipelago\venv\Lib\site-packages\pony\orm\decompiling.py", line 43, in decompile
    decompiler = Decompiler(codeobject)
                 ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Chris\Desktop\gits\ArchipelagoMW\Archipelago\venv\Lib\site-packages\pony\orm\decompiling.py", line 160, in __init__
    decompiler.get_instructions()
  File "C:\Users\Chris\Desktop\gits\ArchipelagoMW\Archipelago\venv\Lib\site-packages\pony\orm\decompiling.py", line 216, in get_instructions
    arg = [cmp_op[oparg]]
           ~~~~~~^^^^^^^
IndexError: tuple index out of range
Exception in thread AP_Autogen:
Traceback (most recent call last):
  File "C:\Python312\Lib\threading.py", line 1073, in _bootstrap_inner
    self.run()
  File "C:\Python312\Lib\threading.py", line 1010, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\Chris\Desktop\gits\ArchipelagoMW\Archipelago\WebHostLib\autolauncher.py", line 101, in keep_running
    to_start = select(generation for generation in Generation if generation.state == STATE_STARTED)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Chris\Desktop\gits\ArchipelagoMW\Archipelago\venv\Lib\site-packages\pony\orm\core.py", line 5560, in select
    return make_query(args, frame_depth=cut_traceback_depth+1)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Chris\Desktop\gits\ArchipelagoMW\Archipelago\venv\Lib\site-packages\pony\orm\core.py", line 5546, in make_query
    tree, external_names, cells = decompile(gen)
                                  ^^^^^^^^^^^^^^
  File "C:\Users\Chris\Desktop\gits\ArchipelagoMW\Archipelago\venv\Lib\site-packages\pony\orm\decompiling.py", line 43, in decompile
    decompiler = Decompiler(codeobject)
                 ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Chris\Desktop\gits\ArchipelagoMW\Archipelago\venv\Lib\site-packages\pony\orm\decompiling.py", line 160, in __init__
    decompiler.get_instructions()
  File "C:\Users\Chris\Desktop\gits\ArchipelagoMW\Archipelago\venv\Lib\site-packages\pony\orm\decompiling.py", line 216, in get_instructions
    arg = [cmp_op[oparg]]
           ~~~~~~^^^^^^^
IndexError: tuple index out of range

@remyjette
Copy link
Collaborator

IndexError: tuple index out of range is the error from the old pony when run on 3.12.

@black-sliver
Copy link
Member Author

Are you working in a venv, if so, have you created a fresh venv or upgraded your existing one?
It'll not use my fork and thus fail, if you did not create a fresh one, because the version numbers did not change.

If you don't use a venv at all, I have no idea how/where pony gets installed on Windows, but pip -R pony should hopefully remove any "outdated" versions regardless of where they are installed.

@LegendaryLinux
Copy link
Member

I am using a venv, yeah, though I didn't create a fresh one after checking out your fork. I'll give that a go.

@remyjette
Copy link
Collaborator

Pony merged the Py3.12 fix and released 0.7.18: https://github.com/ponyorm/pony/releases/tag/v0.7.18

I just tried checking out this branch, merging main into it, reverting the requirements.txt changes and just changing the pony version to 0.7.18, created a new 3.12 venv and tested the webhost. Everything appears to be working correctly. I started a multiworld with a Clique in hard mode, sent a check, restarted the webhost, Loaded save file with 1 received items for 1 players

@black-sliver black-sliver merged commit 7370129 into ArchipelagoMW:main Sep 2, 2024
18 checks passed
@black-sliver black-sliver deleted the py312 branch September 2, 2024 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects: core Issues/PRs that touch core and may need additional validation. affects: webhost Issues/PRs that touch webhost and may need additional validation. is: maintenance Regular updates to requirements and utilities that do not fix bugs or change/add features. waiting-on: peer-review Issue/PR has not been reviewed by enough people yet.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants