@@ -41,6 +41,7 @@ def _python_repository_impl(rctx):
4141
4242 platform = rctx .attr .platform
4343 python_version = rctx .attr .python_version
44+ python_short_version = python_version .rpartition ("." )[0 ]
4445 release_filename = rctx .attr .release_filename
4546 url = rctx .attr .url
4647
@@ -88,7 +89,6 @@ def _python_repository_impl(rctx):
8889 if "windows" in rctx .os .name :
8990 distutils_path = "Lib/distutils/distutils.cfg"
9091 else :
91- python_short_version = python_version .rpartition ("." )[0 ]
9292 distutils_path = "lib/python{}/distutils/distutils.cfg" .format (python_short_version )
9393 if rctx .attr .distutils :
9494 rctx .file (distutils_path , rctx .read (rctx .attr .distutils ))
@@ -130,6 +130,21 @@ filegroup(
130130 ),
131131)
132132
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+
133148exports_files(["{python_path}"])
134149
135150py_runtime(
@@ -146,6 +161,7 @@ py_runtime_pair(
146161)
147162""" .format (
148163 python_path = python_bin ,
164+ python_version = python_short_version ,
149165 )
150166 rctx .file ("BUILD.bazel" , build_content )
151167
0 commit comments