Skip to content

Commit 42d4e9e

Browse files
committed
CI: Use ccache
1 parent 89578fe commit 42d4e9e

File tree

8 files changed

+87
-7
lines changed

8 files changed

+87
-7
lines changed

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

+10-1
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,23 @@ runs:
55
steps:
66

77
- name: Environment Detail
8+
id: env-detail
89
run: |
10+
echo ::group::{Environment Detail}
911
conda info
1012
conda list
13+
echo ::set-output name=python-version::$(conda 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
run: |
15-
python setup.py build_ext -j $N_JOBS
24+
DISTUTILS_C_COMPILER_LAUNCHER=sccache python setup.py build_ext -j $N_JOBS
1625
python -m pip install -e . --no-build-isolation --no-use-pep517 --no-index
1726
shell: bash -el {0}
1827
env:
+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
@@ -63,7 +63,7 @@ jobs:
6363

6464
- name: Build Pandas
6565
id: build
66-
uses: ./.github/actions/build_pandas
66+
uses: ./.github/actions/build-pandas
6767

6868
- name: Check for no warnings when building single-page docs
6969
run: ci/code_checks.sh single-docs
@@ -126,7 +126,7 @@ jobs:
126126

127127
- name: Build Pandas
128128
id: build
129-
uses: ./.github/actions/build_pandas
129+
uses: ./.github/actions/build-pandas
130130

131131
- name: Run ASV benchmarks
132132
run: |

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
uses: ./.github/actions/setup-conda
3939

4040
- name: Build Pandas
41-
uses: ./.github/actions/build_pandas
41+
uses: ./.github/actions/build-pandas
4242

4343
- name: Build website
4444
run: python web/pandas_web.py web/pandas --target-path=web/build

.github/workflows/macos-windows.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
pyarrow-version: ${{ matrix.os == 'macos-latest' && '6' || '' }}
5151

5252
- name: Build Pandas
53-
uses: ./.github/actions/build_pandas
53+
uses: ./.github/actions/build-pandas
5454

5555
- name: Test
5656
uses: ./.github/actions/run-tests

.github/workflows/posix.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ jobs:
154154
pyarrow-version: ${{ matrix.pyarrow_version }}
155155

156156
- name: Build Pandas
157-
uses: ./.github/actions/build_pandas
157+
uses: ./.github/actions/build-pandas
158158

159159
- name: Test
160160
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
@@ -74,7 +74,48 @@ def is_platform_mac():
7474
_pxi_dep[module] = pxi_files
7575

7676

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

0 commit comments

Comments
 (0)