Skip to content

Commit b1e4fda

Browse files
committed
Try plumbing the platform name a different way.
Change-Id: Ic13a6ff61ec445c73483d55241ff42d90f9470b1 Reviewed-on: https://code-review.googlesource.com/c/re2/+/61870 Reviewed-by: Alex Chernyakhovsky <achernya@google.com> Reviewed-by: Paul Wankadia <junyer@google.com>
1 parent 33def66 commit b1e4fda

2 files changed

Lines changed: 17 additions & 11 deletions

File tree

.github/workflows/python.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ jobs:
7171
env:
7272
BAZELISK_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7373
BAZEL_CPU: darwin_${{ matrix.arch.bazel-name }}
74+
PLAT_NAME: macosx-${{ matrix.os }}.0-${{ matrix.arch.python-name }}
7475
# Stop macOS from reporting the system version as 10.x.
7576
# Otherwise, Python refuses to install the built wheel!
7677
SYSTEM_VERSION_COMPAT: 0
@@ -89,11 +90,7 @@ jobs:
8990
shell: bash
9091
- name: Build wheel
9192
run: |
92-
# TODO(junyer): Get rid of this hack whenever there's a better way
93-
# to plumb the platform name all the way down to the wheel builder.
94-
python -m build --wheel \
95-
--config-setting=--build-option=--plat-name \
96-
--config-setting=--build-option=macosx-${{ matrix.os }}.0-${{ matrix.arch.python-name }}
93+
python -m build --wheel
9794
python -m delocate.cmd.delocate_wheel --wheel-dir=. dist/*
9895
shell: bash
9996
working-directory: python
@@ -122,6 +119,7 @@ jobs:
122119
env:
123120
BAZELISK_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
124121
BAZEL_CPU: ${{ matrix.arch.bazel-name }}_windows
122+
PLAT_NAME: ${{ matrix.arch.python-name }}
125123
steps:
126124
- uses: actions/checkout@v3
127125
# Avoid the Chocolatey install of Bazel getting in the way;
@@ -147,11 +145,7 @@ jobs:
147145
shell: bash
148146
- name: Build wheel
149147
run: |
150-
# TODO(junyer): Get rid of this hack whenever there's a better way
151-
# to plumb the platform name all the way down to the wheel builder.
152-
python -m build --wheel \
153-
--config-setting=--build-option=--plat-name \
154-
--config-setting=--build-option=${{ matrix.arch.python-name }}
148+
python -m build --wheel
155149
python -m delvewheel repair --wheel-dir=. dist/*
156150
shell: bash
157151
working-directory: python

python/setup.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ def build_extension(self, ext):
5252
os.environ['PYTHON_BIN_PATH'] = sys.executable
5353

5454
cmd = ['bazel', 'build']
55-
if 'BAZEL_CPU' in os.environ:
55+
try:
5656
cmd.append(f'--cpu={os.environ["BAZEL_CPU"].lower()}')
57+
except KeyError:
58+
pass
5759
cmd += ['--compilation_mode=opt', '--', ':all']
5860
self.spawn(cmd)
5961

@@ -66,6 +68,15 @@ def build_extension(self, ext):
6668
self.spawn(cmd)
6769

6870

71+
def options():
72+
bdist_wheel = {}
73+
try:
74+
bdist_wheel['plat_name'] = os.environ['PLAT_NAME']
75+
except KeyError:
76+
pass
77+
return {'bdist_wheel': bdist_wheel}
78+
79+
6980
def include_dirs():
7081
try:
7182
import pybind11
@@ -100,6 +111,7 @@ def include_dirs():
100111
'Programming Language :: C++',
101112
'Programming Language :: Python :: 3.8',
102113
],
114+
options=options(),
103115
cmdclass={'build_ext': BuildExt},
104116
python_requires='~=3.8',
105117
)

0 commit comments

Comments
 (0)