Skip to content

Conversation

@ryanking13
Copy link
Member

@ryanking13 ryanking13 commented Feb 6, 2023

Description

Add out-of-tree support of pyodide build-recipes. Thanks to the awesome xbuildenv work by Hood, the required code change was quite small.

I am testing this branch here: https://github.com/ryanking13/pyodide-recipes-mirror

Checklists

Copy link
Member

@hoodmane hoodmane left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @ryanking13!

it builds:

  • numpy

This was one of my main objectives when working on the out of tree builds project. =)

it fails to build:

  • scipy

Yeah, that's hopeless, at least until we get a real fortran compiler. Even then it may take signficant work

@ryanking13
Copy link
Member Author

Scipy build error seems related to pythran... but I'm not sure.

scipy/interpolate/_rbfinterp_pythran.cpp:82:41: error: no member named 'as_const' in namespace '(anonymous namespace)::pythonic::types'
      typedef decltype(pythonic::types::as_const(std::declval<__type2>())) __type3;
                       ~~~~~~~~~~~~~~~~~^
scipy/interpolate/_rbfinterp_pythran.cpp:85:41: error: no member named 'as_const' in namespace '(anonymous namespace)::pythonic::types'
      typedef decltype(pythonic::types::as_const(std::declval<__type6>())) __type7;
                       ~~~~~~~~~~~~~~~~~^
scipy/interpolate/_rbfinterp_pythran.cpp:86:29: error: implicit instantiation of undefined template 'std::tuple_element<0, int>'
      typedef typename std::tuple_element<0,typename std::remove_reference<__type7>::type>::type __type8;
                            ^
/workspaces/pyodide-recipes/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__tuple:56:62: note: template is declared here
template <size_t _Ip, class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_element;
                                                             ^
scipy/interpolate/_rbfinterp_pythran.cpp:90:47: error: subscripted value is not an array, pointer, or vector
      typedef decltype(std::declval<__type3>()[std::declval<__type11>()]) __type12;
                       ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
scipy/interpolate/_rbfinterp_pythran.cpp:93:41: error: no member named 'as_const' in namespace '(anonymous namespace)::pythonic::types'
      typedef decltype(pythonic::types::as_const(std::declval<__type14>())) __type15;
                       ~~~~~~~~~~~~~~~~~^
scipy/interpolate/_rbfinterp_pythran.cpp:95:41: error: no member named 'as_const' in namespace '(anonymous namespace)::pythonic::types'
      typedef decltype(pythonic::types::as_const(std::declval<__type17>())) __type18;
                       ~~~~~~~~~~~~~~~~~^
scipy/interpolate/_rbfinterp_pythran.cpp:96:29: error: implicit instantiation of undefined template 'std::tuple_element<0, int>'
      typedef typename std::tuple_element<0,typename std::remove_reference<__type18>::type>::type __type19;
                            ^
/workspaces/pyodide-recipes/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__tuple:56:62: note: template is declared here
template <size_t _Ip, class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_element;
                                                             ^
scipy/interpolate/_rbfinterp_pythran.cpp:100:48: error: subscripted value is not an array, pointer, or vector
      typedef decltype(std::declval<__type15>()[std::declval<__type22>()]) __type23;
                       ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
scipy/interpolate/_rbfinterp_pythran.cpp:130:41: error: no member named 'as_const' in namespace '(anonymous namespace)::pythonic::types'
      typedef decltype(pythonic::types::as_const(std::declval<__type4>())) __type5;
                       ~~~~~~~~~~~~~~~~~^
scipy/interpolate/_rbfinterp_pythran.cpp:133:41: error: no member named 'as_const' in namespace '(anonymous namespace)::pythonic::types'
      typedef decltype(pythonic::types::as_const(std::declval<__type8>())) __type9;
                       ~~~~~~~~~~~~~~~~~^
scipy/interpolate/_rbfinterp_pythran.cpp:134:29: error: implicit instantiation of undefined template 'std::tuple_element<0, int>'
      typedef typename std::tuple_element<0,typename std::remove_reference<__type9>::type>::type __type10;
                            ^
/workspaces/pyodide-recipes/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__tuple:56:62: note: template is declared here
template <size_t _Ip, class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_element;
                                                             ^
scipy/interpolate/_rbfinterp_pythran.cpp:138:47: error: subscripted value is not an array, pointer, or vector
      typedef decltype(std::declval<__type5>()[std::declval<__type13>()]) __type14;
                       ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
scipy/interpolate/_rbfinterp_pythran.cpp:144:47: error: subscripted value is not an array, pointer, or vector
      typedef decltype(std::declval<__type5>()[std::declval<__type22>()]) __type23;
                       ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
scipy/interpolate/_rbfinterp_pythran.cpp:175:41: error: no member named 'as_const' in namespace '(anonymous namespace)::pythonic::types'
      typedef decltype(pythonic::types::as_const(std::declval<__type4>())) __type5;
                       ~~~~~~~~~~~~~~~~~^
scipy/interpolate/_rbfinterp_pythran.cpp:178:41: error: no member named 'as_const' in namespace '(anonymous namespace)::pythonic::types'
      typedef decltype(pythonic::types::as_const(std::declval<__type8>())) __type9;
                       ~~~~~~~~~~~~~~~~~^
scipy/interpolate/_rbfinterp_pythran.cpp:179:29: error: implicit instantiation of undefined template 'std::tuple_element<0, int>'
      typedef typename std::tuple_element<0,typename std::remove_reference<__type9>::type>::type __type10;
                            ^
/workspaces/pyodide-recipes/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__tuple:56:62: note: template is declared here
template <size_t _Ip, class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_element;
                                                             ^
scipy/interpolate/_rbfinterp_pythran.cpp:183:47: error: subscripted value is not an array, pointer, or vector
      typedef decltype(std::declval<__type5>()[std::declval<__type13>()]) __type14;
                       ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
scipy/interpolate/_rbfinterp_pythran.cpp:213:41: error: no member named 'as_const' in namespace '(anonymous namespace)::pythonic::types'
      typedef decltype(pythonic::types::as_const(std::declval<__type6>())) __type7;
                       ~~~~~~~~~~~~~~~~~^
scipy/interpolate/_rbfinterp_pythran.cpp:216:41: error: no member named 'as_const' in namespace '(anonymous namespace)::pythonic::types'
      typedef decltype(pythonic::types::as_const(std::declval<__type10>())) __type11;

@hoodmane
Copy link
Member

hoodmane commented Feb 9, 2023

scipy error

But that's just the first error. There will be many many more if you fix that one.

@ryanking13
Copy link
Member Author

ryanking13 commented Feb 9, 2023

But that's just the first error. There will be many many more if you fix that one.

But we are building scipy in-tree with the same recipe, so if everything works correctly it should be able to build out-of-tree too I think.

@ryanking13
Copy link
Member Author

Okay, I was able to build scipy out-of-tree with the same recipe. The problem was:

  • pythran 0.12.1 and 0.12.0 are not compatible
  • pyodide-build 0.22.1 xbuildenv include pythran 0.12.0 in the host site packages.
  • scipy defines pythran in its pyproject.toml, so it installs latest version (0.12.1) inside the build env.
  • two differenct versions of pythran conflicts during the build

Opened #3576 for a fix.

@ryanking13 ryanking13 changed the title Draft: Out-of-tree recipe build support Out-of-tree recipe build support Feb 20, 2023
@ryanking13 ryanking13 marked this pull request as ready for review February 20, 2023 06:41
@ryanking13
Copy link
Member Author

I think this is ready to be reviewed now. I managed to build core package sets out-of-tree including numpy, scipy, pandas, matplotlib, scikit-learn, scikit-image, Pillow, opencv-python, xgboost.

@hoodmane
Copy link
Member

Thanks! Will review soon.

@ryanking13
Copy link
Member Author

Thanks! This is on top of #3592.

@rth rth added this to the 0.23.0 milestone Mar 17, 2023
@hoodmane hoodmane mentioned this pull request Mar 17, 2023
Copy link
Member

@hoodmane hoodmane left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @ryanking13! I'm sorry it took me so long to get around to reviewing it.

return
try:
os.environ["PYODIDE_ROOT"] = str(search_pyodide_root(__file__))
os.environ["PYODIDE_ROOT"] = str(search_pyodide_root(Path.cwd()))
Copy link
Member

Choose a reason for hiding this comment

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

Is this a safe change? It does something pretty different. Could you explain the logic before vs now?

Copy link
Member Author

@ryanking13 ryanking13 Mar 22, 2023

Choose a reason for hiding this comment

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

I think there was a bug in the logic before, which caused an error here: #3669.

Previously it was finding the pyodide root from the parents of that file. So if we don't install pyodide-build in a virtual environment inside the project folder, it failed.

Copy link
Member

@hoodmane hoodmane left a comment

Choose a reason for hiding this comment

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

Thanks again @ryanking13 !

@ryanking13 ryanking13 merged commit b801885 into pyodide:main Mar 23, 2023
@ryanking13 ryanking13 deleted the build-recipes-oot branch March 23, 2023 05:01
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.

3 participants