-
Notifications
You must be signed in to change notification settings - Fork 1
Migrate the build system to Meson/meson-python #301
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
Open
agriyakhetarpal
wants to merge
47
commits into
main
Choose a base branch
from
meson-python!
base: main
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.
Open
Changes from 25 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
d031c07
Add template `meson.build`
agriyakhetarpal af44227
Delete setuptools-related files
agriyakhetarpal 21577e7
Just make the binary "hugo" or "hugo.exe"
agriyakhetarpal 4ae548f
Add Hugo version template + Python files
agriyakhetarpal 7f805cb
Remove more setuptools metadata
agriyakhetarpal 41a7b34
Add meson-python as build backend
agriyakhetarpal 98540ae
Start script to build Hugo
agriyakhetarpal a25684e
Setup Zig, build Hugo, swap correct build date
agriyakhetarpal 5533e50
Override meson-python for build backend
agriyakhetarpal 9019d1b
Change location of Hugo cache storage
agriyakhetarpal f445608
Rename meson wrapper file
agriyakhetarpal 1fb5b2d
Generate some cross files
agriyakhetarpal 220b75c
Add config settings to use cross files + TODOs
agriyakhetarpal a7275ca
Fix path to build backend
agriyakhetarpal cb10e5e
Fix Hugo version update process
agriyakhetarpal 0717760
Change submodule location
agriyakhetarpal 76c8906
Delete wheel committed by error
agriyakhetarpal 69c2715
Add submodule at new location
agriyakhetarpal f6d144d
Add a job to test editable installations
agriyakhetarpal cce6c65
Make the sdist smaller
agriyakhetarpal ba30349
Add use_zig mappings and Hugo custom_target
agriyakhetarpal 42f441a
Update CLI paths for Hugo executable
agriyakhetarpal d0d09dc
Ignore generated version file
agriyakhetarpal a70288f
Try setting path to cross file
agriyakhetarpal e226c76
Stop meson-python from Windows internal libs check
agriyakhetarpal d361dd1
Test editable build with Python 3.14
agriyakhetarpal d414544
Point to generated cross files correctly
agriyakhetarpal 4cef2a0
Fix win32 cross file + fix paths to cross files
agriyakhetarpal 8c4ae9b
Try `github.workspace`
agriyakhetarpal f6e2f18
Work around Windows Meson cross file stuff...
agriyakhetarpal d15b18d
Fix lint
agriyakhetarpal 0546e02
Try to resolve different Hugo executables
agriyakhetarpal 943f122
Make editable session verbose
agriyakhetarpal 3ce50f6
Fix Python 3.10 joinpath mess
agriyakhetarpal e34f372
Fix wrong zig-windows-amd64-to-arm64 wheel tag
agriyakhetarpal 9a2f099
Try to make auditwheel happy
agriyakhetarpal dd20e6e
Force the platform tag in `get_platform_tag` to be correct
agriyakhetarpal d70881a
🪩 Automated fixes from https://pre-commit.ci
pre-commit-ci[bot] 3150bcb
Merge branch 'main' into meson-python!
agriyakhetarpal 202832a
Debug: try something
agriyakhetarpal 3965988
Revert "Debug: try something"
agriyakhetarpal 8d3d588
Revert "Try to make auditwheel happy"
agriyakhetarpal b0a80ac
Install binary to `datadir`, pick it using `sysconfig`
agriyakhetarpal d72d177
Update docs
agriyakhetarpal a2dba63
🪩 Automated fixes from https://pre-commit.ci
pre-commit-ci[bot] 1748319
Merge branch 'main' into meson-python!
agriyakhetarpal ef37cea
Bump version
agriyakhetarpal 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
Some comments aren't visible on the classic Files Changed page.
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
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
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 |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| [submodule "hugo"] | ||
| path = hugo | ||
| path = hugo-src | ||
| url = https://github.com/gohugoio/hugo.git |
This file was deleted.
Oops, something went wrong.
Submodule hugo-src
updated
from 000000 to d6bc81
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,105 @@ | ||
| project( | ||
| 'hugo-python-distributions', | ||
| version : '0.160.1', | ||
| meson_version : '>=1.3.0', | ||
| default_options : ['warning_level=0'], | ||
| ) | ||
|
|
||
| # Setting `pure: true` routes the Python package (including the bundled Hugo | ||
| # executable) to purelib, so platlib stays empty. Combined with the marker file | ||
| # installed into libdir below, this keeps the wheel tag at py3-none-<platform> | ||
| # instead of a Python-version-specific ABI tag. | ||
| # See _has_extension_modules and _pure in mesonpy/__init__.py | ||
| py = import('python').find_installation(pure: true) | ||
|
|
||
| go = find_program('go', required: true) | ||
| git = find_program('git', required: true) | ||
|
|
||
| configure_file( | ||
| input : 'src/hugo/_version.py.in', | ||
| output : '_version.py', | ||
| configuration : { 'HUGO_VERSION' : meson.project_version() }, | ||
| install : true, | ||
| install_dir : py.get_install_dir() / 'hugo', | ||
| install_tag : 'python-runtime', | ||
| ) | ||
|
|
||
| py.install_sources( | ||
| ['src/hugo/__main__.py', 'src/hugo/cli.py'], | ||
| subdir : 'hugo', | ||
| ) | ||
|
|
||
| host_sys = host_machine.system() | ||
| host_cpu = host_machine.cpu_family() | ||
| exe_suffix = host_sys == 'windows' ? '.exe' : '' | ||
|
|
||
| # Map meson's host_machine values to Golang's GOOS/GOARCH values | ||
| # for cross-compilation | ||
| GOOS_MAP = { | ||
| 'linux' : 'linux', | ||
| 'darwin' : 'darwin', | ||
| 'windows' : 'windows', | ||
| } | ||
| GOARCH_MAP = { | ||
| 'x86_64' : 'amd64', | ||
| 'aarch64' : 'arm64', | ||
| 'arm' : 'arm', | ||
| 'x86' : '386', | ||
| 'ppc64' : 'ppc64le', | ||
| 's390x' : 's390x', | ||
| 'riscv64' : 'riscv64', | ||
| } | ||
| if not GOOS_MAP.has_key(host_sys) | ||
| error('Unsupported host_machine.system: ' + host_sys) | ||
| endif | ||
| if not GOARCH_MAP.has_key(host_cpu) | ||
| error('Unsupported host_machine.cpu_family: ' + host_cpu) | ||
| endif | ||
| goos = GOOS_MAP[host_sys] | ||
| goarch = GOARCH_MAP[host_cpu] | ||
|
|
||
| # Use Zig when cross-compiling, except for the "macOS arm64 to macOS x86_64" | ||
| # case where Zig lacks the macOS SDK and cannot find libresolv.dylib. For that | ||
| # we rely on the system linker as it is where AppleClang has native support | ||
| # for cross-compilation. This can still be overridden by setting the use_zig | ||
| # option to true or false explicitly. | ||
| auto_use_zig = meson.is_cross_build() and host_sys != 'darwin' | ||
| use_zig_opt = get_option('use_zig') | ||
| use_zig = use_zig_opt.auto() ? auto_use_zig : use_zig_opt.enabled() | ||
|
|
||
|
|
||
| custom_target( | ||
| 'hugo-binary', | ||
| output : 'hugo' + exe_suffix, # must match src/hugo/cli.py | ||
| command : [ | ||
| py.full_path(), | ||
| files('scripts/build_hugo.py'), | ||
| '--hugo-src', meson.project_source_root() / 'hugo-src', | ||
| '--cache', meson.project_build_root() / 'hugo_cache', | ||
| '--version', meson.project_version(), | ||
| '--output', '@OUTPUT@', | ||
| '--use-zig', use_zig.to_string(), | ||
| '--goos', goos, | ||
| '--goarch', goarch, | ||
| ], | ||
| install : true, | ||
| install_dir : py.get_install_dir() / 'hugo' / 'binaries', | ||
| install_tag : 'python-runtime', | ||
| build_by_default : true, | ||
| console : true, | ||
| ) | ||
|
|
||
| # This is a hack to make meson-python mark the wheel as non-pure regardless | ||
| # of whether the host platform's magic-number check in mesonpy._is_native | ||
| # matches the target binary. _pure becomes False whenever mesonpy-libs | ||
| # ({libdir}) is non-empty, without running _is_native on its contents. See | ||
| #_WheelBuilder._pure in mesonpy/__init__.py. | ||
| configure_file( | ||
| output : '.platform_marker', | ||
| configuration : configuration_data(), | ||
| install : true, | ||
| install_dir : get_option('libdir'), | ||
| install_tag : 'runtime', | ||
| ) | ||
|
|
||
| meson.add_dist_script(py.full_path(), files('scripts/prune_sdist.py')) |
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,6 @@ | ||
| option( | ||
| 'use_zig', | ||
| type : 'feature', | ||
| value : 'auto', | ||
| description : 'Use ziglang as the CGO cross-compiler. "auto" picks Zig when cross-compiling to a non-darwin target.', | ||
| ) |
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 @@ | ||
| [host_machine] | ||
| system = 'linux' | ||
| cpu_family = 'aarch64' | ||
| cpu = 'aarch64' | ||
| endian = 'little' |
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 @@ | ||
| [host_machine] | ||
| system = 'windows' | ||
| cpu_family = 'x86' | ||
| cpu = 'i686' | ||
| endian = 'little' |
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 @@ | ||
| [host_machine] | ||
| system = 'windows' | ||
| cpu_family = 'aarch64' | ||
| cpu = 'aarch64' | ||
| endian = 'little' |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.