Skip to content

Commit 4ab82d0

Browse files
authored
Re-land PyCapsule (pandas-dev#52021)
* Revert "Revert "Use PyCapsule for internal datetime functions" (pandas-dev#51951)" This reverts commit 8487b2e. * Revert "Revert "Re-enable parallel builds in CI" (pandas-dev#51952)" This reverts commit c8ea34c. * Revert "Revert "CI: parallel build follow up" (pandas-dev#51984)" This reverts commit 93b5135.
1 parent c73c1c8 commit 4ab82d0

38 files changed

+754
-233
lines changed

.circleci/setup_env.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ if pip list | grep -q ^pandas; then
5555
fi
5656

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

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

.github/actions/build_pandas/action.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,5 @@ runs:
1616
python -m pip install -e . --no-build-isolation --no-use-pep517 --no-index
1717
shell: bash -el {0}
1818
env:
19-
# Cannot use parallel compilation on Windows, see https://github.com/pandas-dev/pandas/issues/30873
20-
# 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
21-
N_JOBS: 1
22-
#N_JOBS: ${{ runner.os == 'Windows' && 1 || 2 }}
19+
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
20+
N_JOBS: ${{ runner.os == 'macOS' && 3 || 2 }}

.github/actions/setup-conda/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ runs:
3030
environment-name: ${{ inputs.environment-name }}
3131
extra-specs: ${{ inputs.extra-specs }}
3232
channels: conda-forge
33-
channel-priority: ${{ runner.os == 'macOS' && 'flexible' || 'strict' }}
33+
channel-priority: 'strict'
3434
condarc-file: ci/condarc.yml
3535
cache-env: true
3636
cache-downloads: true

.github/workflows/32-bit-linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
python -m pip install --no-deps -U pip wheel 'setuptools<60.0.0' && \
4141
python -m pip install versioneer[toml] && \
4242
python -m pip install cython numpy python-dateutil pytz pytest>=7.0.0 pytest-xdist>=2.2.0 pytest-asyncio>=0.17 hypothesis>=6.34.2 && \
43-
python setup.py build_ext -q -j1 && \
43+
python setup.py build_ext -q -j$(nproc) && \
4444
python -m pip install --no-build-isolation --no-use-pep517 -e . && \
4545
python -m pip list && \
4646
export PANDAS_CI=1 && \

.github/workflows/python-dev.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,9 @@ jobs:
8282
python -m pip install python-dateutil pytz cython hypothesis>=6.34.2 pytest>=7.0.0 pytest-xdist>=2.2.0 pytest-cov pytest-asyncio>=0.17
8383
python -m pip list
8484
85-
# GH 47305: Parallel build can cause flaky ImportError from pandas/_libs/tslibs
8685
- name: Build Pandas
8786
run: |
88-
python setup.py build_ext -q -j1
87+
python setup.py build_ext -q -j4
8988
python -m pip install -e . --no-build-isolation --no-use-pep517 --no-index
9089
9190
- name: Build Version

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,5 @@ prune pandas/tests/io/parser/data
5858
# Selectively re-add *.cxx files that were excluded above
5959
graft pandas/_libs/src
6060
graft pandas/_libs/tslibs/src
61+
include pandas/_libs/pd_parser.h
62+
include pandas/_libs/pd_parser.c

pandas/_libs/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
]
1111

1212

13+
# Below imports needs to happen first to ensure pandas top level
14+
# module gets monkeypatched with the pandas_datetime_CAPI
15+
# see pandas_datetime_exec in pd_datetime.c
16+
import pandas._libs.pandas_parser # noqa # isort: skip # type: ignore[reportUnusedImport]
17+
import pandas._libs.pandas_datetime # noqa # isort: skip # type: ignore[reportUnusedImport]
1318
from pandas._libs.interval import Interval
1419
from pandas._libs.tslibs import (
1520
NaT,

pandas/_libs/index.pyx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ from pandas._libs.tslibs.nattype cimport c_NaT as NaT
2020
from pandas._libs.tslibs.np_datetime cimport (
2121
NPY_DATETIMEUNIT,
2222
get_unit_from_dtype,
23+
import_pandas_datetime,
2324
)
25+
26+
import_pandas_datetime()
27+
28+
2429
from pandas._libs.tslibs.period cimport is_period_object
2530
from pandas._libs.tslibs.timedeltas cimport _Timedelta
2631
from pandas._libs.tslibs.timestamps cimport _Timestamp

pandas/_libs/lib.pyx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,11 @@ cdef extern from "numpy/arrayobject.h":
8888
cdef extern from "numpy/ndarrayobject.h":
8989
bint PyArray_CheckScalar(obj) nogil
9090

91-
92-
cdef extern from "src/parse_helper.h":
91+
cdef extern from "pd_parser.h":
9392
int floatify(object, float64_t *result, int *maybe_int) except -1
93+
void PandasParser_IMPORT()
94+
95+
PandasParser_IMPORT
9496

9597
from pandas._libs cimport util
9698
from pandas._libs.util cimport (

pandas/_libs/missing.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ from pandas._libs.tslibs.np_datetime cimport (
3434
get_datetime64_unit,
3535
get_datetime64_value,
3636
get_timedelta64_value,
37+
import_pandas_datetime,
3738
)
3839

40+
import_pandas_datetime()
41+
3942
from pandas._libs.ops_dispatch import maybe_dispatch_ufunc_to_dunder_op
4043

4144
cdef:

0 commit comments

Comments
 (0)