6
6
import setuptools
7
7
import setuptools .command .build_ext
8
8
import shutil
9
- import sys
10
- import sysconfig
11
9
12
10
long_description = r"""A drop-in replacement for the re module.
13
11
@@ -67,10 +65,7 @@ def build_extension(self, ext):
67
65
except KeyError :
68
66
pass
69
67
# Register the local Python toolchains with highest priority.
70
- self .generate_python_toolchains ()
71
68
cmd .append ('--extra_toolchains=//python/toolchains:all' )
72
- # Print debug information during toolchain resolution.
73
- cmd .append ('--toolchain_resolution_debug=.*' )
74
69
cmd += ['--compilation_mode=opt' , '--' , ':all' ]
75
70
self .spawn (cmd )
76
71
@@ -82,88 +77,6 @@ def build_extension(self, ext):
82
77
cmd = ['bazel' , 'clean' , '--expunge' ]
83
78
self .spawn (cmd )
84
79
85
- def generate_python_toolchains (self ):
86
- include = sysconfig .get_path ('include' )
87
- libs = os .path .join (include , '../libs' )
88
-
89
- os .makedirs ('toolchains' )
90
- shutil .copytree (include , 'toolchains/include' )
91
- try :
92
- shutil .copytree (libs , 'toolchains/libs' )
93
- except FileNotFoundError :
94
- # We must not be running on Windows. :)
95
- pass
96
-
97
- with open ('toolchains/BUILD.bazel' , 'x' ) as file :
98
- file .write (
99
- """\
100
- load("@rules_python//python/cc:py_cc_toolchain.bzl", "py_cc_toolchain")
101
- load("@rules_python//python:py_runtime.bzl", "py_runtime")
102
- load("@rules_python//python:py_runtime_pair.bzl", "py_runtime_pair")
103
-
104
- package(default_visibility = ["//visibility:public"])
105
-
106
- toolchain(
107
- name = "py",
108
- toolchain = ":py_toolchain",
109
- toolchain_type = "@rules_python//python:toolchain_type",
110
- )
111
-
112
- py_runtime_pair(
113
- name = "py_toolchain",
114
- py3_runtime = ":interpreter",
115
- )
116
-
117
- py_runtime(
118
- name = "interpreter",
119
- interpreter_path = "{interpreter_path}",
120
- interpreter_version_info = {{
121
- "major": "{major}",
122
- "minor": "{minor}",
123
- }},
124
- python_version = "PY3",
125
- )
126
-
127
- toolchain(
128
- name = "py_cc",
129
- toolchain = ":py_cc_toolchain",
130
- toolchain_type = "@rules_python//python/cc:toolchain_type",
131
- )
132
-
133
- py_cc_toolchain(
134
- name = "py_cc_toolchain",
135
- headers = ":headers",
136
- libs = ":libraries",
137
- python_version = "{major}.{minor}",
138
- )
139
-
140
- cc_library(
141
- name = "headers",
142
- hdrs = glob(["include/**/*.h"]),
143
- includes = ["include"],
144
- deps = select({{
145
- "@platforms//os:windows": [":interface_library"],
146
- "//conditions:default": [],
147
- }}),
148
- )
149
-
150
- cc_import(
151
- name = "interface_library",
152
- interface_library = select({{
153
- "@platforms//os:windows": "libs/python{major}{minor}.lib",
154
- "//conditions:default": None,
155
- }}),
156
- system_provided = True,
157
- )
158
-
159
- # Not actually necessary for our purposes. :)
160
- cc_library(
161
- name = "libraries",
162
- )
163
- """ .format (interpreter_path = sys .executable .replace ('\\ ' , '/' ),
164
- major = sys .version_info .major ,
165
- minor = sys .version_info .minor ))
166
-
167
80
168
81
def options ():
169
82
bdist_wheel = {}
0 commit comments