Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: Use cc_import to import python lib properly #17474

Merged
merged 1 commit into from
Mar 6, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 14 additions & 8 deletions third_party/py/BUILD.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@ licenses(["restricted"])

package(default_visibility = ["//visibility:public"])

# To build Python C/C++ extension on Windows, we need to link to python import library pythonXY.lib
# See https://docs.python.org/3/extending/windows.html
cc_import(
name = "python_lib",
interface_library = select({
":windows": ":python_import_lib",
# A placeholder for Unix platforms which makes --no_build happy.
"//conditions:default": "not-existing.lib",
}),
system_provided = 1,
)

cc_library(
name = "python_headers",
hdrs = [":python_include"],
data = select({
":windows": [":python_import_lib"],
deps = select({
":windows": [":python_lib"],
"//conditions:default": [],
}),
includes = ["python_include"],
linkopts = select({
# TODO(pcloudy): Ideally, this should just go into deps after resolving
# https://github.com/bazelbuild/bazel/issues/3237,
":windows": ["$(locations :python_import_lib)"],
"//conditions:default": [],
}),
)

cc_library(
Expand Down