-
Notifications
You must be signed in to change notification settings - Fork 19
RFC: replace setuptools with meson-python for more stable and predictable builds and installations #128
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
Draft
ilumsden
wants to merge
33
commits into
llnl:develop
Choose a base branch
from
TauferLab:meson_build_sys
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
RFC: replace setuptools with meson-python for more stable and predictable builds and installations #128
Changes from 25 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
470e1e7
Adds automated codecov support to Hatchet
ilumsden 029e147
Bumps Python version for black and flake checks to 3.9 to ensure tool…
ilumsden e78da99
Initial changes
ilumsden ca108fc
Sets gitattributes to not capture tests directory in dist
ilumsden d4b7791
Further updates to gitattributes and gitignore
ilumsden 26f7493
Spelling fix
ilumsden 0af93d1
Current progress
ilumsden 60e2f8c
Gets a fully working package with meson-python
ilumsden d5a76c9
Removes 'meson[ninja]' from pyproject.toml's build-system.requires si…
ilumsden f101329
Cleans up metadata in pyproject.toml
ilumsden cbfe0d2
Adds a check to the top-level meson.build to ensure the version in ve…
ilumsden 60b1e11
Adds comments
ilumsden e2ff223
Adds extra for HDF5 writer
ilumsden 38d4500
Tweaks CI to install Hatchet locally with pip
ilumsden 43a9955
Fixes license headers
ilumsden ccddb5f
Formatting fix
ilumsden 0c9eb9d
Formatting to make flake happy
ilumsden ecde7ba
Adds ninja extra to build requirements for Hatchet
ilumsden 70b2c6b
Adds script for editable installs and tries not using editable in uni…
ilumsden 2feaace
Adds tables extra to install of Hatchet in CI
ilumsden 4daea24
Fixes the extra name in CI
ilumsden fce6d47
Merge branch 'develop' into meson_build_sys
ilumsden fb08595
Update .gitattributes
ilumsden 1f9199b
Update pyproject.toml
ilumsden 2b2e54f
Drops the version check on the textx dependency since that check will…
ilumsden f52430d
Deletes install.sh since it will no longer work
ilumsden 407ef1a
Adds some arguments to find_installation to try to restrict lookup
ilumsden a038611
Updates top level meson.build to get version from Hatchet's Python code
ilumsden 670ab8a
Removes the hatchet.__version__ check as it is now redundant
ilumsden e067ae1
Small syntax fix
ilumsden 66d5d81
Tries to get print_version.py running
ilumsden 8e92bc5
Reverts the version stuff in meson since running print_version.py isn…
ilumsden 952efa7
A few attempted fixes
ilumsden File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,3 +9,5 @@ max-line-length = 88 | |
| select = C,E,F,W,B,B950 | ||
| ignore = E501,W503,E203 | ||
| builtins = IPython | ||
| exclude = | ||
| build | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| hatchet/tests export-ignore | ||
| screenshot.png export-ignore | ||
| pytest.ini export-ignore | ||
| logo.png export-ignore | ||
| logo-hex.png export-ignore | ||
| install.sh export-ignore | ||
| CHANGELOG.md export-ignore | ||
| .pre-commit-config.yaml export-ignore | ||
| .flake8 export-ignore | ||
| .coveragerc export-ignore | ||
| .codecov.yml export-ignore | ||
| docs export-ignore | ||
| .github export-ignore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,3 +14,4 @@ hatchet/vis/static/*_bundle* | |
|
|
||
| dist/ | ||
| llnl_hatchet.egg-info/ | ||
| **/__pycache__/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # Specify the names of the Cython extension modules, excluding file extensions | ||
| cython_module_names = [ | ||
| 'graphframe_modules', | ||
| 'reader_modules' | ||
| ] | ||
|
|
||
| # Loop over the Cython modules and build/install them to | ||
| # <INSTALL_PREFIX>/hatchet/cython_modules/libs | ||
| foreach mod_name : cython_module_names | ||
| py.extension_module( | ||
| mod_name, | ||
| mod_name + '.pyx', | ||
| dependencies: py_dep, | ||
| subdir: 'hatchet' / 'cython_modules' / 'libs', | ||
| install: true | ||
| ) | ||
| endforeach |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Specify the pure Python files for this directory | ||
| hatchet_external_python_sources = [ | ||
| '__init__.py', | ||
| 'console.py' | ||
| ] | ||
|
|
||
| # Install the specified pure Python files into | ||
| # <INSTALL_PREFIX>/hatchet/external | ||
| py.install_sources( | ||
| hatchet_external_python_sources, | ||
| pure: false, | ||
| subdir: 'hatchet' / 'external' | ||
| ) | ||
|
|
||
| # Install roundtrip as-is into | ||
| # <INSTALL_PREFIX>/hatchet/external | ||
| install_subdir( | ||
| 'roundtrip', | ||
| install_dir: py_top_install_dir / 'hatchet' / 'external' | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # Specify the pure Python files for this directory | ||
| hatchet_python_sources = [ | ||
| '__init__.py', | ||
| 'frame.py', | ||
| 'graph.py', | ||
| 'graphframe.py', | ||
| 'node.py', | ||
| 'version.py' | ||
| ] | ||
|
|
||
| # Install the specified pure Python files into | ||
| # <INSTALL_PREFIX>/hatchet | ||
| py.install_sources( | ||
| hatchet_python_sources, | ||
| pure: false, | ||
| subdir: 'hatchet' | ||
| ) | ||
|
|
||
| # Go through all the subdirectories except for 'test' | ||
| subdir('cython_modules') | ||
| subdir('external') | ||
| subdir('query') | ||
| subdir('readers') | ||
| subdir('util') | ||
| subdir('vis') | ||
| subdir('writers') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Specify the pure Python files for this directory | ||
| hatchet_query_python_sources = [ | ||
| '__init__.py', | ||
| 'compat.py', | ||
| 'compound.py', | ||
| 'engine.py', | ||
| 'errors.py', | ||
| 'object_dialect.py', | ||
| 'query.py', | ||
| 'string_dialect.py' | ||
| ] | ||
|
|
||
| # Install the specified pure Python files into | ||
| # <INSTALL_PREFIX>/hatchet/query | ||
| py.install_sources( | ||
| hatchet_query_python_sources, | ||
| pure: false, | ||
| subdir: 'hatchet' / 'query' | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # Specify the pure Python files for this directory | ||
| hatchet_readers_python_sources = [ | ||
| '__init__.py', | ||
| 'caliper_native_reader.py', | ||
| 'caliper_reader.py', | ||
| 'cprofile_reader.py', | ||
| 'dataframe_reader.py', | ||
| 'gprof_dot_reader.py', | ||
| 'hdf5_reader.py', | ||
| 'hpctoolkit_reader.py', | ||
| 'json_reader.py', | ||
| 'literal_reader.py', | ||
| 'pyinstrument_reader.py', | ||
| 'spotdb_reader.py', | ||
| 'tau_reader.py', | ||
| 'timemory_reader.py' | ||
| ] | ||
|
|
||
| # Install the specified pure Python files into | ||
| # <INSTALL_PREFIX>/hatchet/readers | ||
| py.install_sources( | ||
| hatchet_readers_python_sources, | ||
| pure: false, | ||
| subdir: 'hatchet' / 'readers' | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # Specify the pure Python files for this directory | ||
| # Note: don't include 'print_version.py' because | ||
| # that file is not needed in binary distributions | ||
| hatchet_util_python_sources = [ | ||
| '__init__.py', | ||
| 'colormaps.py', | ||
| 'config.py', | ||
| 'deprecated.py', | ||
| 'dot.py', | ||
| 'executable.py', | ||
| 'profiler.py', | ||
| 'timer.py' | ||
| ] | ||
|
|
||
| # Install the specified pure Python files into | ||
| # <INSTALL_PREFIX>/hatchet/util | ||
| py.install_sources( | ||
| hatchet_util_python_sources, | ||
| pure: false, | ||
| subdir: 'hatchet' / 'util' | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Copyright 2017-2023 Lawrence Livermore National Security, LLC and other | ||
| # Hatchet Project Developers. See the top-level LICENSE file for details. | ||
| # | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
| import os | ||
| import sys | ||
|
|
||
| sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | ||
|
|
||
| from version import __version__ # noqa: E402 | ||
|
|
||
| print(__version__) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # Specify the pure Python files for this directory | ||
| hatchet_vis_python_sources = [ | ||
| '__init__.py', | ||
| 'loader.py', | ||
| 'static_fixer.py' | ||
| ] | ||
|
|
||
| # Install the specified pure Python files into | ||
| # <INSTALL_PREFIX>/hatchet/vis | ||
| py.install_sources( | ||
| hatchet_vis_python_sources, | ||
| pure: false, | ||
| subdir: 'hatchet' / 'vis' | ||
| ) | ||
|
|
||
| # Install directory for this source directory | ||
| hatchet_vis_install_dir = py_top_install_dir / 'hatchet' / 'vis' | ||
|
|
||
| # Install all the subdirectories for visualization code as-is | ||
| # into hatchet_vis_install_dir | ||
| install_subdir( | ||
| 'external', | ||
| install_dir: hatchet_vis_install_dir | ||
| ) | ||
| install_subdir( | ||
| 'scripts', | ||
| install_dir: hatchet_vis_install_dir | ||
| ) | ||
| install_subdir( | ||
| 'static', | ||
| install_dir: hatchet_vis_install_dir | ||
| ) | ||
| install_subdir( | ||
| 'styles', | ||
| install_dir: hatchet_vis_install_dir | ||
| ) | ||
| install_subdir( | ||
| 'templates', | ||
| install_dir: hatchet_vis_install_dir | ||
| ) | ||
|
|
||
| # Install the following non-Python files as-is | ||
| # into hatchet_vis_install_dir | ||
| install_data( | ||
| 'package.json', 'README.md', 'requirements.txt', 'webpack.config.js', | ||
| install_dir: hatchet_vis_install_dir | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Specify the pure Python files for this directory | ||
| hatchet_writers_python_sources = [ | ||
| '__init__.py', | ||
| 'dataframe_writer.py', | ||
| 'hdf5_writer.py' | ||
| ] | ||
|
|
||
| # Install the specified pure Python files into | ||
| # <INSTALL_PREFIX>/hatchet/writers | ||
| py.install_sources( | ||
| hatchet_writers_python_sources, | ||
| pure: false, | ||
| subdir: 'hatchet' / 'writers' | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #!/bin/bash | ||
|
|
||
| python3 -m pip install meson[ninja] meson-python Cython | ||
|
|
||
| python3 -m pip install --no-build-isolation -e . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # Setup the Meson Project | ||
| project('llnl-hatchet', 'cython', | ||
| version: '2024.1.1' | ||
| ) | ||
|
|
||
| # Get the Meson Python object, a dependency object to Python for extension modules, | ||
| # and the path to the top-level install directory | ||
| py = import('python').find_installation(pure: false) | ||
| py_dep = py.dependency() | ||
| py_top_install_dir = py.get_install_dir() | ||
|
|
||
| # Verify that the version from version.py matches the Meson project version | ||
| version_run = run_command(py.path(), meson.current_source_dir() / 'hatchet' / 'util' / 'print_version.py') | ||
| if version_run.returncode() != 0 | ||
| error('The __version__ variable in Hatchet cannot be determined') | ||
| endif | ||
| version_from_py = version_run.stdout().strip() | ||
| if not version_from_py.version_compare(meson.project_version()) | ||
| error('The __version__ variable in Hatchet does not match the Meson project version') | ||
| endif | ||
|
|
||
| # Enter the 'hatchet' subdirectory | ||
| subdir('hatchet') | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to note that I was able to build hatchet with meson on Quartz using conda and python 3.11.9. But when trying on local (Windows) using conda (python 3.11.9), I get the following error on this line:
Same error If i run
. install_editable.sh. I was able to install this way withsetuptools.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two questions related to this @michaelmckinsey1:
pkgconfiginstalled?libpython<version_stuff>.so) installed?Long story short, this is essentially caused by Windows being different from every other OS on the planet and doing certain things differently from every other OS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michaelmckinsey1 when you get the chance, can you try to download and install the following sdist in a Python venv?
https://files.pythonhosted.org/packages/65/6e/09db70a523a96d25e115e71cc56a6f9031e7b8cd166c1ac8438307c14058/numpy-1.26.4.tar.gz
Once the file is downloaded, you can install with
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious if that will fail with the same error. From what I can tell, the Python lookup Meson code is the same as what NumPy uses. If installing that sdist fails too, then there's likely an issue with your Windows install of Python. But, if it doesn't, then there's something wrong with my Meson stuff in Hatchet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pkgconfig, but installing it did not fix the issue..dllnot.soright? I don't even see anylibpython*.dll, all I see in conda is:I also tried with
venv, and I tried on another windows device with conda, same error. I would assume for now it's a general issue with our meson build for Windows, unless someone else is able to successfully build on Windows.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michaelmckinsey1 can you run
python3 -m sysconfigand paste the output here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For what it's worth, I can now reproduce on macOS when pkgconfig is not installed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I've worked this out. For some (stupid) reason, Meson never tries to use Python's
sysconfiglibrary to locate the development libraries or include dirs. Meson has 2 lookup modes for the Python dependency:pkgconfig: invokes pkg-config to locate the libraries. Will fail if pkg-config is not installed (unlikely on Linux, but likely on macOS and Windows), ifPKG_CONFIG_PATHis not properly set, or if the Python install does not have a.pcfilesystem: uses variables insysconfigto build the expected library name and searches for that library in recognized compiler search paths (e.g.,LD_LIBRARY_PATHon UNIX). This is why I said Meson's a bit stupid because it's already usingsysconfigto build library names, but it's not using thesysconfigvariables that directly point to the recognized libpythonSo, because we build extension modules (i.e., the Cython code), users need one of the following to be true:
pkg-configmust be installedLD_LIBRARY_PATH) need to be properly setThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michaelmckinsey1 when you get the chance, can you try at least one of these solutions on Windows? I'll try on macOS. If this works, I'll try to see if there's a way I can add pkg-config to the build dependencies