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 python version problems #214

Merged
merged 11 commits into from
Mar 6, 2023
Merged

Fix python version problems #214

merged 11 commits into from
Mar 6, 2023

Conversation

cschwan
Copy link
Contributor

@cschwan cschwan commented Mar 6, 2023

Here we'll fix the problems discovered in this comment: #211 (comment).

@@ -13,7 +11,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: ['3.7', '3.8', '3.9', '3.11', 'pypy3.7', 'pypy3.8', 'pypy3.9', '3.10']
Copy link
Member

Choose a reason for hiding this comment

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

This should be irrelevant, since the wheel is built in any case inside a manylinux container.

Not sure how to implement it with sed...
I know something algorithmic is more convenient (even with some changes to the base, sed would keep working), but if it is too complex I'd rather go for a patch, or just commit the final result manually edited.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

About the irrelevancy I'm not so sure anymore, it seems setup-python may also have an effect there: https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md#using-setup-python-with-a-self-hosted-runner. We should figure out the effect and do it properly as you said.

Copy link
Member

Choose a reason for hiding this comment

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

A self-hosted runner is not a container, but a different machine you provide on your own to run the workflow, instead of using those of GitHub (i.e. Azure...).

Instead, maturin-action is running a container in a GitHub's virtual machine, that is relevant for the host system (we need a Linux machine to run a Linux container, otherwise we would need a Linux virtual machine inside the virtual machine), but it is not relevant Python-wise, since the manylinux container comes pre-built with its versions of Python.

This is true only for Linux, while for Windows and MacOS the setup-python is a crucial step.

#release:
# name: Release
# runs-on: ubuntu-latest
# if: "startsWith(github.ref, 'refs/tags/')"
Copy link
Member

Choose a reason for hiding this comment

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

Since this is only running on releases, you could keep this uncommented (just to reduce the diff)

on:
release:
types: [published]
on: push
Copy link
Member

Choose a reason for hiding this comment

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

You can also add an event, without removing the previous one>

Suggested change
on: push
on:
push:
release:
types: [published]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's going in the right direction; I think I want to run every job except release in wheels.yml whenever I want to test them (in branches like this one).

Copy link
Member

Choose a reason for hiding this comment

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

This is also what Stefano C is doing in quantum repos (even if they are just pure Python... here I believe it's more relevant).

You can filter the jobs and individual steps with if: key, as you are doing, and the condition can contain an expression, that can depend on variables in contexts (thus including events and outputs of previous steps).
https://docs.github.com/en/actions/learn-github-actions/expressions
https://docs.github.com/en/actions/learn-github-actions/contexts
https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idif
https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsif

@cschwan
Copy link
Contributor Author

cschwan commented Mar 6, 2023

It seems to work, except that on Windows no PyPy (3.7, 3.8, 3.9) wheels are created.

@alecandido
Copy link
Member

It seems to work, except that on Windows no PyPy (3.7, 3.8, 3.9) wheels are created.

That is not a problem :)

@alecandido
Copy link
Member

alecandido commented Mar 6, 2023

I still don't see MacOS wheels for CPython 3.7, 3.8, and 3.9 in https://github.com/NNPDF/pineappl/suites/11369716006/artifacts/584873397
(i.e. the wheels archive from https://github.com/NNPDF/pineappl/actions/runs/4341762408)

@cschwan
Copy link
Contributor Author

cschwan commented Mar 6, 2023

You're right: instead the corresponding PyPy wheels are created (and also found) twice. See this line from the action:

Found PyPy 3.7 at /Users/runner/hostedtoolcache/PyPy/3.7.13/x64/bin/python3.7, PyPy 3.8 at /Users/runner/hostedtoolcache/PyPy/3.8.16/x64/bin/python3.8, PyPy 3.9 at /Users/runner/hostedtoolcache/PyPy/3.9.16/x64/bin/python3.9, CPython 3.10 at /Users/runner/hostedtoolcache/Python/3.10.10/x64/bin/python3.10, CPython 3.11 at /Library/Frameworks/Python.framework/Versions/3.11/bin/python3.11, PyPy 3.7 at /Users/runner/hostedtoolcache/PyPy/3.7.13/x64/bin/pypy3.7, PyPy 3.8 at /Users/runner/hostedtoolcache/PyPy/3.8.16/x64/bin/pypy3.8, PyPy 3.9 at /Users/runner/hostedtoolcache/PyPy/3.9.16/x64/bin/pypy3.9

Note how it finds PyPy (?) 3.7

  • once as /Users/runner/hostedtoolcache/PyPy/3.7.13/x64/bin/python3.7 and
  • then as /Users/runner/hostedtoolcache/PyPy/3.7.13/x64/bin/pypy3.7.

Both claim to have

Built wheel for PyPy 3.7 to dist/pineappl-0.6.0a2-pp37-pypy37_pp73-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl

@cschwan
Copy link
Contributor Author

cschwan commented Mar 6, 2023

It seems to work, except that on Windows no PyPy (3.7, 3.8, 3.9) wheels are created.

That is not a problem :)

I agree, but what worries me is that I don't understand what's going on here. I specifically requested these versions, why are they not present?

They are installed, but it seems maturin doesn't find them:

Found CPython 3.11 at C:\hostedtoolcache\windows\Python\3.11.2\x64\python.exe, CPython 3.10 at C:\hostedtoolcache\windows\Python\3.10.10\x64\python.exe, CPython 3.9 at C:\hostedtoolcache\windows\Python\3.9.13\x64\python.exe, CPython 3.8 at C:\hostedtoolcache\windows\Python\3.8.10\x64\python.exe, CPython 3.7 at C:\hostedtoolcache\windows\Python\3.7.9\x64\python.exe

@alecandido
Copy link
Member

They are installed, but it seems maturin doesn't find them:

Then there are two main options:

  1. try specifying everything explicitly, and giving up with --find-interpreter (at least in this case)
  2. file an issue on maturin repo (messense is usually replying fast and very helpful)

Note how it finds PyPy (?) 3.7

  • once as /Users/runner/hostedtoolcache/PyPy/3.7.13/x64/bin/python3.7 and
  • then as /Users/runner/hostedtoolcache/PyPy/3.7.13/x64/bin/pypy3.7.

This I believe to be normal, and most likely the first is a link to the second, in such a way that PyPy can work both side-by-side and as a drop-in replacement of CPython.

@cschwan
Copy link
Contributor Author

cschwan commented Mar 6, 2023

Note how it finds PyPy (?) 3.7

  • once as /Users/runner/hostedtoolcache/PyPy/3.7.13/x64/bin/python3.7 and
  • then as /Users/runner/hostedtoolcache/PyPy/3.7.13/x64/bin/pypy3.7.

This I believe to be normal, and most likely the first is a link to the second, in such a way that PyPy can work both side-by-side and as a drop-in replacement of CPython.

Is this OK? Because the wheel is twice created for PyPy, can CPython work with it?

@alecandido
Copy link
Member

Is this OK? Because the wheel is twice created for PyPy, can CPython work with it?

No, definitely not. The compiled wheel needs ABI compatibility with the interpreter.
In order to guarantee this, wheels adopted a consistent naming scheme, that is the one you observed in the generated objects.

It might be that on MacOS, for whatever reason, PyPy is actually the python3.x x \in [7, 8, 9] executable found by maturin, so it is regenerating twice the wheel for PyPy and overwriting it, while those for CPython are never generated.

Since for PyPy Linux is definitely far more than enough, maybe just try to remove it from all the lists of python-version (for Linux it will be built anyhow, since PyPy will be inside the container).

@alecandido
Copy link
Member

alecandido commented Mar 6, 2023

@cschwan I have the feeling that 80433c0 is in the wrong branch, but I might be wrong...

EDIT: ah sorry, I just got the notification missed the series of "Revert" commits; we will squash anyhow, so please ignore my message

@alecandido
Copy link
Member

@cschwan in https://github.com/NNPDF/pineappl/actions/runs/4344435880 we actually obtained all the wheels we wanted:

  • we have all the full Python versions range ([3.7, 3.11]) for CPython for all the three platforms
  • we have PyPy wheels for Linux

Moreover, the workflow is now running by default on push:, but without uploading the wheels (that should only happen on releases, but of course this I couldn't test).
Everything is documented in update-wheels.sh.

Should we agree on the current result, or do we have still some desiderata left behind?

@alecandido
Copy link
Member

Curious fact: Windows has the smallest wheels, while MacOS the biggest ones

  • Win: 676 KB
  • Linux: 764 KB
  • MacOS: 1.3 MB

The size of the wheel does not depend on the Python version or the interpreter (wheels for Linux-PyPy are the same size of Linux-CPython). This makes me believe that they are actually very similar, and only the platform makes an actual significant difference...

@alecandido alecandido closed this Mar 6, 2023
@alecandido alecandido reopened this Mar 6, 2023
@cschwan
Copy link
Contributor Author

cschwan commented Mar 6, 2023

Should we agree on the current result, or do we have still some desiderata left behind?

As far as it concerns me, that's perfect! Go ahead and merge it.

@cschwan
Copy link
Contributor Author

cschwan commented Mar 6, 2023

Curious fact: Windows has the smallest wheels, while MacOS the biggest ones

* Win: 676 KB

* Linux: 764 KB

* MacOS: 1.3 MB

The size of the wheel does not depend on the Python version or the interpreter (wheels for Linux-PyPy are the same size of Linux-CPython). This makes me believe that they are actually very similar, and only the platform makes an actual significant difference...

These numbers make sense, because for MacOS the universal wheels are basically two wheels in one, one for x86_64 and the other for aarch64.

@alecandido alecandido merged commit 6276d0b into master Mar 6, 2023
@alecandido alecandido deleted the fix-python-version-problems branch March 6, 2023 15:46
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