Skip to content

Conversation

@robertodr
Copy link
Contributor

@robertodr robertodr commented Oct 26, 2019

Description

I've redone the Python bindings using pybind11. The bindings are now more transparent and easier to read/extend than the SWIG bindings were.

If pybind11 is not around, it will be fetched. This trick requires use of CMake 3.11 at least.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Questions

  • Can we tag 2.0.0 when this is approved and merge to master?

Status

  • Ready to go

@robertodr robertodr marked this pull request as ready for review October 27, 2019 21:58
@codecov-io
Copy link

codecov-io commented Oct 27, 2019

Codecov Report

Merging #96 into master will not change coverage.
The diff coverage is 75%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #96   +/-   ##
=======================================
  Coverage   49.46%   49.46%           
=======================================
  Files          77       77           
  Lines        1785     1785           
=======================================
  Hits          883      883           
  Misses        902      902
Impacted Files Coverage Δ
src/xcfun.cpp 71.99% <75%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ca137ba...db470d4. Read the comment docs.

@robertodr robertodr requested review from aspgomes and stigrj October 28, 2019 09:10
@stigrj
Copy link
Contributor

stigrj commented Oct 29, 2019

./setup --pybindings

gives the following error

CMake Error at python/CMakeLists.txt:8 (find_package):
  Could not find a package configuration file provided by "pybind11"
  (requested version 2.3.0) with any of the following names:

    pybind11Config.cmake
    pybind11-config.cmake

  Add the installation prefix of "pybind11" to CMAKE_PREFIX_PATH or set
  "pybind11_DIR" to a directory containing one of the above files.  If
  "pybind11" provides a separate development package or SDK, be sure it has
  been installed.

@robertodr
Copy link
Contributor Author

robertodr commented Oct 29, 2019 via email

@stigrj
Copy link
Contributor

stigrj commented Oct 29, 2019

Each download failed!

    error: downloading 'https://github.com/pybind/pybind11/archive/v2.3.0.tar.gz' failed
         status_code: 1
         status_string: "Unsupported protocol"
         log:
         --- LOG BEGIN ---
         Protocol "https" not supported or disabled in libcurl

  Closing connection -1

@robertodr
Copy link
Contributor Author

Ehm... It works on Travis 🤷‍♂️ Where are you trying to build?

@stigrj
Copy link
Contributor

stigrj commented Oct 29, 2019

It's the same

./setup --pybindings

...sorry, I read "what"...

I'm building on my Ubuntu

@robertodr
Copy link
Contributor Author

I cannot reproduce it. Can you try to cURL pybind11 by hand?

@stigrj
Copy link
Contributor

stigrj commented Oct 29, 2019

I'm able to run the command in .ci/pybind11.sh

curl -Ls https://github.com/pybind/pybind11/archive/v${pybind11_VERSION}.tar.gz | tar -xz -C pybind11 --strip-components=1

Is this the same command FetchContent_Populate runs?

@robertodr
Copy link
Contributor Author

I don't think it's the exact same, but something similar.

@robertodr
Copy link
Contributor Author

Googling turned this one up: https://github.com/ruslo/hunter/issues/972#issuecomment-323687499

@stigrj
Copy link
Contributor

stigrj commented Oct 29, 2019

Argh, the annoyance

@robertodr
Copy link
Contributor Author

Gentle nudge here. It'd be good to get this merged so I can move on with conda packaging and redoing the Fortran interface with iso_c_binding

@bast
Copy link
Member

bast commented Nov 8, 2019

I will review today ...

@robertodr
Copy link
Contributor Author

Thanks 🐙

Copy link
Member

@bast bast left a comment

Choose a reason for hiding this comment

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

Thumbs up from me but before we merge we need Andre and Christoph to comment since they depend most on the SWIG interface which would be removed by this merge.

I also agree that we target a v2.0.0 with this merge but would like if we test it a bit first. In other words this would be v2.0.0-beta or v2.0.0-rc.

@chjacob-tubs
Copy link
Contributor

Sorry, was busy / travelling the last two weeks. I will try to test over the weekend.

@robertodr
Copy link
Contributor Author

Yes, this should be a beta release. We can do rc when the Fortran bindings are refurbished.


m.def("xcfun_version", &xcfun_version, "XCFun version");
m.def("xcfun_splash", &xcfun_splash, "XCFun splash screen");

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please add
m.def("xcfun_test", &xcfun_test, "XCFun self test");

We are calling xcfun_test from the PyADF test suite to make sure xcfun is working correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review. Good catch! pybind11 won't generate binding code unless you explicitly define the function/class to be bound.

Copy link
Contributor

@chjacob-tubs chjacob-tubs left a comment

Choose a reason for hiding this comment

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

Looks good, except for my comment everything is working fine in PyADF.

@chjacob-tubs
Copy link
Contributor

It works on my Mac, but I somehow dont get it to work on Ubuntu. Setup now fails with
CMake Error: Could not open file for write in copy operation /home/christoph/sources/xcfun/build/include/XCFun/XCFunExport.h.tmp CMake Error: : System Error: Not a directory CMake Error at /home/christoph/sources/cmake-3.15-install/share/cmake-3.15/Modules/GenerateExportHeader.cmake:394 (configure_file): configure_file Problem configuring file Call Stack (most recent call first): /home/christoph/sources/cmake-3.15-install/share/cmake-3.15/Modules/GenerateExportHeader.cmake:410 (_do_generate_export_header) src/CMakeLists.txt:4 (generate_export_header)

Any idea what the problem might be?

@robertodr
Copy link
Contributor Author

Yes, I made a silly CMake mistake. Should be fixed in the latest commit.

@chjacob-tubs
Copy link
Contributor

OK, now it works! (One minor issue: It seems that CMake does not discover the system-installed pybind11 but always downloads and builds itself. Thats fine for me, I actually dont know how / where CMake is looking for pybind11)

@robertodr
Copy link
Contributor Author

How was pybind11 installed? I can look at this later next week.

@chjacob-tubs
Copy link
Contributor

On Ubuntu both with apt-get and with pip, an the Mac with macports

@robertodr
Copy link
Contributor Author

The PyPI package does not install the CMake support files. The package from apt-get might be too old? What version is it?

@chjacob-tubs
Copy link
Contributor

OK, I got it to work, I guess that was the problem.

@chjacob-tubs
Copy link
Contributor

Should we merge this now? How are you handling this / who is pushing the button?

@robertodr
Copy link
Contributor Author

Sorry, should have been clearer. I wanted to give @aspgomes one more week for comments, then anyone with write access can push the button (I usually prefer not to self-merge)

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.

6 participants