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

Meson support #413

Merged
merged 28 commits into from
Apr 8, 2024
Merged

Meson support #413

merged 28 commits into from
Apr 8, 2024

Conversation

WillAyd
Copy link
Contributor

@WillAyd WillAyd commented Apr 1, 2024

Not sure if there is a desire for supporting another build backend, but figured I would share in case.

Meson seems a bit simpler than the existing CMake configuration, and has the advantage of:

  1. Installing dependencies via the wrap database easily
  2. Potentially making nanoarrow installable via the WrapDB

Point 2 is not covered here, but might be a nice future enhancement for downstream Python libraries like NumPy and pandas that use Meson as their build systems

@codecov-commenter
Copy link

codecov-commenter commented Apr 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.76%. Comparing base (a9ef745) to head (bfaea57).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #413   +/-   ##
=======================================
  Coverage   88.76%   88.76%           
=======================================
  Files          82       82           
  Lines       14633    14633           
=======================================
  Hits        12989    12989           
  Misses       1644     1644           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@paleolimbot paleolimbot left a comment

Choose a reason for hiding this comment

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

Thank you for opening this!

I'm definitely open to this for nanoarrow as long as the options that are exposed are tested and there is an example somewhere of how to use nanoarrow as a meson dependency. Off the top of my head, a script like ci/scripts/meson-build.sh might be a low-effort way to do this, and we could maybe add it as a weekly job (like release verification)?

@WillAyd WillAyd marked this pull request as ready for review April 2, 2024 01:19
@WillAyd
Copy link
Contributor Author

WillAyd commented Apr 2, 2024

Sounds good - I just copied over the minimal example and switched it to Meson. It is still a little different from what end users would do long term (i.e. would be nice to have nanoarrow in the WrapDB) but I think the gist of it is there

Copy link
Member

@paleolimbot paleolimbot left a comment

Choose a reason for hiding this comment

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

would be nice to have nanoarrow in the WrapDB)

Perhaps after 0.5.0 (in a month or so) it could be submitted? No pressure, but if you'd be willing to take that on I'd be happy to support anything else that needs to happen.

ci/scripts/build-with-meson.sh Show resolved Hide resolved
ci/scripts/build-with-meson.sh Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

There is a more minimal example in the cmake build tests folder in examples/ that might be a better fit here (and also might be a better fit in the minimal cmake example, too, in some future PR making all our examples better).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you point me to which example you are talking about? I copied the source code for this over from cmake-minimal

# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

Copy link
Member

Choose a reason for hiding this comment

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

Does this need a comment explaining what the difference would be if this weren't in the source tree? (At least until nanoarrow is in the wrap database?)

meson.build Show resolved Hide resolved
Comment on lines 23 to 24
# TODO: CMake uses a regex to extract major/minor/patch from this string
version = '0.5.0-SNAPSHOT'
Copy link
Member

Choose a reason for hiding this comment

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

This can be hard-coded as long as it's in the version-bumping script (linked above)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ended up replacing this in the latest version to pull from the project configuration. I don't believe meson supports regular expressions so its a bit more convoluted than the CMake version to split that into major / minor / patch, but I think should work

Comment on lines 73 to 75
# TODO: the CMake configuration sets a different C++ version depending on
# the version of Arrow used. Meson allows this standard to be set by subproject
# do we need to do anything here?
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need this for the Meson build...we need some way to make sure that this works on Centos7, but not for very long, and we can just use CMake to test that.

src/nanoarrow/meson.build Show resolved Hide resolved
Comment on lines 26 to 28
paths:
- '.github/workflows/meson-build.yaml'
- 'ci/scripts/build-with-meson.sh'
Copy link
Member

Choose a reason for hiding this comment

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

Probably this should also run when any of the config or options or build files are modified?

@WillAyd
Copy link
Contributor Author

WillAyd commented Apr 2, 2024

Yea happy to do so

Comment on lines 19 to 20
incdir = '../../../src'
incdir2 = '../../../src/nanoarrow'
Copy link
Member

Choose a reason for hiding this comment

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

thanks for the PR, I am not an expert on meson but this feels odd. Isn't there a way to not hardcode those directory paths?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch - I set that up before I created the nanoarrow_dep target, but can switch over to that

Copy link
Member

@paleolimbot paleolimbot left a comment

Choose a reason for hiding this comment

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

I took a run through the READMEs and found a couple of things! Meson is cool!

Comment on lines 27 to 31
- 'meson.build'
- 'meson.options'
- 'src/nanoarrow/meson.build'
- 'dev/benchmarks/meson.build'
- 'dev/benchmarks/c/meson.build'
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- 'meson.build'
- 'meson.options'
- 'src/nanoarrow/meson.build'
- 'dev/benchmarks/meson.build'
- 'dev/benchmarks/c/meson.build'
- '**meson.build'
- '**meson.options'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There should only ever be one meson.options file at the project root so I didn't add the wildcard for that. But nice idea on the meson.build files

.github/workflows/meson-build.yaml Show resolved Hide resolved
under the License.
-->

# Minimal CMake Example
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# Minimal CMake Example
# Minimal Meson Example

Copy link
Member

Choose a reason for hiding this comment

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

I still think that the minimal example could be smaller here:

#include "nanoarrow/nanoarrow.h"
#include "nanoarrow/nanoarrow.hpp"
int main(int argc, char* argv[]) {
nanoarrow::UniqueSchema schema;
NANOARROW_RETURN_NOT_OK(ArrowSchemaInitFromType(schema.get(), NANOARROW_TYPE_INT32));
printf("Schema format for int32 is '%s'", schema->format);
return EXIT_SUCCESS;
}

README.md Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Outdated
Upon a successful build you can execute the test suite and benchmarks with the following commands:

```sh
meson test # default test run
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
meson test # default test run
meson test nanoarrow: # default test run

README.md Outdated
```sh
meson test # default test run
meson test --wrap valgrind # run tests under valgrind
meson test --benchmark # run benchmarks
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
meson test --benchmark # run benchmarks
meson test --benchmark --verbose # run benchmarks

resulting length (or any error encountered whilst building the array).

```bash
./example_cmake_minimal_app
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
./example_cmake_minimal_app
./example_meson_minimal_app

@WillAyd
Copy link
Contributor Author

WillAyd commented Apr 8, 2024

I believe I addressed all feedback but let me know if anything is outstanding

Copy link
Member

@paleolimbot paleolimbot left a comment

Choose a reason for hiding this comment

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

Sorry...I missed that notification! Thank you!

@paleolimbot paleolimbot merged commit 22eab6b into apache:main Apr 8, 2024
33 checks passed
@WillAyd WillAyd deleted the meson-support branch April 8, 2024 18:45
eddelbuettel pushed a commit to eddelbuettel/arrow-nanoarrow that referenced this pull request Apr 10, 2024
Not sure if there is a desire for supporting another build backend, but
figured I would share in case.

Meson seems a bit simpler than the existing CMake configuration, and has
the advantage of:

  1. Installing dependencies via the wrap database easily
2. Potentially making nanoarrow installable via the
[WrapDB](https://mesonbuild.com/Adding-new-projects-to-wrapdb.html)

Point 2 is not covered here, but might be a nice future enhancement for
downstream Python libraries like NumPy and pandas that use Meson as
their build systems
@paleolimbot paleolimbot added this to the nanoarrow 0.5.0 milestone May 22, 2024
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.

4 participants