Skip to content

Commit 09ecbee

Browse files
committed
CI: Use ccache
1 parent 1bdedc6 commit 09ecbee

File tree

8 files changed

+86
-6
lines changed

8 files changed

+86
-6
lines changed

.github/actions/build_pandas/action.yml renamed to .github/actions/build-pandas/action.yml

+9
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,20 @@ runs:
55
steps:
66

77
- name: Environment Detail
8+
id: env-detail
89
run: |
10+
echo ::group::{Environment Detail}
911
micromamba info
1012
micromamba list
13+
echo ::set-output name=python-version::$(micromamba list -f python --json | jq -r '.[0].version')
14+
echo ::endgroup::
1115
shell: bash -el {0}
1216

17+
- name: Set up Ccache
18+
uses: ./.github/actions/setup-ccache
19+
with:
20+
extra-cache-key: ${{ steps.env-detail.outputs.python-version }}
21+
1322
- name: Build Pandas
1423
if : ${{ runner.os != 'Windows' }}
1524
run: |
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Setup sccache
2+
inputs:
3+
extra-cache-key:
4+
required: false
5+
default: ''
6+
runs:
7+
using: composite
8+
steps:
9+
- name: Get Date
10+
id: get-date
11+
run: echo "::set-output name=today::$(/bin/date -u '+%Y%m%d')"
12+
shell: bash
13+
14+
- name: Fix Windows temporary directory
15+
# On Windows, for some reason the default temporary directory provided to sccache
16+
# may become read-only at some point. Work around by having a private tempdir.
17+
id: mktemp
18+
run: echo "::set-output name=tmpdir::$(cygpath -w $(mktemp -d))"
19+
shell: bash
20+
if: ${{ runner.os == 'Windows' }}
21+
22+
- name: Setup sccache
23+
uses: hendrikmuhs/[email protected]
24+
with:
25+
variant: sccache
26+
key: ${{ runner.os }}--${{ runner.arch }}--${{ github.workflow }}--${{ steps.get-date.outputs.today }}--${{ inputs.extra-cache-key }}
27+
env:
28+
TMP: "${{ steps.mktemp.outputs.tmpdir }}"

.github/workflows/code-checks.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262

6363
- name: Build Pandas
6464
id: build
65-
uses: ./.github/actions/build_pandas
65+
uses: ./.github/actions/build-pandas
6666

6767
# The following checks are independent of each other and should still be run if one fails
6868
- name: Check for no warnings when building single-page docs
@@ -125,7 +125,7 @@ jobs:
125125

126126
- name: Build Pandas
127127
id: build
128-
uses: ./.github/actions/build_pandas
128+
uses: ./.github/actions/build-pandas
129129

130130
- name: Run ASV benchmarks
131131
run: |

.github/workflows/docbuild-and-upload.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
uses: ./.github/actions/setup-conda
4545

4646
- name: Build Pandas
47-
uses: ./.github/actions/build_pandas
47+
uses: ./.github/actions/build-pandas
4848

4949
- name: Set up maintainers cache
5050
uses: actions/cache@v3

.github/workflows/macos-windows.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
pyarrow-version: ${{ matrix.os == 'macos-latest' && '9' || '' }}
5757

5858
- name: Build Pandas
59-
uses: ./.github/actions/build_pandas
59+
uses: ./.github/actions/build-pandas
6060

6161
- name: Test
6262
uses: ./.github/actions/run-tests

.github/workflows/ubuntu.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ jobs:
173173
pyarrow-version: ${{ matrix.pyarrow_version }}
174174

175175
- name: Build Pandas
176-
uses: ./.github/actions/build_pandas
176+
uses: ./.github/actions/build-pandas
177177

178178
- name: Test
179179
uses: ./.github/actions/run-tests

ci/run_tests.sh

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/bin/bash -e
2+
python -c 'import pandas; pandas.show_versions()'
3+
exit 0
24

35
# Workaround for pytest-xdist (it collects different tests in the workers if PYTHONHASHSEED is not set)
46
# https://github.com/pytest-dev/pytest/issues/920

setup.py

+42-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,48 @@ def is_platform_mac():
7373
_pxi_dep[module] = pxi_files
7474

7575

76-
class build_ext(_build_ext):
76+
class CompilerLauncherMixin:
77+
"""Add "compiler launchers" to distutils.
78+
79+
We use this to be able to run the Pandas build using "ccache".
80+
81+
A compiler launcher is a program that is invoked instead of invoking the
82+
compiler directly. It is passed the full compiler invocation command line.
83+
84+
A similar feature exists in CMake, see
85+
https://cmake.org/cmake/help/latest/prop_tgt/LANG_COMPILER_LAUNCHER.html.
86+
"""
87+
88+
__is_set_up = False
89+
90+
def build_extensions(self):
91+
# Integrate into "build_ext"
92+
self.__setup()
93+
super().build_extensions()
94+
95+
def build_libraries(self):
96+
# Integrate into "build_clib"
97+
self.__setup()
98+
super().build_extensions()
99+
100+
def __setup(self):
101+
if self.__is_set_up:
102+
return
103+
self.__is_set_up = True
104+
compiler_launcher = os.getenv("DISTUTILS_C_COMPILER_LAUNCHER")
105+
if compiler_launcher:
106+
107+
def spawn_with_compiler_launcher(cmd):
108+
exclude_programs = ("link.exe",)
109+
if not cmd[0].endswith(exclude_programs):
110+
cmd = [compiler_launcher] + cmd
111+
return original_spawn(cmd)
112+
113+
original_spawn = self.compiler.spawn
114+
self.compiler.spawn = spawn_with_compiler_launcher
115+
116+
117+
class build_ext(CompilerLauncherMixin, _build_ext):
77118
@classmethod
78119
def render_templates(cls, pxifiles):
79120
for pxifile in pxifiles:

0 commit comments

Comments
 (0)