@@ -41,6 +41,7 @@ def _python_repository_impl(rctx):
41
41
42
42
platform = rctx .attr .platform
43
43
python_version = rctx .attr .python_version
44
+ python_short_version = python_version .rpartition ("." )[0 ]
44
45
release_filename = rctx .attr .release_filename
45
46
url = rctx .attr .url
46
47
@@ -88,7 +89,6 @@ def _python_repository_impl(rctx):
88
89
if "windows" in rctx .os .name :
89
90
distutils_path = "Lib/distutils/distutils.cfg"
90
91
else :
91
- python_short_version = python_version .rpartition ("." )[0 ]
92
92
distutils_path = "lib/python{}/distutils/distutils.cfg" .format (python_short_version )
93
93
if rctx .attr .distutils :
94
94
rctx .file (distutils_path , rctx .read (rctx .attr .distutils ))
@@ -130,6 +130,21 @@ filegroup(
130
130
),
131
131
)
132
132
133
+ filegroup(
134
+ name = "includes",
135
+ srcs = glob(["include/**/*.h"]),
136
+ )
137
+
138
+ cc_library(
139
+ name = "python_headers",
140
+ hdrs = [":includes"],
141
+ includes = [
142
+ "include",
143
+ "include/python{python_version}",
144
+ "include/python{python_version}m",
145
+ ],
146
+ )
147
+
133
148
exports_files(["{python_path}"])
134
149
135
150
py_runtime(
@@ -146,6 +161,7 @@ py_runtime_pair(
146
161
)
147
162
""" .format (
148
163
python_path = python_bin ,
164
+ python_version = python_short_version ,
149
165
)
150
166
rctx .file ("BUILD.bazel" , build_content )
151
167
0 commit comments