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

Fix PyJulia on Python 3.12 #538

Merged
merged 7 commits into from
Dec 16, 2023
Merged

Conversation

MilesCranmer
Copy link
Collaborator

@MilesCranmer MilesCranmer commented Oct 30, 2023

cc @mkitti do you think you could give this a look over? It still seems like there are some issues even though from julia import Main doesn't blow up... Any help appreciated.

This updates the importlib API according to what was noticed in #509 (which were giving deprecation warnings, we simply didn't update in time).

This is a lot of guess work about the importlib API: https://docs.python.org/3/library/importlib.html, so I'd appreciate if someone could give a close reading.

I found this stackoverflow answer to be particularly helpful: https://stackoverflow.com/a/43573798/2689923

cc @IlyaOrson this should finally fix the PySR issue you saw (the proper way!)

@MilesCranmer
Copy link
Collaborator Author

MilesCranmer commented Oct 31, 2023

Seems like the issue now is that the returned module is not a JuliaModule object, and thus doesn't have access to the Julia properties of the symbol. Maybe the sys.modules.setdefault is not working? Or somehow Julia is turning it into a regular module type?

@mkitti
Copy link
Member

mkitti commented Oct 31, 2023

I'm looking.

Copy link

codecov bot commented Nov 5, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (bdefc8b) 85.22% compared to head (13abc67) 81.43%.

Files Patch % Lines
src/julia/core.py 94.44% 1 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##           fix-ci-settings     #538      +/-   ##
===================================================
- Coverage            85.22%   81.43%   -3.79%     
===================================================
  Files                   39       39              
  Lines                 2342     2349       +7     
===================================================
- Hits                  1996     1913      -83     
- Misses                 346      436      +90     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MilesCranmer MilesCranmer changed the base branch from master to fix-ci-settings November 5, 2023 21:45
@MilesCranmer
Copy link
Collaborator Author

Okay it seems like it's mostly working now after adding a missing method:

1 failed, 135 passed, 9 skipped, 7 warnings in 65.80s (0:01:05)

Want to take a look?

@MilesCranmer
Copy link
Collaborator Author

@mkitti do you think you might be able to take a look at this? Seems like we're very close now.

@mkitti
Copy link
Member

mkitti commented Nov 13, 2023

I will have a little more time on Thursday.

@MilesCranmer
Copy link
Collaborator Author

Did you get a chance to take a look? Anything I can help push on?

@mkitti
Copy link
Member

mkitti commented Nov 17, 2023

I'm taking a look now.

@mkitti
Copy link
Member

mkitti commented Nov 18, 2023

This is taking a while to review since I'm trying to figure out why CI is failing. If you have any insight on getting CI to succeed to disabling some tests, let me know.

@MilesCranmer
Copy link
Collaborator Author

I did a downstream integration test with the full PySR suite and with this PR, everything seems to be working.

I think the current CI failure is due to this:

In Python 3.12, distutils will no longer be installed by make install or any of the first-party distribution. Third-party redistributors should no longer include distutils in their bundles or repositories.

Seems like distutils is being used somewhere in the pipeline?

@MilesCranmer
Copy link
Collaborator Author

Which tool is running this command?

│ ProcessFailedException(Base.Process[Process(setenv(`/home/runner/work/pyjulia/pyjulia/.tox/py/bin/python -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('VERSION'))"`,["GITHUB_ACTIONS=true", "PYTHONHASHSEED=3720144583", "PATH=/home/runner/work/pyjulia/pyjulia/.tox/py/bin:/opt/hostedtoolcache/julia/1.4.2/x64/bin:/opt/hostedtoolcache/Python/3.12.0/x64/bin:/opt/hostedtoolcache/Python/3.12.0/x64:/home/runner/.local/bin:/opt/pipx_bin:/home/runner/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games", "TOX_ENV_NAME=py", "PYTHON=/home/runner/work/pyjulia/pyjulia/.tox/py/bin/python", "PYJULIA_TEST_REBUILD=yes", "TOX_PACKAGE=/home/runner/work/pyjulia/pyjulia/.tox/.tmp/package/1/julia-0.6.1.tar.gz", "LD_LIBRARY_PATH=/opt/hostedtoolcache/Python/3.12.0/x64/lib", "PIP_DISABLE_PIP_VERSION_CHECK=1", "CI=true", "LANG=C.UTF-8", "PKG_CONFIG_PATH=/opt/hostedtoolcache/Python/3.12.0/x64/lib/pkgconfig", "JULIA_LOAD_PATH=@:/tmp/jl_aivj83", "TOX_WORK_DIR=/home/runner/work/pyjulia/pyjulia/.tox", "HOME=/home/runner", "PYJULIA_TEST_PYTHON_JL_IS_INSTALLED=yes", "TOX_ENV_DIR=/home/runner/work/pyjulia/pyjulia/.tox/py", "VIRTUAL_ENV=/home/runner/work/pyjulia/pyjulia/.tox/py", "PYTHONIOENCODING=UTF-8", "OPENBLAS_MAIN_FREE=1"]), ProcessExited(1))])

Is this from Conda.jl or PyCall.jl maybe? (distutils has been removed in 3.12)

@MilesCranmer
Copy link
Collaborator Author

I think this is partially fixed by my PR JuliaPy/PyCall.jl#1068... let's see

@MilesCranmer
Copy link
Collaborator Author

MilesCranmer commented Dec 16, 2023

@mkitti it seems like with JuliaPy/PyCall.jl#1068, many of the 3.12 CI runs are now passing! There are some remaining issues but those look to be weirdness about the CI cache (?).

I wonder if we can merge this now (after your review) to fix 3.12 and then fix those other GitHub action-specific issues later?

@mkitti
Copy link
Member

mkitti commented Dec 16, 2023

Ok, let's try

@mkitti mkitti merged commit 1f08cc4 into JuliaPy:fix-ci-settings Dec 16, 2023
36 of 38 checks passed
@MilesCranmer MilesCranmer deleted the import-issue branch December 16, 2023 14:51
@MilesCranmer MilesCranmer restored the import-issue branch December 16, 2023 14:51
@MilesCranmer
Copy link
Collaborator Author

Thanks!

Not sure why but it merged into #541 rather than master... I guess I had set that as the base or something?

mkitti pushed a commit that referenced this pull request Dec 29, 2023
* Update setup actions

* Fix PyJulia on Python 3.12 (#538)

* Fix importlib deprecated API

* Test Python 3.12

* Test Julia 1.9

* Fix semantics of exec_module vs create_module

* Ensure we can find spec from JuliaModule

* Bump version with python 3.12 compat

* Declare compat for 3.11 and 3.12

* Only test 1.6, 1.9, 1
MilesCranmer added a commit that referenced this pull request Dec 30, 2023
Squashed commit of the following:

commit 12cba08
Merge: 28af425 ce3ac83
Author: Miles Cranmer <[email protected]>
Date:   Sat Dec 30 02:23:21 2023 +0000

    Merge pull request #544 from JuliaPy/update-to-0.6.2

    Bump to 0.6.2 with Python 3.12 fix

commit ce3ac83
Author: MilesCranmer <[email protected]>
Date:   Sat Dec 30 02:03:45 2023 +0000

    Bump to 0.6.2 with Python 3.12 fix

commit 28af425
Author: Miles Cranmer <[email protected]>
Date:   Fri Dec 29 16:55:50 2023 +0000

    Update setup actions and get working on 3.12 (#541)

    * Update setup actions

    * Fix PyJulia on Python 3.12 (#538)

    * Fix importlib deprecated API

    * Test Python 3.12

    * Test Julia 1.9

    * Fix semantics of exec_module vs create_module

    * Ensure we can find spec from JuliaModule

    * Bump version with python 3.12 compat

    * Declare compat for 3.11 and 3.12

    * Only test 1.6, 1.9, 1
MilesCranmer added a commit that referenced this pull request Dec 30, 2023
Squashed commit of the following:

commit 18589bb
Author: MilesCranmer <[email protected]>
Date:   Sat Dec 30 02:25:30 2023 +0000

    Bump to 0.6.2

    Squashed commit of the following:

    commit 12cba08
    Merge: 28af425 ce3ac83
    Author: Miles Cranmer <[email protected]>
    Date:   Sat Dec 30 02:23:21 2023 +0000

        Merge pull request #544 from JuliaPy/update-to-0.6.2

        Bump to 0.6.2 with Python 3.12 fix

    commit ce3ac83
    Author: MilesCranmer <[email protected]>
    Date:   Sat Dec 30 02:03:45 2023 +0000

        Bump to 0.6.2 with Python 3.12 fix

    commit 28af425
    Author: Miles Cranmer <[email protected]>
    Date:   Fri Dec 29 16:55:50 2023 +0000

        Update setup actions and get working on 3.12 (#541)

        * Update setup actions

        * Fix PyJulia on Python 3.12 (#538)

        * Fix importlib deprecated API

        * Test Python 3.12

        * Test Julia 1.9

        * Fix semantics of exec_module vs create_module

        * Ensure we can find spec from JuliaModule

        * Bump version with python 3.12 compat

        * Declare compat for 3.11 and 3.12

        * Only test 1.6, 1.9, 1
MilesCranmer added a commit that referenced this pull request Dec 30, 2023
commit 57d6b6a
Author: MilesCranmer <[email protected]>
Date:   Sat Dec 30 02:45:53 2023 +0000

    Ensure setuptools installed in test

commit 18589bb
Author: MilesCranmer <[email protected]>
Date:   Sat Dec 30 02:25:30 2023 +0000

    Bump to 0.6.2

    Squashed commit of the following:

    commit 12cba08
    Merge: 28af425 ce3ac83
    Author: Miles Cranmer <[email protected]>
    Date:   Sat Dec 30 02:23:21 2023 +0000

        Merge pull request #544 from JuliaPy/update-to-0.6.2

        Bump to 0.6.2 with Python 3.12 fix

    commit ce3ac83
    Author: MilesCranmer <[email protected]>
    Date:   Sat Dec 30 02:03:45 2023 +0000

        Bump to 0.6.2 with Python 3.12 fix

    commit 28af425
    Author: Miles Cranmer <[email protected]>
    Date:   Fri Dec 29 16:55:50 2023 +0000

        Update setup actions and get working on 3.12 (#541)

        * Update setup actions

        * Fix PyJulia on Python 3.12 (#538)

        * Fix importlib deprecated API

        * Test Python 3.12

        * Test Julia 1.9

        * Fix semantics of exec_module vs create_module

        * Ensure we can find spec from JuliaModule

        * Bump version with python 3.12 compat

        * Declare compat for 3.11 and 3.12

        * Only test 1.6, 1.9, 1
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