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 poc #19

Closed
wants to merge 80 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
36112ef
WIP: Build pandas with meson
lithomas1 Jul 12, 2022
6219ad0
update
lithomas1 Jul 14, 2022
33a0a7c
[skip ci] compile more & test something
lithomas1 Jul 14, 2022
43ba995
compile more
lithomas1 Jul 16, 2022
15e0385
build all extensions
lithomas1 Jul 18, 2022
0eeaa7d
clean a little
lithomas1 Jul 19, 2022
7c2c132
clean more
lithomas1 Jul 19, 2022
3df0963
super mega cleanup
lithomas1 Jul 24, 2022
e70bfc6
remove deps usage & maybe workaround bug
lithomas1 Jul 25, 2022
950f0a6
fix install paths
lithomas1 Jul 25, 2022
7e401dc
fix all oopsies
lithomas1 Jul 25, 2022
95e49e7
Merge branch 'pandas-dev:main' into meson-poc
lithomas1 Aug 22, 2022
781a671
Merge branch 'main' of https://github.com/pandas-dev/pandas into meso…
lithomas1 Sep 1, 2022
d074fc1
build pandas on CI with meson
lithomas1 Sep 1, 2022
e0214a5
try something
lithomas1 Sep 2, 2022
2751aee
try something
lithomas1 Sep 2, 2022
5e04d4e
try building with pip again
lithomas1 Sep 19, 2022
6edad44
install meson-python too
lithomas1 Sep 19, 2022
8f0adf2
use my meson-python fork
lithomas1 Sep 19, 2022
47f21d7
build in verbose mode
lithomas1 Sep 20, 2022
30e11c6
Merge remote-tracking branch 'upstream/main' into meson-poc
lithomas1 Sep 20, 2022
132a689
update
lithomas1 Sep 21, 2022
89c4b6b
add required shell
lithomas1 Sep 21, 2022
5f0a175
fix msvc detection?
lithomas1 Sep 22, 2022
48b02d4
try something
lithomas1 Sep 22, 2022
9b83eff
maybe fix windows?
lithomas1 Sep 22, 2022
039123f
maybe fix?
lithomas1 Sep 22, 2022
deb9305
Merge branch 'pandas-dev:main' into meson-poc
lithomas1 Sep 24, 2022
eb41668
disable caching for now
lithomas1 Sep 24, 2022
94ccae2
try to fix windows again
lithomas1 Sep 24, 2022
4c0d93c
maybe fix?
lithomas1 Sep 24, 2022
6efabb1
hardcode version, fix windows?
lithomas1 Sep 24, 2022
883fca7
use my fork of meson as well
lithomas1 Sep 24, 2022
b49f4c5
maybe fix sas module export name?
lithomas1 Sep 25, 2022
da09ba0
keep using versioneer
lithomas1 Oct 3, 2022
5b4dddc
fix version string
lithomas1 Oct 3, 2022
25178d5
hopefully get versionning working, other than the sdist case
lithomas1 Oct 3, 2022
a15586a
fix show_versions
lithomas1 Oct 4, 2022
3c5ae94
green?
lithomas1 Oct 14, 2022
c01409c
try to fix coverage
lithomas1 Oct 14, 2022
a286e66
maybe fix?
lithomas1 Oct 14, 2022
e61ef35
fix version generation for sdists
lithomas1 Oct 15, 2022
588527f
Finally fix?
lithomas1 Oct 15, 2022
9a94331
Merge remote-tracking branch 'upstream/main' into meson-poc
lithomas1 Oct 15, 2022
d4da54b
Update for sas byteswap module
lithomas1 Oct 18, 2022
15e2cd0
Pull upstreamed changes
lithomas1 Oct 19, 2022
3983e1c
Fix everything else?
lithomas1 Oct 19, 2022
f3a9419
fix circleci and maybe fix docs
lithomas1 Oct 20, 2022
bfcb9d0
Update
lithomas1 Oct 22, 2022
524e493
Merge branch 'main' into meson-poc
lithomas1 Nov 2, 2022
a62ee23
adjust build to account for deprecations
lithomas1 Nov 2, 2022
0397b46
try to fix docs
lithomas1 Nov 2, 2022
29184cb
Merge branch 'meson-poc' of github.com:lithomas1/pandas into meson-poc
lithomas1 Nov 2, 2022
cdf5605
update meson-python repo
lithomas1 Nov 2, 2022
4ce0be4
debug docs
lithomas1 Nov 2, 2022
1766cf9
Merge branch 'meson-poc' of github.com:lithomas1/pandas into meson-poc
lithomas1 Nov 2, 2022
7ca8ef9
typoed
lithomas1 Nov 2, 2022
3ae8954
debug more
lithomas1 Nov 2, 2022
d7ddd87
Try cd'ing into the doc directory
lithomas1 Nov 3, 2022
19157f0
adjust
lithomas1 Nov 3, 2022
6f97335
more verbosity
lithomas1 Nov 3, 2022
a3a4eb5
update and take another stab at fixing the docs
lithomas1 Nov 5, 2022
9277582
Merge branch 'meson-poc' of github.com:lithomas1/pandas into meson-poc
lithomas1 Nov 5, 2022
b7e6624
try not installing conda-forge c/cxx-compiler
lithomas1 Nov 6, 2022
dd65aaf
Merge branch 'pandas-dev:main' into meson-poc
lithomas1 Nov 6, 2022
6cbdfb8
try to get minimal doc build that doesn't segfault
lithomas1 Nov 8, 2022
dd0f03c
Merge branch 'meson-poc' of github.com:lithomas1/pandas into meson-poc
lithomas1 Nov 8, 2022
a4c3389
add back web deps
lithomas1 Nov 8, 2022
05d2f53
add matplotlib back
lithomas1 Nov 8, 2022
26435dd
bring back more packages
lithomas1 Nov 8, 2022
7a2bb0c
Debug more
lithomas1 Nov 8, 2022
a16e989
Silence warnings and debug more
lithomas1 Nov 8, 2022
71bcd58
try to catch the segfault
lithomas1 Nov 9, 2022
a948860
catchsegv and debug build
lithomas1 Nov 9, 2022
dec5317
use catchsegv properly
lithomas1 Nov 9, 2022
aa57379
try to fix strdup not found by lowering compiler strictness
lithomas1 Nov 9, 2022
ecb6f6e
Bring back everything but compilers
lithomas1 Nov 9, 2022
4d0a15b
Going for green
lithomas1 Nov 9, 2022
c4c3f9b
Try for green sans 32-bit
lithomas1 Nov 9, 2022
335ccf8
restore doc build and fix wrong python on macos
lithomas1 Nov 9, 2022
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
*.py[ocd]
*.so
.build_cache_dir
.mesonpy-native-file.ini
MANIFEST

# Python files #
Expand Down
40 changes: 40 additions & 0 deletions generate_pxi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import argparse
import os

from Cython import Tempita


def process_tempita(pxifile, outfile):
if (
os.path.exists(outfile)
and os.stat(pxifile).st_mtime < os.stat(outfile).st_mtime
):
# if .pxi.in is not updated, no need to output .pxi
return

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()
19 changes: 19 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This file is adapted from https://github.com/scipy/scipy/blob/main/meson.build
project(
'pandas',
'c', 'cpp', 'cython',
version: '1.5.0.dev0',
license: 'BSD-3',
meson_version: '>=0.60',
default_options: [
'buildtype=debugoptimized',
Copy link

Choose a reason for hiding this comment

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

Is this normal to do this with meson? With setuptools you build release by default and have to opt in to debug

Choose a reason for hiding this comment

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

meson's default buildtype is "debug" (especially useful for getting started on a wide variety of generic C/C++ projects), but e.g. the PEP 517 builder will then set a release buildtype. So this poc, when built with pip install, will still build release by default. But running meson setup && ninja will use this setting to build with debug.

People running meson setup instead of pip install are probably hacking on pandas anyway, so that might not be a bad distinction.

Choose a reason for hiding this comment

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

I'll note that numpy.distutils does build in debug mode by default (it has hardcoded -g flags), and it indeed seems like a sensible default for development.

Copy link

Choose a reason for hiding this comment

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

This makes sense in theory, but in practice to limit the scope of changes I would suggest we still now build release by default and come back to a later change to make a clear delineation between when we want a debug versus release build.

'c_std=c99'
]
)

py_mod = import('python')
py = py_mod.find_installation('python3')
py_dep = py.dependency()
tempita = files('generate_pxi.py')

subdir('pandas')
295 changes: 295 additions & 0 deletions pandas/_libs/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,295 @@
_algos_common_helper = custom_target('algos_common_helper_pxi',
output: 'algos_common_helper.pxi',
input: 'algos_common_helper.pxi.in',
command: [
py, tempita, '@INPUT@', '-o', '@OUTDIR@'
]
)
_algos_take_helper = custom_target('algos_take_helper_pxi',
output: 'algos_take_helper.pxi',
input: 'algos_take_helper.pxi.in',
command: [
py, tempita, '@INPUT@', '-o', '@OUTDIR@'
]
)
_khash_primitive_helper = custom_target('khash_primitive_helper_pxi',
output: 'khash_for_primitive_helper.pxi',
input: 'khash_for_primitive_helper.pxi.in',
command: [
py, tempita, '@INPUT@', '-o', '@OUTDIR@'
]
)
_hashtable_class_helper = custom_target('hashtable_class_helper_pxi',
output: 'hashtable_class_helper.pxi',
input: 'hashtable_class_helper.pxi.in',
command: [
py, tempita, '@INPUT@', '-o', '@OUTDIR@'
]
)
_hashtable_func_helper = custom_target('hashtable_func_helper_pxi',
output: 'hashtable_func_helper.pxi',
input: 'hashtable_func_helper.pxi.in',
command: [
py, tempita, '@INPUT@', '-o', '@OUTDIR@'
]
)
_index_class_helper = custom_target('index_class_helper_pxi',
output: 'index_class_helper.pxi',
input: 'index_class_helper.pxi.in',
command: [
py, tempita, '@INPUT@', '-o', '@OUTDIR@'
]
)
_sparse_op_helper = custom_target('sparse_op_helper_pxi',
output: 'sparse_op_helper.pxi',
input: 'sparse_op_helper.pxi.in',
command: [
py, tempita, '@INPUT@', '-o', '@OUTDIR@'
]
)
_intervaltree_helper = custom_target('intervaltree_helper_pxi',
output: 'intervaltree.pxi',
input: 'intervaltree.pxi.in',
command: [
py, tempita, '@INPUT@', '-o', '@OUTDIR@'
]
)
_algos_common_helper_dep = declare_dependency(sources: _algos_common_helper)
_algos_take_helper_dep = declare_dependency(sources: _algos_take_helper)
_khash_primitive_helper_dep = declare_dependency(sources: _khash_primitive_helper)
_hashtable_class_helper_dep = declare_dependency(sources: _hashtable_class_helper)
_hashtable_func_helper_dep = declare_dependency(sources: _hashtable_func_helper)
_index_class_helper_dep = declare_dependency(sources: _index_class_helper)
_sparse_op_helper_dep = declare_dependency(sources: _sparse_op_helper)
_intervaltree_helper_dep = declare_dependency(sources: _intervaltree_helper)
# TODO: can this be removed, I wish meson copied .pyx source to the build dir automatically
# The reason we can't build the pyx files inplace and copy to build dir is because
# the generated pxi files cannot be written to the source directory.
# (Meson only supports out of tree builds)
cython_sources_list = [
# List of cython sources e.g. .pyx, .pxd & __init__.py
# Does NOT include .pxi.in
'__init__.py',
'algos.pxd',
'algos.pyx',
'arrays.pxd',
'arrays.pyx',
'dtypes.pxd',
'groupby.pyx',
'hashing.pyx',
'hashtable.pxd',
'hashtable.pyx',
'index.pyx',
'indexing.pyx',
'internals.pyx',
'interval.pyx',
'join.pyx',
'khash.pxd',
'lib.pyx',
'lib.pxd',
'missing.pxd',
'missing.pyx',
'ops.pyx',
'ops_dispatch.pyx',
'parsers.pyx',
'properties.pyx',
'reduction.pyx',
'reshape.pyx',
'sparse.pyx',
'testing.pyx',
'tslib.pyx',
'util.pxd',
'writers.pyx'
]
cython_sources = {}

foreach source: cython_sources_list
source_pyx = configure_file(
input: source,
output: source,
copy: true
)
cython_sources += {source: source_pyx}
endforeach

#py.extension_module(
# 'parsing',
# ['tslibs/parsing.pyx'],
# include_directories: [inc_np, klib_include, 'src/parser', 'src', 'tslibs/src/datetime'],
# dependencies: [py_dep],
# subdir: 'pandas/_libs/tslibs',
# install: true
#)

subdir('tslibs')

py.extension_module(
'algos',
[_algos_common_helper, _algos_take_helper, _khash_primitive_helper, cython_sources['algos.pyx']],
include_directories: [inc_np, klib_include],
dependencies: [py_dep, _algos_common_helper_dep, _algos_take_helper_dep, _khash_primitive_helper_dep],
subdir: 'pandas/_libs',
install: true
)

py.extension_module(
'arrays',
cython_sources['arrays.pyx'],
include_directories: [inc_np],
dependencies: py_dep,

Choose a reason for hiding this comment

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

https://mesonbuild.com/Release-notes-for-0-63-0.html#python-extension-modules-now-depend-on-the-python-library-by-default

Based on an SciPy discussion with @rgommers, Meson 0.63.0 now implicitly adds that py_dep for you. This reduces boilerplate in build definitions, as long as you bump your minimum requirement to the latest Meson release. Of course, the SciPy example you based this on, predates this change, so SciPy has not adapted to this yet or raised the minimum build requirements.

As a brand-new Meson port, you'd be ideally placed to take advantage of this and in doing so avoid adding that boilerplate to any version of meson.build.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Thanks for the heads-up, will include it in my next clean-up commit.

subdir: 'pandas/_libs',
install: true
)

py.extension_module(
'groupby',
cython_sources['groupby.pyx'],
include_directories: [inc_np],
dependencies: py_dep,
subdir: 'pandas/_libs',
install: true
)

py.extension_module(
'hashing',
cython_sources['hashing.pyx'],
include_directories: [inc_np],
dependencies: py_dep,
subdir: 'pandas/_libs',
install: true
)

py.extension_module(
'hashtable',
[cython_sources['hashtable.pyx'], _khash_primitive_helper, _hashtable_class_helper, _hashtable_func_helper],
include_directories: [inc_np, klib_include],
dependencies: [py_dep, _khash_primitive_helper_dep, _hashtable_class_helper_dep, _hashtable_func_helper_dep],
subdir: 'pandas/_libs',
install: true
)

#py.extension_module(
# 'index',
# [cython_sources['index.pyx'], _index_class_helper],
# include_directories: [inc_np, klib_include],
# dependencies: [py_dep, _index_class_helper_dep],
# subdir: 'pandas/_libs',
# install: true
#)

py.extension_module(
'indexing',
['indexing.pyx'],
include_directories: [inc_np],
dependencies: py_dep,
subdir: 'pandas/_libs',
install: true
)

py.extension_module(
'internals',
['internals.pyx'],
include_directories: [inc_np],
dependencies: py_dep,
subdir: 'pandas/_libs',
install: true
)

#py.extension_module(
# 'interval',
# [cython_sources['interval.pyx'], _intervaltree_helper],
# include_directories: [inc_np, klib_include],
# dependencies: [py_dep, _intervaltree_helper_dep],
# subdir: 'pandas/_libs',
# install: true
#)

py.extension_module(
'join',
[cython_sources['join.pyx'], _khash_primitive_helper],
include_directories: [inc_np, klib_include],
dependencies: [py_dep, _khash_primitive_helper_dep],
subdir: 'pandas/_libs',
install: true
)

py.extension_module(
'lib',
['lib.pyx', 'src/parser/tokenizer.c'],
include_directories: [inc_np, klib_include, inc_datetime],
dependencies: [py_dep],
subdir: 'pandas/_libs',
install: true
)

#py.extension_module(
# 'parsers',
# [cython_sources['parsers.pyx'], _khash_primitive_helper, 'src/parser/tokenizer.c', 'src/parser/io.c'],
# include_directories: [inc_np, klib_include, 'src/parser', 'src'],
# dependencies: [py_dep, _khash_primitive_helper_dep],
# subdir: 'pandas/_libs',
# install: true
#)

py.extension_module(
'reduction',
['reduction.pyx'],
include_directories: [inc_np],
dependencies: [py_dep],
subdir: 'pandas/_libs',
install: true
)

py.extension_module(
'ops',
['ops.pyx'],
include_directories: [inc_np],
dependencies: [py_dep],
subdir: 'pandas/_libs',
install: true
)

py.extension_module(
'ops_dispatch',
['ops_dispatch.pyx'],
include_directories: [inc_np],
dependencies: [py_dep],
subdir: 'pandas/_libs',
install: true
)

py.extension_module(
'properties',
['properties.pyx'],
include_directories: [inc_np],
dependencies: [py_dep],
subdir: 'pandas/_libs',
install: true
)

py.extension_module(
'reshape',
['reshape.pyx'],
include_directories: [inc_np],
dependencies: [py_dep],
subdir: 'pandas/_libs',
install: true
)

py.extension_module(
'sparse',
[cython_sources['sparse.pyx'], _sparse_op_helper],
include_directories: [inc_np],
dependencies: [py_dep, _sparse_op_helper_dep],
subdir: 'pandas/_libs',
install: true
)

py.extension_module(
'tslib',
['tslib.pyx', 'tslibs/src/datetime/np_datetime.c'],
include_directories: [inc_np, inc_datetime],
dependencies: [py_dep],
subdir: 'pandas/_libs',
install: true
)
Loading