Skip to content

Meson poc #19

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

Closed
wants to merge 80 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
6 changes: 1 addition & 5 deletions .circleci/setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@ if pip list | grep -q ^pandas; then
pip uninstall -y pandas || true
fi

echo "Build extensions"
# GH 47305: Parallel build can causes flaky ImportError from pandas/_libs/tslibs
python setup.py build_ext -q -j1

echo "Install pandas"
python -m pip install --no-build-isolation --no-use-pep517 -e .
python -m pip install --no-build-isolation -v .

echo "done"
17 changes: 10 additions & 7 deletions .github/actions/build_pandas/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ runs:
shell: bash -el {0}

- name: Build Pandas
if : ${{ runner.os != 'Windows' }}
run: |
python setup.py build_ext -j $N_JOBS
python -m pip install -e . --no-build-isolation --no-use-pep517 --no-index
pip install . --no-build-isolation -v
shell: bash -el {0}
env:
# Cannot use parallel compilation on Windows, see https://github.com/pandas-dev/pandas/issues/30873
# GH 47305: Parallel build causes flaky ImportError: /home/runner/work/pandas/pandas/pandas/_libs/tslibs/timestamps.cpython-38-x86_64-linux-gnu.so: undefined symbol: pandas_datetime_to_datetimestruct
N_JOBS: 1
#N_JOBS: ${{ runner.os == 'Windows' && 1 || 2 }}

- name: Build Pandas (Windows)
if: ${{ runner.os == 'Windows' }}
run: |
call micromamba activate test
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
python -m pip install . --no-build-isolation -v
shell: cmd /C call {0}
9 changes: 5 additions & 4 deletions .github/workflows/32-bit-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ jobs:
. ~/virtualenvs/pandas-dev/bin/activate && \
python -m pip install --no-deps -U pip wheel 'setuptools<60.0.0' && \
pip install cython numpy python-dateutil pytz pytest pytest-xdist pytest-asyncio>=0.17 hypothesis && \
python setup.py build_ext -q -j1 && \
python -m pip install --no-build-isolation --no-use-pep517 -e . && \
python -m pip list && \
pip install "git+https://github.com/mesonbuild/meson.git@master" && \
pip install "git+https://github.com/mesonbuild/meson-python.git@main" && \
export PANDAS_CI=1 && \
pytest -m 'not slow and not network and not clipboard and not single_cpu' pandas --junitxml=test-data.xml"
python -m pip install --no-build-isolation -v . && \
python -m pip list && \
pytest -m 'not slow and not network and not clipboard and not single_cpu' pandas --junitxml=test-data.xml --import-mode=importlib"

- name: Publish test results for Python 3.8-32 bit full Linux
uses: actions/upload-artifact@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docbuild-and-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ jobs:
run: python web/pandas_web.py web/pandas --target-path=web/build

- name: Build documentation
run: doc/make.py --warnings-are-errors
run: cd doc && python make.py --warnings-are-errors

- name: Build documentation zip
run: doc/make.py zip_html
run: cd doc && python make.py zip_html

- name: Build the interactive terminal
run: |
Expand Down
26 changes: 21 additions & 5 deletions .github/workflows/python-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,34 @@ jobs:
python -m pip install --upgrade pip setuptools wheel
python -m pip install -i https://pypi.anaconda.org/scipy-wheels-nightly/simple numpy
python -m pip install git+https://github.com/nedbat/coveragepy.git
python -m pip install python-dateutil pytz cython hypothesis==6.52.1 pytest>=6.2.5 pytest-xdist pytest-cov pytest-asyncio>=0.17
python -m pip install python-dateutil pytz cython
# TODO: update when upstream releases fixes
python -m pip install "git+https://github.com/mesonbuild/meson.git@master"
python -m pip install "git+https://github.com/FFY00/meson-python.git@main"
python -m pip install hypothesis==6.52.1 pytest>=6.2.5 pytest-xdist pytest-cov pytest-asyncio>=0.17
python -m pip list

# GH 47305: Parallel build can cause flaky ImportError from pandas/_libs/tslibs
# Sigh, someone (numpy?) is depending on mingw, which pandas doesn't compile with.
# Also, meson doesn't detect visual c++ unless cl.exe is in path.
# TODO: File a bug with meson about this.
- name: Build Pandas
if : ${{ runner.os != 'Windows' }}
run: |
python setup.py build_ext -q -j1
python -m pip install -e . --no-build-isolation --no-use-pep517 --no-index
python3 -m pip install . --no-build-isolation -v
shell: bash -el {0}

- name: Build Pandas (Windows)
if: ${{ runner.os == 'Windows' }}
run: |
call micromamba activate test
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
python -m pip install . --no-build-isolation -v
shell: cmd /C call {0}

- name: Build Version
run: |
python -c "import pandas; pandas.show_versions();"
# Can't import pandas from the source directory
cd .. && python -c "import pandas; pandas.show_versions();"

- name: Test
uses: ./.github/actions/run-tests
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
2 changes: 2 additions & 0 deletions ci/deps/actions-310-numpydev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ dependencies:
- pip
- pip:
- "cython"
- "git+https://github.com/mesonbuild/meson.git@master"
- "git+https://github.com/mesonbuild/meson-python.git@main"
- "--extra-index-url https://pypi.anaconda.org/scipy-wheels-nightly/simple"
- "--pre"
- "numpy"
Expand Down
3 changes: 3 additions & 0 deletions ci/deps/actions-310.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ dependencies:
- xlrd
- xlsxwriter
- zstandard
- pip:
- "git+https://github.com/mesonbuild/meson.git@master"
- "git+https://github.com/mesonbuild/meson-python.git@main"
3 changes: 3 additions & 0 deletions ci/deps/actions-38-downstream_compat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,6 @@ dependencies:
- pyyaml
- py
- pytorch
- pip:
- "git+https://github.com/mesonbuild/meson.git@master"
- "git+https://github.com/mesonbuild/meson-python.git@main"
3 changes: 3 additions & 0 deletions ci/deps/actions-38-minimum_versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ dependencies:
- xlrd=2.0.1
- xlsxwriter=1.4.3
- zstandard=0.15.2
- pip:
- "git+https://github.com/mesonbuild/meson.git@master"
- "git+https://github.com/mesonbuild/meson-python.git@main"
3 changes: 3 additions & 0 deletions ci/deps/actions-38.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,6 @@ dependencies:
- xlrd
- xlsxwriter
- zstandard
- pip:
- "git+https://github.com/mesonbuild/meson.git@master"
- "git+https://github.com/mesonbuild/meson-python.git@main"
3 changes: 3 additions & 0 deletions ci/deps/actions-39.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ dependencies:
- xlrd
- xlsxwriter
- zstandard
- pip:
- "git+https://github.com/mesonbuild/meson.git@master"
- "git+https://github.com/mesonbuild/meson-python.git@main"
3 changes: 3 additions & 0 deletions ci/deps/actions-pypy-38.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ dependencies:
- numpy
- python-dateutil
- pytz
- pip:
- "git+https://github.com/mesonbuild/meson.git@master"
- "git+https://github.com/mesonbuild/meson-python.git@main"
3 changes: 3 additions & 0 deletions ci/deps/circle-38-arm64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ dependencies:
- xlrd
- xlsxwriter
- zstandard
- pip:
- "git+https://github.com/mesonbuild/meson.git@master"
- "git+https://github.com/mesonbuild/meson-python.git@main"
7 changes: 4 additions & 3 deletions ci/run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash -e


# Workaround for pytest-xdist (it collects different tests in the workers if PYTHONHASHSEED is not set)
# https://github.com/pytest-dev/pytest/issues/920
# https://github.com/pytest-dev/pytest/issues/1075
Expand All @@ -13,7 +14,7 @@ if [[ "not network" == *"$PATTERN"* ]]; then
fi

if [[ "$COVERAGE" == "true" ]]; then
COVERAGE="-s --cov=pandas --cov-report=xml --cov-append"
COVERAGE="-s --cov=pandas --cov-report=xml --cov-append --cov-config=setup.cfg"
else
COVERAGE="" # We need to reset this for COVERAGE="false" case
fi
Expand All @@ -24,7 +25,7 @@ if [[ $(uname) == "Linux" && -z $DISPLAY ]]; then
XVFB="xvfb-run "
fi

PYTEST_CMD="${XVFB}pytest -r fEs -n $PYTEST_WORKERS --dist=loadfile $TEST_ARGS $COVERAGE $PYTEST_TARGET"
PYTEST_CMD="${XVFB}pytest -r fEs -n $PYTEST_WORKERS --dist=loadfile --import-mode=importlib $TEST_ARGS $COVERAGE $PYTEST_TARGET"

if [[ "$PATTERN" ]]; then
PYTEST_CMD="$PYTEST_CMD -m \"$PATTERN\""
Expand All @@ -33,7 +34,7 @@ fi
echo $PYTEST_CMD
sh -c "$PYTEST_CMD"

if [[ "$PANDAS_DATA_MANAGER" != "array" && "$PYTEST_TARGET" == "pandas" ]]; then
if [[ "$PANDAS_DATA_MANAGER" != "array" && "$PYTEST_TARGET" == "pandas/pandas" ]]; then
# The ArrayManager tests should have already been run by PYTEST_CMD if PANDAS_DATA_MANAGER was already set to array
# If we're targeting specific files, e.g. test_downstream.py, don't run.
PYTEST_AM_CMD="PANDAS_DATA_MANAGER=array pytest -n $PYTEST_WORKERS --dist=loadfile $TEST_ARGS $COVERAGE pandas"
Expand Down
4 changes: 2 additions & 2 deletions doc/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ def main():
# external libraries (namely Sphinx) to compile this module and resolve
# the import of `python_path` correctly. The latter is used to resolve
# the import within the module, injecting it into the global namespace
os.environ["PYTHONPATH"] = args.python_path
sys.path.insert(0, args.python_path)
# os.environ["PYTHONPATH"] = args.python_path
# sys.path.insert(0, args.python_path)
globals()["pandas"] = importlib.import_module("pandas")

# Set the matplotlib backend to the non-interactive Agg backend for all
Expand Down
2 changes: 2 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,5 @@ dependencies:
- pip:
- jupyterlite==0.1.0b12
- sphinx-toggleprompt
- "git+https://github.com/mesonbuild/meson.git@master"
- "git+https://github.com/mesonbuild/meson-python.git@main"
33 changes: 33 additions & 0 deletions 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 generate_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import argparse
import os

import versioneer


def write_version_info(path):
if os.environ.get("MESON_DIST_ROOT"):
# raise ValueError("dist root is", os.environ.get("MESON_DIST_ROOT"))
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()
49 changes: 49 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This file is adapted from https://github.com/scipy/scipy/blob/main/meson.build
project(
'pandas',
'c', 'cpp', 'cython',
version: '2.0.0.dev0',
license: 'BSD-3',
# TODO: bump when meson 0.64.0 comes out,
# we are relying on 0.64.0 features
meson_version: '>=0.63',
default_options: [
# TODO: investigate, does meson try to compile against debug Python
# when buildtype = debug, this seems to be causing problems on CI
# where provided Python is not compiled in debug mode
'buildtype=release',
# TODO: turn on werror when ready
#'werror=true',
# TODO: We are using POSIX functions(strdup in ujson), so we can't compile
# with strict C99 :(
#'c_std=c99'
]
)

add_global_arguments('-DNPY_NO_DEPRECATED_API=0', language : 'c')
add_global_arguments('-DNPY_NO_DEPRECATED_API=0', language : 'cpp')

py_mod = import('python')
fs = import('fs')
py = py_mod.find_installation('python')
py_dep = py.dependency()
tempita = files('generate_pxi.py')
versioneer = files('generate_version.py')

if fs.exists('_version_meson.py')
py.install_sources('_version_meson.py', subdir: 'pandas')
else
custom_target('write_version_file',
output: '_version_meson.py',
command: [
py, versioneer, '-o', '@OUTPUT@'
],
build_by_default: true,
build_always_stale: true,
install: true,
install_dir: py.get_install_dir(pure: false) / 'pandas'
)
meson.add_dist_script(py, versioneer, '-o', '_version_meson.py')
endif

subdir('pandas')
16 changes: 11 additions & 5 deletions pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,18 @@
from pandas.util._tester import test

# use the closest tagged version if possible
from pandas._version import get_versions
_built_with_meson = False
try:
from pandas._version_meson import __version__, __git_version__

_built_with_meson = True
except ImportError:
from pandas._version import get_versions

v = get_versions()
__version__ = v.get("closest-tag", v["version"])
__git_version__ = v.get("full-revisionid")
del get_versions, v
v = get_versions()
__version__ = v.get("closest-tag", v["version"])
__git_version__ = v.get("full-revisionid")
del get_versions, v

# GH 27101
__deprecated_num_index_names = ["Float64Index", "Int64Index", "UInt64Index"]
Expand Down
Loading