diff options
author | Ralf Gommers <ralf.gommers@gmail.com> | 2022-11-23 23:40:23 +0100 |
---|---|---|
committer | Ralf Gommers <ralf.gommers@gmail.com> | 2022-11-25 12:37:46 +0100 |
commit | 4002a7d421ff10780c28a3643683af7a9754f87f (patch) | |
tree | a06d4c10642d1c93d552f80f1e90f393c9953c18 /generate_version.py | |
parent | 632f573f12c641990bfac24cf4df435804340a7f (diff) | |
download | numpy-4002a7d421ff10780c28a3643683af7a9754f87f.tar.gz |
BLD: enable building NumPy with Meson
This enables building with NumPy on Linux and macOS. Windows support
should be complete to, but is untested as of now and may need a few
tweaks. This contains:
- A set of `meson.build` files and related code generation script
tweaks, header templates, etc.
- One CI job on Linux
- Basic docs on using Meson to build NumPy (not yet integrated in the
html docs, it's too early for that - this is for early adopters right
now).
The build should be complete, with the major exception of SIMD support.
The full test suite passes. See gh-22546 for the tracking issue with
detailed notes on the plan for switching NumPy to Meson as its build
system.
Co-authored-by: Stefan van der Walt <stefanv@berkeley.edu>
Diffstat (limited to 'generate_version.py')
-rw-r--r-- | generate_version.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/generate_version.py b/generate_version.py new file mode 100644 index 000000000..b3c8a3978 --- /dev/null +++ b/generate_version.py @@ -0,0 +1,40 @@ +# Note: This file has to live next to versioneer.py or it will not work +import argparse +import os + +import versioneer + + +def write_version_info(path): + vinfo = versioneer.get_versions() + full_version = vinfo['version'] + git_revision = vinfo['full-revisionid'] + + if os.environ.get("MESON_DIST_ROOT"): + path = os.path.join(os.environ.get("MESON_DIST_ROOT"), path) + + with open(path, "w") as f: + f.write("def get_versions():\n") + f.write(" return {\n") + f.write(f" 'full-revisionid': '{git_revision}',\n") + f.write(f" 'version': '{full_version}'\n") + f.write("}") + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument( + "-o", "--outfile", type=str, help="Path to write version info to" + ) + args = parser.parse_args() + + if not args.outfile.endswith(".py"): + raise ValueError( + f"Output file must be a Python file. " + f"Got: {args.outfile} as filename instead" + ) + + write_version_info(args.outfile) + + +main() |