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

Cannot build from source #18390

Closed
SengerM opened this issue Apr 30, 2023 · 35 comments
Closed

Cannot build from source #18390

SengerM opened this issue Apr 30, 2023 · 35 comments
Labels
Build issues Issues with building from source, including different choices of architecture, compilers and OS Cython Issues with the internal Cython code base Pythran Items related to internal Pythran code base

Comments

@SengerM
Copy link

SengerM commented Apr 30, 2023

Want to build from source to work on adding a missing distribution (Landau distribution). Following the steps from here. Using the pip+venv workflow. Already cloned the repo and created the virtual environment, run python -m pip install numpy pytest cython pythran pybind11 meson ninja pydevtool rich-click successfully. I am getting an error when running python3 dev.py build, specifically meson.build:1:0: ERROR: Cython compiler 'cython' cannot compile programs. If I look into the log I find:

Compiler stderr:
...
  File "/home/me/.venvs/scipy-dev/lib/python3.10/site-packages/pythran/optimizations/pattern_transform.py", line 346, in <module>
    getattr(PatternTransform, attr_name) + (known_pattern,))
AttributeError: type object 'PatternTransform' has no attribute 'typePatterns'. Did you mean: 'CallPatterns'?

How can I fix this to build the development version of scipy?

OS: Ubuntu 22.04.
Python: 3.10.6

@j-bowhay j-bowhay added the Build issues Issues with building from source, including different choices of architecture, compilers and OS label Apr 30, 2023
@j-bowhay
Copy link
Member

This is showing up on our CI too so is not an issue unique to you. Note before working on your new feature it is worth proposing it on the mailing list first so as to not waste effort.

This was referenced Apr 30, 2023
@tylerjereddy
Copy link
Contributor

meson-python new release on April 28th, but I ruled that out in gh-18393--pinning it back had no effect.

I cannot reproduce locally on two separate Linux boxes, and the failure is even showing up on ARM flavors of Linux and MacOS in CI per gh-18392, so it can't just be a compiler update on a single platform.

@andyfaff
Copy link
Contributor

I'm seeing this locally. I was going to try meson-python as well, but you tried that.

@andyfaff
Copy link
Contributor

I can build if I don't use Pythran. If I do use Pythran the meson log looks something like:

C++ compiler for the host machine: aarch64-linux-gnu-g++ (gcc 11.3.0 "aarch64-linux-gnu-g++ (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0")
C++ linker for the host machine: aarch64-linux-gnu-g++ ld.bfd 2.38
Running compile:
Working directory:  /tmp/tmp745x3ddu
Command line:  cython /tmp/tmp745x3ddu/testfile.pyx -o /tmp/tmp745x3ddu/output.exe --fast-fail

Code:
 print("hello world")
Compiler stdout:

Compiler stderr:
 Traceback (most recent call last):
  File "/root/miniconda3/envs/build-env/bin/cython", line 11, in <module>
    sys.exit(setuptools_main())
             ^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/build-env/lib/python3.11/site-packages/Cython/Compiler/Main.py", line 848, in setuptools_main
    return main(command_line = 1)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/build-env/lib/python3.11/site-packages/Cython/Compiler/Main.py", line 866, in main
    result = compile(sources, options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/build-env/lib/python3.11/site-packages/Cython/Compiler/Main.py", line 788, in compile
    return compile_multiple(source, options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/build-env/lib/python3.11/site-packages/Cython/Compiler/Main.py", line 757, in compile_multiple
    context = options.create_context()
              ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/build-env/lib/python3.11/site-packages/Cython/Compiler/Main.py", line 600, in create_context
    return Context(self.include_path, self.compiler_directives,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/build-env/lib/python3.11/site-packages/Cython/Compiler/Main.py", line 80, in __init__
    from . import Builtin, CythonScope
  File "/root/miniconda3/envs/build-env/lib/python3.11/site-packages/Cython/Compiler/CythonScope.py", line 5, in <module>
    from .UtilityCode import CythonUtilityCode
  File "/root/miniconda3/envs/build-env/lib/python3.11/site-packages/Cython/Compiler/UtilityCode.py", line 3, in <module>
    from .TreeFragment import parse_from_strings, StringParseContext
  File "/root/miniconda3/envs/build-env/lib/python3.11/site-packages/Cython/Compiler/TreeFragment.py", line 17, in <module>
    from .Visitor import VisitorTransform
  File "Cython/Compiler/Visitor.py", line 16, in init Cython.Compiler.Visitor
  File "/root/miniconda3/envs/build-env/lib/python3.11/site-packages/Cython/Compiler/Nodes.py", line 31, in <module>
    from .Pythran import has_np_pythran, pythran_type, is_pythran_buffer
  File "/root/miniconda3/envs/build-env/lib/python3.11/site-packages/Cython/Compiler/Pythran.py", line 10, in <module>
    import pythran
  File "/root/miniconda3/envs/build-env/lib/python3.11/site-packages/pythran/__init__.py", line 42, in <module>
    from pythran.toolchain import (generate_cxx, compile_cxxfile, compile_cxxcode,
  File "/root/miniconda3/envs/build-env/lib/python3.11/site-packages/pythran/toolchain.py", line 12, in <module>
    from pythran.middlend import refine, mark_unexported_functions
  File "/root/miniconda3/envs/build-env/lib/python3.11/site-packages/pythran/middlend.py", line 4, in <module>
    from pythran.optimizations import (ComprehensionPatterns, ListCompToGenexp,
  File "/root/miniconda3/envs/build-env/lib/python3.11/site-packages/pythran/optimizations/__init__.py", line 21, in <module>
    from .pattern_transform import PatternTransform
  File "/root/miniconda3/envs/build-env/lib/python3.11/site-packages/pythran/optimizations/pattern_transform.py", line 346, in <module>
    getattr(PatternTransform, attr_name) + (known_pattern,))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'PatternTransform' has no attribute 'typePatterns'. Did you mean: 'CallPatterns'?

@andyfaff
Copy link
Contributor

I also tried to use pythran on an easier example:

def dprod(l0,l1):
    """WoW, generator expression, zip and sum."""
    return sum(x * y for x, y in zip(l0, l1))

Trying to pythranise it (pythran dprod.py) gives:

Traceback (most recent call last):
  File "/root/miniconda3/envs/build-env/bin/pythran", line 5, in <module>
    from pythran.run import run
  File "/root/miniconda3/envs/build-env/lib/python3.11/site-packages/pythran/__init__.py", line 42, in <module>
    from pythran.toolchain import (generate_cxx, compile_cxxfile, compile_cxxcode,
  File "/root/miniconda3/envs/build-env/lib/python3.11/site-packages/pythran/toolchain.py", line 12, in <module>
    from pythran.middlend import refine, mark_unexported_functions
  File "/root/miniconda3/envs/build-env/lib/python3.11/site-packages/pythran/middlend.py", line 4, in <module>
    from pythran.optimizations import (ComprehensionPatterns, ListCompToGenexp,
  File "/root/miniconda3/envs/build-env/lib/python3.11/site-packages/pythran/optimizations/__init__.py", line 21, in <module>
    from .pattern_transform import PatternTransform
  File "/root/miniconda3/envs/build-env/lib/python3.11/site-packages/pythran/optimizations/pattern_transform.py", line 346, in <module>
    getattr(PatternTransform, attr_name) + (known_pattern,))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'PatternTransform' has no attribute 'typePatterns'. Did you mean: 'CallPatterns'?
(build-env) root@67162ede6fe0:/io# pythran dprod.py
Traceback (most recent call last):
  File "/root/miniconda3/envs/build-env/bin/pythran", line 5, in <module>
    from pythran.run import run
  File "/root/miniconda3/envs/build-env/lib/python3.11/site-packages/pythran/__init__.py", line 42, in <module>
    from pythran.toolchain import (generate_cxx, compile_cxxfile, compile_cxxcode,
  File "/root/miniconda3/envs/build-env/lib/python3.11/site-packages/pythran/toolchain.py", line 12, in <module>
    from pythran.middlend import refine, mark_unexported_functions
  File "/root/miniconda3/envs/build-env/lib/python3.11/site-packages/pythran/middlend.py", line 4, in <module>
    from pythran.optimizations import (ComprehensionPatterns, ListCompToGenexp,
  File "/root/miniconda3/envs/build-env/lib/python3.11/site-packages/pythran/optimizations/__init__.py", line 21, in <module>
    from .pattern_transform import PatternTransform
  File "/root/miniconda3/envs/build-env/lib/python3.11/site-packages/pythran/optimizations/pattern_transform.py", line 346, in <module>
    getattr(PatternTransform, attr_name) + (known_pattern,))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'PatternTransform' has no attribute 'typePatterns'. Did you mean: 'CallPatterns'?

Installed packages:

$ pip list
Package            Version
------------------ -------
beniget            0.4.1
build              0.10.0
Cython             0.29.34
gast               0.5.4
meson              1.1.0
meson-python       0.13.1
ninja              1.11.1
numpy              1.24.3
packaging          23.1
pip                23.1.2
ply                3.11
pybind11           2.10.4
pyproject_hooks    1.0.0
pyproject-metadata 0.7.1
pythran            0.12.1
setuptools         67.7.2
wheel              0.40.0

@serge-sans-paille, it looks like something upstream in Pythran/Pythran's dependencies may be causing this. Can you shine light on the situation?

@tylerjereddy
Copy link
Contributor

@andyfaff can you try gast==0.5.3 that fixed it for me

@tylerjereddy
Copy link
Contributor

Released April 29th, so that makes sense, also doesn't get bumped easily in my old virtualenvs, had to make a fresh one to repro and pull in new gast.

@andyfaff
Copy link
Contributor

Rolling back to gast=0.5.3 gets me:

(pythran) 192-168-1-113:scipy andrew$ pythran dprod.py 
No pythran specification, nothing will be exported
CRITICAL: Chair to keyboard interface error
E: Empty spec files while generating native module
CRITICAL:pythran:Chair to keyboard interface error
E: Empty spec files while generating native module

(Not sure if that's what I'm supposed to see from a pythran call, but at least it's not the other message).

@tylerjereddy
Copy link
Contributor

For SciPy proper, I can definitely build from source with gast 0.5.3 and it definitely fails reproducibly with 0.5.4.

@andyfaff
Copy link
Contributor

This cost me an hour of fiddling around last night, couldn't understand why I couldn't build.

@tylerjereddy
Copy link
Contributor

Yeah, intermediate build deps are a bit more annoying to intercept/pin as well. I'm not sure if we'll get a yank for that release, just replace it with a new/fixed one soon, or if we should i.e., manually pin gast for a little while in the CI jobs where we can (which, I suppose, would be CI jobs that don't lean heavily on pyproject.toml directly?).

@ilayn
Copy link
Member

ilayn commented Apr 30, 2023

Or turn off Pythran parts maybe through SCIPY_USE_PYTHRAN=0 until things are sorted out?

@h-vetinari
Copy link
Member

h-vetinari commented Apr 30, 2023

Or turn off Pythran parts maybe through SCIPY_USE_PYTHRAN=0 until things are sorted out?

Better to pin gast IMO than turn off pythran completely.

@ilayn
Copy link
Member

ilayn commented Apr 30, 2023

We don't have much pythran presence anyways and the parts rely on Pythran have also Cython fallbacks in case you have performance in mind.

@andyfaff
Copy link
Contributor

andyfaff commented May 1, 2023

There's a fair few places that we'd have to modify to make a pin like that, and turning off Pythran isn't necessarily that easy either.

I'd hope that the gast release would get yanked pretty quickly. @serge-sans-paille is the maintainer for both gast and pythran, so would be able to do that.
The situation may reveal a gap in pythran testing, there's presumably not a CI entry that does regular testing of it's upstream dependencies.

@andyfaff
Copy link
Contributor

andyfaff commented May 1, 2023

If I get time we could put necessary workarounds into e.g. .github/workflows/linux_meson.yml, which is probably the most important workflow, in a single commit. Then just back it out with git revert when the time comes to it.

@tupui tupui added Cython Issues with the internal Cython code base Pythran Items related to internal Pythran code base labels May 1, 2023
@tylerjereddy
Copy link
Contributor

Looks like there's an upstream pythran branch they'd like us to test as well.

@h-vetinari
Copy link
Member

So pythran 0.13.0 got released, which fixed the compatibility with gast 0.5.4, but seems to break something else:

[827/1624] Compiling C++ object scipy/stats/_stats_pythran.cpython-310-x86_64-linux-gnu.so.p/meson-generated_..__stats_pythran.cpp.o
FAILED: scipy/stats/_stats_pythran.cpython-310-x86_64-linux-gnu.so.p/meson-generated_..__stats_pythran.cpp.o 
c++ -Iscipy/stats/_stats_pythran.cpython-310-x86_64-linux-gnu.so.p -Iscipy/stats -I../scipy/stats -I../../../usr/lib/python3.10/site-packages/pythran -I../../../usr/lib/python3.10/site-packages/numpy/core/include -I/usr/include/python3.10 -fvisibility=hidden -fvisibility-inlines-hidden -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c++14 -O2 -g -fPIC -DENABLE_PYTHON_MODULE -D__PYTHRAN__=3 -DPYTHRAN_BLAS_NONE -Wno-cpp -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-unused-function -Wno-unused-variable -Wno-int-in-bool-context -MD -MQ scipy/stats/_stats_pythran.cpython-310-x86_64-linux-gnu.so.p/meson-generated_..__stats_pythran.cpp.o -MF scipy/stats/_stats_pythran.cpython-310-x86_64-linux-gnu.so.p/meson-generated_..__stats_pythran.cpp.o.d -o scipy/stats/_stats_pythran.cpython-310-x86_64-linux-gnu.so.p/meson-generated_..__stats_pythran.cpp.o -c scipy/stats/_stats_pythran.cpp
In file included from ../../../usr/lib/python3.10/site-packages/pythran/xsimd/xsimd.hpp:55,
                 from ../../../usr/lib/python3.10/site-packages/pythran/pythonic/include/numpy/ceil.hpp:8,
                 from scipy/stats/_stats_pythran.cpp:34:
../../../usr/lib/python3.10/site-packages/pythran/xsimd/arch/xsimd_scalar.hpp:465:25: error: exponent has no digits
  465 |         return std::exp(0x1.26bb1cp+1f * x);
      |                         ^~~~~~~~~~~
../../../usr/lib/python3.10/site-packages/pythran/xsimd/arch/xsimd_scalar.hpp:469:25: error: exponent has no digits
  469 |         return std::exp(0x1.26bb1bbb55516p+1 * x);
      |                         ^~~~~~~~~~~~~~~~~~
../../../usr/lib/python3.10/site-packages/pythran/xsimd/arch/xsimd_scalar.hpp: In function 'float xsimd::exp10(const float&)':
../../../usr/lib/python3.10/site-packages/pythran/xsimd/arch/xsimd_scalar.hpp:465:37: error: unable to find numeric literal operator 'operator""f'
  465 |         return std::exp(0x1.26bb1cp+1f * x);
      |                                     ^~
../../../usr/lib/python3.10/site-packages/pythran/xsimd/arch/xsimd_scalar.hpp:465:37: note: use '-fext-numeric-literals' to enable more built-in suffixes

I'm seeing this in musllinux_amd64_test and the "Windows tests / cp310 (meson) fast" job.

@andyfaff
Copy link
Contributor

andyfaff commented May 2, 2023

@h-vetinari can you report that upstream?

@h-vetinari
Copy link
Member

@h-vetinari can you report that upstream?

Already did (currently only as a comment in serge-sans-paille/pythran#2100; can be turned into an issue if I didn't overlook something obvious).

@h-vetinari
Copy link
Member

An alternative to unbreak current (already released as of now) pythran+gast would be to move to C++17. We've been ready for this for a while.

Of course, unbreaking CI should be uncoupled from such a decision, but it might be independently worthwhile and uncontroversial, hence why I'm mentioning it.

CC @rgommers @andyfaff @mckib2 @tylerjereddy

@h-vetinari
Copy link
Member

h-vetinari commented May 2, 2023

An alternative to unbreak current (already released as of now) pythran+gast would be to move to C++17. We've been ready for this for a while.

I have a sinking feeling that this consideration has become out of date; judging from -D__USE_MINGW_ANSI_STDIO=1 we're using mingw for the windows builds, and presumably one that's old enough not to support C++17 😭... There's no other reason to run into

error: 'aligned_alloc' is not a member of 'std'

which I see happening in #15841, see e.g. this run.

@tylerjereddy
Copy link
Contributor

Oh dear, this is a bit frustrating. Isn't it also strange that we're depending on 0.13.0 instead of 0.12.x for a bug fix? I think you already mentioned that upstream. It appears that in the cross-listed PR you're experimenting with a third branch of Pythran now!

@serge-sans-paille
Copy link
Contributor

Oh dear, this is a bit frustrating. Isn't it also strange that we're depending on 0.13.0 instead of 0.12.x for a bug fix?

Pytrhan maintainer here: Yeah, it's frustrating, but I don't want to start maintaining different branches / releases, so I'm just releasing new version of Pythran. A bit unsound from a theoretical point of view, but that's the best I have to offer given my bandwidth :-)

@rgommers
Copy link
Member

rgommers commented May 2, 2023

@serge-sans-paille there is a problem with that: pythran 0.12.1 has the requirement gast~=0.5.0, so if gast 0.5.4 broke pythran 0.12.1, that means all scipy from-source builds are currently broken. How about you release gast 0.6.0 which is identical to 0.5.4, and then yank 0.5.4 from PyPI? That should take like 15 minutes, since it's all pure Python, and will fix all the problems here.

I can offer to help with maintaining bugfix releases and dependency specifiers if that helps with the bandwidth issue. This is important for us though - we carefully put upper bounds on pythran in scipy release branches so that we won't be affected by future changes/regressions; but we can't be in a situation where bugfix releases of either pythran or its transitive dependencies break already released scipy versions.

@serge-sans-paille
Copy link
Contributor

serge-sans-paille commented May 2, 2023 via email

@serge-sans-paille
Copy link
Contributor

@rgommers : first attempt in https://github.com/serge-sans-paille/pythran/tree/release/0.12.2. I can tag it and release it on PyPI if it matches scipy's need.

Just to clarify the problem : I did a patch release of gast, but this had a side effect of introducing a new global object that matches the dynamic condition know_patterns = [x for x in globals().values() if hasattr(x, "pattern")] fixed by serge-sans-paille/pythran@f0c2777#diff-30bff397bd1e6eee13cca1ccfa375208bc191914a79ffdec9b62973a140e3570L326 .

@rgommers
Copy link
Member

rgommers commented May 2, 2023

@rgommers : first attempt in https://github.com/serge-sans-paille/pythran/tree/release/0.12.2. I can tag it and release it on PyPI if it matches scipy's need.

Thanks! The version specifier should be ==0.5.3 or, perhaps preferred, <=0.5.4 (not =0.5.3 with a single "=", I don't think that works). With that change, this should do the job.

@serge-sans-paille
Copy link
Contributor

@rgommers like this? (I guess you meant gast<=0.5.3)

@rgommers
Copy link
Member

rgommers commented May 2, 2023

oops, yes indeed.

@serge-sans-paille
Copy link
Contributor

release 0.12.2 tagged on github and pushed on PyPI. If I understand correctly this should fix scipy builds without needing to change anything in scipy code, correct?

@rgommers
Copy link
Member

rgommers commented May 2, 2023

Indeed. I'll restart a CI job to verify right now, but everything should be fixed. Thanks a lot!

@serge-sans-paille
Copy link
Contributor

That being said, Pythran 0.13.1 has a lot of performance improvement, you should give it a chance ;-)

@rgommers
Copy link
Member

rgommers commented May 2, 2023

That being said, Pythran 0.13.1 has a lot of performance improvement, you should give it a chance ;-)

Definitely. We are automatically using that on SciPy main, and will use it in SciPy 1.11.0 which is planned for early June. In conda-forge it will also be used after rebuilds. On PyPI we can't change metadata post-release though, so there's we're at <0.13.

@rgommers
Copy link
Member

rgommers commented May 2, 2023

Indeed seems all fixed, closing. Thanks everyone for helping debug this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build issues Issues with building from source, including different choices of architecture, compilers and OS Cython Issues with the internal Cython code base Pythran Items related to internal Pythran code base
Projects
None yet
Development

No branches or pull requests

9 participants