Skip to content

Fails to build on PyPy 3.11 #657

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

Open
wRAR opened this issue Mar 8, 2025 · 10 comments
Open

Fails to build on PyPy 3.11 #657

wRAR opened this issue Mar 8, 2025 · 10 comments

Comments

@wRAR
Copy link

wRAR commented Mar 8, 2025

uvloop/loop.c: At top level:
uvloop/loop.c:211059:12: fatal error: internal/pycore_frame.h: No such file or directory
211059 |   #include "internal/pycore_frame.h"
       |            ^~~~~~~~~~~~~~~~~~~~~~~~~

lxml has the same problem so I guess it's the same underlying issue that requires regenerating C code with Cython 3.0.12.

@lucascompython
Copy link

This means it used to work with PyPy 3.10?
I never got it working.

@wRAR
Copy link
Author

wRAR commented Mar 20, 2025

@lucascompython I can't promise it fully works but the Scrapy CI runs simple tests that use uvloop on PyPy 3.10.

@lucascompython
Copy link

lucascompython commented Mar 20, 2025

I'm not getting the same error.
Here it also mentions PyPy 3.11 not being able to build httptools, it works if I just install from the git repo.
Trying doing that with uvloop still doesn't work.
This is the output I get:

  × Failed to build `uvloop @ git+https://github.com/MagicStack/uvloop@7bb12a174884b2ec8b3162a08564e5fb8a5c6b39`
  ├─▶ The build backend returned an error
  ╰─▶ Call to `setuptools.build_meta.build_wheel` failed (exit status: 1)

      [stdout]
      running bdist_wheel
      running build
      running build_py
      copying uvloop/__init__.py -> build/lib.linux-x86_64-pypy311/uvloop
      copying uvloop/_noop.py -> build/lib.linux-x86_64-pypy311/uvloop
      copying uvloop/_testbase.py -> build/lib.linux-x86_64-pypy311/uvloop
      copying uvloop/_version.py -> build/lib.linux-x86_64-pypy311/uvloop
      running egg_info
      writing uvloop.egg-info/PKG-INFO
      writing dependency_links to uvloop.egg-info/dependency_links.txt
      writing requirements to uvloop.egg-info/requires.txt
      writing top-level names to uvloop.egg-info/top_level.txt
      reading manifest file 'uvloop.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      adding license file 'LICENSE-APACHE'
      adding license file 'LICENSE-MIT'
      writing manifest file 'uvloop.egg-info/SOURCES.txt'
      copying uvloop/cbhandles.pxd -> build/lib.linux-x86_64-pypy311/uvloop
      copying uvloop/cbhandles.pyx -> build/lib.linux-x86_64-pypy311/uvloop
      copying uvloop/dns.pyx -> build/lib.linux-x86_64-pypy311/uvloop
      copying uvloop/errors.pyx -> build/lib.linux-x86_64-pypy311/uvloop
      copying uvloop/loop.pxd -> build/lib.linux-x86_64-pypy311/uvloop
      copying uvloop/loop.pyi -> build/lib.linux-x86_64-pypy311/uvloop
      copying uvloop/loop.pyx -> build/lib.linux-x86_64-pypy311/uvloop
      copying uvloop/lru.pyx -> build/lib.linux-x86_64-pypy311/uvloop
      copying uvloop/pseudosock.pyx -> build/lib.linux-x86_64-pypy311/uvloop
      copying uvloop/py.typed -> build/lib.linux-x86_64-pypy311/uvloop
      copying uvloop/request.pxd -> build/lib.linux-x86_64-pypy311/uvloop
      copying uvloop/request.pyx -> build/lib.linux-x86_64-pypy311/uvloop
      copying uvloop/server.pxd -> build/lib.linux-x86_64-pypy311/uvloop
      copying uvloop/server.pyx -> build/lib.linux-x86_64-pypy311/uvloop
      copying uvloop/sslproto.pxd -> build/lib.linux-x86_64-pypy311/uvloop
      copying uvloop/sslproto.pyx -> build/lib.linux-x86_64-pypy311/uvloop
      copying uvloop/handles/async_.pxd -> build/lib.linux-x86_64-pypy311/uvloop/handles
      copying uvloop/handles/async_.pyx -> build/lib.linux-x86_64-pypy311/uvloop/handles
      copying uvloop/handles/basetransport.pxd -> build/lib.linux-x86_64-pypy311/uvloop/handles
      copying uvloop/handles/basetransport.pyx -> build/lib.linux-x86_64-pypy311/uvloop/handles
      copying uvloop/handles/check.pxd -> build/lib.linux-x86_64-pypy311/uvloop/handles
      copying uvloop/handles/check.pyx -> build/lib.linux-x86_64-pypy311/uvloop/handles
      copying uvloop/handles/fsevent.pxd -> build/lib.linux-x86_64-pypy311/uvloop/handles
      copying uvloop/handles/fsevent.pyx -> build/lib.linux-x86_64-pypy311/uvloop/handles
      copying uvloop/handles/handle.pxd -> build/lib.linux-x86_64-pypy311/uvloop/handles
      copying uvloop/handles/handle.pyx -> build/lib.linux-x86_64-pypy311/uvloop/handles
      copying uvloop/handles/idle.pxd -> build/lib.linux-x86_64-pypy311/uvloop/handles
      copying uvloop/handles/idle.pyx -> build/lib.linux-x86_64-pypy311/uvloop/handles
      copying uvloop/handles/pipe.pxd -> build/lib.linux-x86_64-pypy311/uvloop/handles
      copying uvloop/handles/pipe.pyx -> build/lib.linux-x86_64-pypy311/uvloop/handles
      copying uvloop/handles/poll.pxd -> build/lib.linux-x86_64-pypy311/uvloop/handles
      copying uvloop/handles/poll.pyx -> build/lib.linux-x86_64-pypy311/uvloop/handles
      copying uvloop/handles/process.pxd -> build/lib.linux-x86_64-pypy311/uvloop/handles
      copying uvloop/handles/process.pyx -> build/lib.linux-x86_64-pypy311/uvloop/handles
      copying uvloop/handles/stream.pxd -> build/lib.linux-x86_64-pypy311/uvloop/handles
      copying uvloop/handles/stream.pyx -> build/lib.linux-x86_64-pypy311/uvloop/handles
      copying uvloop/handles/streamserver.pxd -> build/lib.linux-x86_64-pypy311/uvloop/handles
      copying uvloop/handles/streamserver.pyx -> build/lib.linux-x86_64-pypy311/uvloop/handles
      copying uvloop/handles/tcp.pxd -> build/lib.linux-x86_64-pypy311/uvloop/handles
      copying uvloop/handles/tcp.pyx -> build/lib.linux-x86_64-pypy311/uvloop/handles
      copying uvloop/handles/timer.pxd -> build/lib.linux-x86_64-pypy311/uvloop/handles
      copying uvloop/handles/timer.pyx -> build/lib.linux-x86_64-pypy311/uvloop/handles
      copying uvloop/handles/udp.pxd -> build/lib.linux-x86_64-pypy311/uvloop/handles
      copying uvloop/handles/udp.pyx -> build/lib.linux-x86_64-pypy311/uvloop/handles
      copying uvloop/includes/__init__.py -> build/lib.linux-x86_64-pypy311/uvloop/includes
      copying uvloop/includes/consts.pxi -> build/lib.linux-x86_64-pypy311/uvloop/includes
      copying uvloop/includes/debug.pxd -> build/lib.linux-x86_64-pypy311/uvloop/includes
      copying uvloop/includes/flowcontrol.pxd -> build/lib.linux-x86_64-pypy311/uvloop/includes
      copying uvloop/includes/python.pxd -> build/lib.linux-x86_64-pypy311/uvloop/includes
      copying uvloop/includes/stdlib.pxi -> build/lib.linux-x86_64-pypy311/uvloop/includes
      copying uvloop/includes/system.pxd -> build/lib.linux-x86_64-pypy311/uvloop/includes
      copying uvloop/includes/uv.pxd -> build/lib.linux-x86_64-pypy311/uvloop/includes
      running build_ext
      building 'uvloop.loop' extension
      gcc -pthread -DNDEBUG -O2 -fPIC -I/home/lucas/.cache/uv/builds-v0/.tmpnwjcbq/include
      -I/tmp/usession-py3.11-0/build/pypy-3.11/include/pypy3.11
      -I/home/lucas/.cache/uv/git-v0/checkouts/9bd1e57c26ad0fbb/7bb12a1/vendor/libuv/include -c uvloop/loop.c -o
      build/temp.linux-x86_64-pypy311/uvloop/loop.o -O2

      [stderr]
      /home/lucas/.cache/uv/builds-v0/.tmpnwjcbq/lib/pypy3.11/site-packages/setuptools/config/_apply_pyprojecttoml.py:82:
      SetuptoolsDeprecationWarning: `project.license` as a TOML table is deprecated
      !!

              ********************************************************************************
              Please use a simple string containing a SPDX expression for `project.license`. You can also use
      `project.license-files`.

              By 2026-Feb-18, you need to update your project and remove deprecated calls
              or your builds will no longer be supported.

              See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details.
              ********************************************************************************

      !!
        corresp(dist, value, root_dir)
      /home/lucas/.cache/uv/builds-v0/.tmpnwjcbq/lib/pypy3.11/site-packages/setuptools/config/_apply_pyprojecttoml.py:61:
      SetuptoolsDeprecationWarning: License classifiers are deprecated.
      !!

              ********************************************************************************
              Please consider removing the following classifiers in favor of a SPDX license expression:

              License :: OSI Approved :: Apache Software License
              License :: OSI Approved :: MIT License

              See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details.
              ********************************************************************************

      !!
        dist._finalize_license_expression()
      /home/lucas/.cache/uv/builds-v0/.tmpnwjcbq/lib/pypy3.11/site-packages/setuptools/dist.py:760:
      SetuptoolsDeprecationWarning: License classifiers are deprecated.
      !!

              ********************************************************************************
              Please consider removing the following classifiers in favor of a SPDX license expression:

              License :: OSI Approved :: Apache Software License
              License :: OSI Approved :: MIT License

              See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details.
              ********************************************************************************

      !!
        self._finalize_license_expression()
      warning: no previously-included files matching '*' found under directory 'vendor/libuv/.git'
      /home/lucas/.cache/uv/builds-v0/.tmpnwjcbq/lib/pypy3.11/site-packages/setuptools/command/build_py.py:212:
      _Warning: Package 'uvloop.handles' is absent from the `packages` configuration.
      !!

              ********************************************************************************
              ############################
              # Package would be ignored #
              ############################
              Python recognizes 'uvloop.handles' as an importable package[^1],
              but it is absent from setuptools' `packages` configuration.

              This leads to an ambiguous overall configuration. If you want to distribute this
              package, please make sure that 'uvloop.handles' is explicitly added
              to the `packages` configuration field.

              Alternatively, you can also rely on setuptools' discovery methods
              (for example by using `find_namespace_packages(...)`/`find_namespace:`
              instead of `find_packages(...)`/`find:`).

              You can read more about "package discovery" on setuptools documentation page:

              - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html

              If you don't want 'uvloop.handles' to be distributed and are
              already explicitly excluding 'uvloop.handles' via
              `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`,
              you can try to use `exclude_package_data`, or `include-package-data=False` in
              combination with a more fine grained `package-data` configuration.

              You can read more about "package data files" on setuptools documentation page:

              - https://setuptools.pypa.io/en/latest/userguide/datafiles.html


              [^1]: For Python, any directory (with suitable naming) can be imported,
                    even if it does not contain any `.py` files.
                    On the other hand, currently there is no concept of package data
                    directory, all directories are treated like packages.
              ********************************************************************************

      !!
        check.warn(importable)
      /home/lucas/.cache/uv/builds-v0/.tmpnwjcbq/lib/pypy3.11/site-packages/setuptools/command/build_py.py:212:
      _Warning: Package 'uvloop.includes' is absent from the `packages` configuration.
      !!

              ********************************************************************************
              ############################
              # Package would be ignored #
              ############################
              Python recognizes 'uvloop.includes' as an importable package[^1],
              but it is absent from setuptools' `packages` configuration.

              This leads to an ambiguous overall configuration. If you want to distribute this
              package, please make sure that 'uvloop.includes' is explicitly added
              to the `packages` configuration field.

              Alternatively, you can also rely on setuptools' discovery methods
              (for example by using `find_namespace_packages(...)`/`find_namespace:`
              instead of `find_packages(...)`/`find:`).

              You can read more about "package discovery" on setuptools documentation page:

              - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html

              If you don't want 'uvloop.includes' to be distributed and are
              already explicitly excluding 'uvloop.includes' via
              `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`,
              you can try to use `exclude_package_data`, or `include-package-data=False` in
              combination with a more fine grained `package-data` configuration.

              You can read more about "package data files" on setuptools documentation page:

              - https://setuptools.pypa.io/en/latest/userguide/datafiles.html


              [^1]: For Python, any directory (with suitable naming) can be imported,
                    even if it does not contain any `.py` files.
                    On the other hand, currently there is no concept of package data
                    directory, all directories are treated like packages.
              ********************************************************************************

      !!
        check.warn(importable)
      In file included from uvloop/loop.c:1263:
      uvloop/includes/compat.h: In function ‘Context_CopyCurrent’:
      uvloop/includes/compat.h:75:12: error: implicit declaration of function ‘PyContext_CopyCurrent’; did you mean
      ‘Context_CopyCurrent’? [-Wimplicit-function-declaration]
         75 |     return PyContext_CopyCurrent();
            |            ^~~~~~~~~~~~~~~~~~~~~
            |            Context_CopyCurrent
      uvloop/includes/compat.h:75:12: error: returning ‘int’ from a function with return type ‘PyObject *’ {aka
      ‘struct _object *’} makes pointer from integer without a cast [-Wint-conversion]
         75 |     return PyContext_CopyCurrent();
            |            ^~~~~~~~~~~~~~~~~~~~~~~
      uvloop/includes/compat.h: In function ‘Context_Enter’:
      uvloop/includes/compat.h:79:12: error: implicit declaration of function ‘PyContext_Enter’; did you mean
      ‘Context_Enter’? [-Wimplicit-function-declaration]
         79 |     return PyContext_Enter(ctx);
            |            ^~~~~~~~~~~~~~~
            |            Context_Enter
      uvloop/includes/compat.h: In function ‘Context_Exit’:
      uvloop/includes/compat.h:83:12: error: implicit declaration of function ‘PyContext_Exit’; did you mean
      ‘Context_Exit’? [-Wimplicit-function-declaration]
         83 |     return PyContext_Exit(ctx);
            |            ^~~~~~~~~~~~~~
            |            Context_Exit
      uvloop/loop.c: In function ‘__pyx_f_6uvloop_4loop_9UVProcess__init’:
      uvloop/loop.c:129041:5: error: implicit declaration of function ‘PyOS_BeforeFork’; did you mean
      ‘PyOS_AfterFork’? [-Wimplicit-function-declaration]
      129041 |     PyOS_BeforeFork();
             |     ^~~~~~~~~~~~~~~
             |     PyOS_AfterFork
      uvloop/loop.c:129102:5: error: implicit declaration of function ‘PyOS_AfterFork_Parent’; did you mean
      ‘PyOS_AfterFork’? [-Wimplicit-function-declaration]
      129102 |     PyOS_AfterFork_Parent();
             |     ^~~~~~~~~~~~~~~~~~~~~
             |     PyOS_AfterFork
      uvloop/loop.c: In function ‘__pyx_f_6uvloop_4loop_9UVProcess__after_fork’:
      uvloop/loop.c:130217:3: error: implicit declaration of function ‘PyOS_AfterFork_Child’; did you mean
      ‘PyOS_AfterFork’? [-Wimplicit-function-declaration]
      130217 |   PyOS_AfterFork_Child();
             |   ^~~~~~~~~~~~~~~~~~~~
             |   PyOS_AfterFork
      error: command '/usr/bin/gcc' failed with exit code 1

I've also tried compiling uvloop with Cython 3.1.0.a1, but got the same error.
And I get the same error when trying with PyPy3.10

@wRAR
Copy link
Author

wRAR commented Mar 20, 2025

-Werror=implicit-function-declaration is (I assume, anyway) not enabled by default on Ubuntu 24.04 used in our GitHub CI jobs but is enabled on your system. The underlying issue seems to be #537

@lucascompython
Copy link

Yeah, #537 seems to be the issue, but you did have it working on PyPy3.10 right?
I get that error on PyPy3.10, PyPy3.11, PyPy3.11 compiled from source using Cython 3.0 and Cython 3.1.0 alpha 1.

@wRAR
Copy link
Author

wRAR commented Mar 21, 2025

Again, it builds fine on the GitHub CI ubuntu-24.04 runner env and that's why it works there, so I can only assume that the GCC used on that runner (be it the default Ubuntu one or some provided by the runner image) doesn't have -Werror=implicit-function-declaration enabled by default, unlike e.g. current Debian unstable.

@lucascompython
Copy link

lucascompython commented Mar 21, 2025

I get that, I can turn off those warning, and it builds, and I can install uvloop, but then it doesn't run.
Because, well, those symbols aren't defined anywhere.

Traceback (most recent call last):
  File "/home/lucas/Desktop/tests/uvloop_pypy/main.py", line 4, in <module>
    import uvloop
  File "/home/lucas/Desktop/tests/uvloop/uvloop/__init__.py", line 9, in <module>
    from .loop import Loop as __BaseLoop  # NOQA
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: /home/lucas/Desktop/tests/uvloop/uvloop/loop.pypy310-pp73-x86_64-linux-gnu.so: undefined symbol: PyContext_CopyCurrent

@wRAR
Copy link
Author

wRAR commented Mar 21, 2025

That's also old and not specific to PyPy 3.10: #370

(note that I have no idea about any of this, but it's easily googleable)

@lucascompython
Copy link

You probably mean #380.
But yeah, I'm just wondering how it works on CI and I can't seem to get it working.

@fantix
Copy link
Member

fantix commented Apr 16, 2025

It might be that the recent updates in the toolchain somehow got it working, but I think that's unlikely and quite unexpected, as uvloop does not support PyPy at this moment. Please also see Yury's comments on porting uvloop to PyPy in #82.

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

No branches or pull requests

3 participants