Skip to content

Commit 07a3459

Browse files
committed
Adding further configuration to the py_wheel generation
Signed-off-by: Ethan Mahintorabi <[email protected]>
1 parent 15baeb1 commit 07a3459

File tree

6 files changed

+34
-22
lines changed

6 files changed

+34
-22
lines changed

BUILD.bazel

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
55
load("//bazel:tcl_encode_or.bzl", "tcl_encode")
66
load("//bazel:tcl_wrap_cc.bzl", "tcl_wrap_cc")
7-
load("//bazel:python_wrap_cc.bzl", "python_wrap_cc")
7+
load("//bazel:python_wrap_cc.bzl", "python_wrap_cc", "PYTHON_STABLE_API_DEFINE")
88

99
package(
1010
features = [
@@ -70,9 +70,7 @@ OPENROAD_LIBRARY_DEPS = [
7070
"//src/exa",
7171
"//src/exa:ui",
7272
"//src/fin",
73-
# "//src/fin:ui",
7473
"//src/gpl",
75-
# "//src/gpl:ui",
7674
"//src/grt",
7775
"//src/grt:ui",
7876
"//src/ifp",
@@ -82,15 +80,11 @@ OPENROAD_LIBRARY_DEPS = [
8280
"//src/odb",
8381
"//src/odb:ui",
8482
"//src/pad",
85-
# "//src/pad:ui",
8683
"//src/par",
8784
"//src/par:ui",
8885
"//src/pdn",
89-
# "//src/pdn:ui",
9086
"//src/ppl",
91-
# "//src/ppl:ui",
9287
"//src/psm",
93-
# "//src/psm:ui",
9488
"//src/rcx",
9589
"//src/rcx:ui",
9690
"//src/rmp",
@@ -269,6 +263,7 @@ tcl_wrap_cc(
269263
],
270264
)
271265

266+
272267
# This target compiles the SWIG C++ wrapper into a shared library (.so)
273268
# that Python can load dynamically.
274269
cc_binary(
@@ -300,6 +295,7 @@ cc_binary(
300295
"@boost.stacktrace",
301296
"@openroad_rules_python//python/cc:current_py_cc_headers",
302297
],
298+
defines = [PYTHON_STABLE_API_DEFINE],
303299
)
304300

305301
# This packages the SWIG-generated Python wrapper (odb.py) and the

bazel/python_wrap_cc.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ PythonSwigInfo = provider(
1717
],
1818
)
1919

20+
PYTHON_STABLE_API_DEFINE = "Py_LIMITED_API=0x030A0000"
21+
2022
def _get_transitive_srcs(srcs, deps):
2123
return depset(
2224
srcs,

openroad/BUILD

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,14 @@ py_package(
2727

2828
py_wheel(
2929
name = "openroad_wheel",
30+
abi = "abi3",
3031
distribution = "openroad",
3132
homepage = "https://github.com/The-OpenROAD-Project/OpenROAD",
32-
python_tag = "py3",
33+
python_requires = ">=3.10",
34+
python_tag = "cp310",
3335
version = "0.0.1",
3436
deps = [
3537
":openroad_pkg",
3638
],
39+
platform = "linux_x86_64"
3740
)

src/ifp/src/InitFloorplan-py.i

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@
1313
%import "dbtypes.i"
1414

1515
%typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) ifp::RowParity {
16-
const char *str = PyUnicode_AsUTF8($input);
16+
Py_ssize_t size;
17+
// Part of stable abi3 for >=3.10
18+
const char *str = PyUnicode_AsUTF8AndSize($input, &size);
1719
$1 = strcasecmp(str, "NONE") != 0 || strcasecmp(str, "EVEN") != 0 || strcasecmp(str, "ODD") != 0;
1820
}
1921

20-
%typemap(in) ifp::RowParity {
21-
const char *str = PyUnicode_AsUTF8($input);
22+
%typemap(in) ifp::RowParity
23+
{
24+
Py_ssize_t size;
25+
// Part of stable abi3 for >=3.10
26+
const char *str = PyUnicode_AsUTF8AndSize($input, &size);
27+
2228
if (strcasecmp(str, "NONE") == 0) {
2329
$1 = ifp::RowParity::NONE;
2430
} else if (strcasecmp(str, "EVEN") == 0) {
@@ -30,9 +36,9 @@
3036
}
3137
}
3238

33-
// These are needed to coax swig into sending or returning Python
34-
// lists, arrays, or sets (as appropriate) of opaque pointers. Note
35-
// that you must %include (not %import) <std_vector.i> and <std_array.i>
39+
// These are needed to coax swig into sending or returning Python
40+
// lists, arrays, or sets (as appropriate) of opaque pointers. Note
41+
// that you must %include (not %import) <std_vector.i> and <std_array.i>
3642
// before these definitions
3743
namespace std {
3844
%template(site_list) std::vector<odb::dbSite*>;

src/odb/BUILD

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22
# Copyright (c) 2025-2025, Precision Innovations Inc.
33

4-
load("//bazel:python_wrap_cc.bzl", "python_wrap_cc")
4+
load("//bazel:python_wrap_cc.bzl", "PYTHON_STABLE_API_DEFINE", "python_wrap_cc")
55
load("//bazel:tcl_encode_or.bzl", "tcl_encode")
66
load("//bazel:tcl_wrap_cc.bzl", "tcl_wrap_cc")
77

@@ -85,6 +85,7 @@ cc_library(
8585
cc_binary(
8686
name = "_odb.so",
8787
srcs = [":swig-py"],
88+
defines = [PYTHON_STABLE_API_DEFINE],
8889
includes = ["src/swig/common"],
8990
linkshared = True,
9091
deps = [
@@ -102,7 +103,7 @@ py_library(
102103
data = [":_odb.so"],
103104
# This allows imports relative to the workspace root.
104105
imports = ["."],
105-
visibility = ["//visibility:public",]
106+
visibility = ["//visibility:public"],
106107
)
107108

108109
cc_library(

src/utl/BUILD

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22
# Copyright (c) 2025, The OpenROAD Authors
33

4+
load("//bazel:python_wrap_cc.bzl", "PYTHON_STABLE_API_DEFINE", "python_wrap_cc")
45
load("//bazel:tcl_encode_or.bzl", "tcl_encode")
56
load("//bazel:tcl_wrap_cc.bzl", "tcl_wrap_cc")
6-
load("//bazel:python_wrap_cc.bzl", "python_wrap_cc")
77

88
package(
99
default_visibility = ["//:__subpackages__"],
@@ -71,7 +71,10 @@ cc_library(
7171
"include/utl/validation.h",
7272
"src/LoggerCommon.h",
7373
],
74-
includes = ["include", "src"],
74+
includes = [
75+
"include",
76+
"src",
77+
],
7578
deps = [
7679
"//src/sta:opensta_lib",
7780
"@boost.algorithm",
@@ -91,9 +94,10 @@ cc_library(
9194
cc_binary(
9295
name = "_utl.so",
9396
srcs = [
94-
":swig-py",
9597
"src/LoggerCommon.h",
98+
":swig-py",
9699
],
100+
defines = [PYTHON_STABLE_API_DEFINE],
97101
includes = ["src"],
98102
linkshared = True,
99103
deps = [
@@ -112,7 +116,7 @@ py_library(
112116
data = [":_utl.so"],
113117
# This allows imports relative to the workspace root.
114118
imports = ["."],
115-
visibility = ["//visibility:public",]
119+
visibility = ["//visibility:public"],
116120
)
117121

118122
cc_library(
@@ -141,9 +145,9 @@ cc_library(
141145
"@boost.iterator",
142146
"@boost.random",
143147
"@boost.stacktrace",
148+
"@openroad_rules_python//python/cc:current_py_cc_headers",
144149
"@spdlog",
145150
"@tk_tcl//:tcl",
146-
"@openroad_rules_python//python/cc:current_py_cc_headers",
147151
],
148152
)
149153

@@ -188,4 +192,4 @@ python_wrap_cc(
188192
"src",
189193
],
190194
visibility = ["//visibility:public"],
191-
)
195+
)

0 commit comments

Comments
 (0)