Skip to content

BLD: Add meson build scripts #49114

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

Merged
merged 2 commits into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions scripts/generate_pxi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import argparse
import os

from Cython import Tempita


def process_tempita(pxifile, outfile):
with open(pxifile) as f:
tmpl = f.read()
pyxcontent = Tempita.sub(tmpl)

with open(outfile, "w") as f:
f.write(pyxcontent)


def main():
parser = argparse.ArgumentParser()
parser.add_argument("infile", type=str, help="Path to the input file")
parser.add_argument("-o", "--outdir", type=str, help="Path to the output directory")
args = parser.parse_args()

if not args.infile.endswith(".in"):
raise ValueError(f"Unexpected extension: {args.infile}")

outdir_abs = os.path.join(os.getcwd(), args.outdir)
outfile = os.path.join(
outdir_abs, os.path.splitext(os.path.split(args.infile)[1])[0]
)

process_tempita(args.infile, outfile)


main()
34 changes: 34 additions & 0 deletions scripts/generate_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import argparse
import os

import versioneer
Copy link
Member

Choose a reason for hiding this comment

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

So this won't be our vendored versioneer?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops. I forgot to update this when I moved it into scripts, will fix it in my next PR.

Unfortunately, I don't think we are able to use non-vendored versioneer.



def write_version_info(path):
if os.environ.get("MESON_DIST_ROOT"):
# raise ValueError("dist root is", os.environ.get("MESON_DIST_ROOT"))
Copy link
Member

Choose a reason for hiding this comment

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

If you could remove in a follow up that would be great

path = os.path.join(os.environ.get("MESON_DIST_ROOT"), path)
with open(path, "w") as file:
file.write(f'__version__="{versioneer.get_version()}"\n')
file.write(
f'__git_version__="{versioneer.get_versions()["full-revisionid"]}"\n'
)


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()