Skip to content

Commit 50b271e

Browse files
Remove legacy shared_ptr and include_boost API parameters
Now that autowrap uses std::shared_ptr exclusively: - Remove shared_ptr parameter from CodeGenerator.__init__ and generate_code() - Remove include_boost parameter from generate_code(), parse_and_generate_code(), and Main.create_wrapper_code() - Simplify fixed_include_dirs() and get_include_dirs() to take no arguments - Remove include_shared_ptr attribute from CodeGenerator 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 790401f commit 50b271e

File tree

5 files changed

+7
-22
lines changed

5 files changed

+7
-22
lines changed

autowrap/CodeGenerator.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,13 @@ def augment_arg_names(method):
9393
]
9494

9595

96-
def fixed_include_dirs(include_boost: bool) -> List[AnyStr]:
96+
def fixed_include_dirs() -> List[AnyStr]:
9797
from importlib.resources import files
9898

9999
autowrap_files = files("autowrap")
100100
data = str(autowrap_files.joinpath("data_files"))
101101
autowrap_internal = str(autowrap_files.joinpath("data_files/autowrap"))
102102

103-
# The include_boost flag is kept for backwards-compatibility but is ignored.
104-
# We always use only the autowrap data directories and do not ship Boost anymore.
105103
return [data, autowrap_internal]
106104

107105

@@ -119,7 +117,6 @@ class CodeGenerator(object):
119117
pxd_dir: Optional[AnyStr]
120118
manual_code: Dict[str, Code]
121119
extra_cimports: Collection[str]
122-
include_shared_ptr: str
123120
include_refholder: bool
124121
include_numpy: bool
125122
add_relative: bool
@@ -162,7 +159,6 @@ def __init__(
162159
extra_cimports=None,
163160
all_decl=None,
164161
add_relative=False,
165-
shared_ptr="std",
166162
):
167163
self.pxd_dir = None
168164
if all_decl is None:
@@ -172,10 +168,6 @@ def __init__(
172168

173169
self.manual_code: Dict[str, Code] = manual_code
174170
self.extra_cimports: Collection[str] = extra_cimports
175-
# Use C++ standard shared_ptr by default. Boost shared_ptr is no longer supported.
176-
if shared_ptr not in ("std", None):
177-
raise ValueError("Only std::shared_ptr is supported; use shared_ptr='std' or omit it.")
178-
self.include_shared_ptr: str = "std"
179171
self.include_refholder: bool = True
180172
self.include_numpy: bool = False
181173
self.add_relative: bool = add_relative
@@ -252,11 +244,11 @@ def __init__(
252244
self.wrapped_classes_cnt: int = 0
253245
self.wrapped_methods_cnt: int = 0
254246

255-
def get_include_dirs(self, include_boost: bool) -> List[AnyStr]:
247+
def get_include_dirs(self) -> List[AnyStr]:
256248
if self.pxd_dir is not None:
257-
return fixed_include_dirs(include_boost) + [self.pxd_dir]
249+
return fixed_include_dirs() + [self.pxd_dir]
258250
else:
259-
return fixed_include_dirs(include_boost)
251+
return fixed_include_dirs()
260252

261253
def setup_cimport_paths(self) -> None:
262254
"""

autowrap/Main.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ def create_wrapper_code(
199199
out,
200200
extra_inc_dirs,
201201
extra_opts,
202-
include_boost=True,
203202
allDecl=[],
204203
):
205204
cimports, manual_code = collect_manual_code(addons)
@@ -211,7 +210,6 @@ def create_wrapper_code(
211210
debug=False,
212211
manual_code=manual_code,
213212
extra_cimports=cimports,
214-
include_boost=include_boost,
215213
all_decl=allDecl,
216214
)
217215

autowrap/__init__.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,9 @@ def generate_code(
7676
debug=False,
7777
manual_code=None,
7878
extra_cimports=None,
79-
include_boost=True,
8079
include_numpy=False,
8180
all_decl=[],
8281
add_relative=False,
83-
shared_ptr="std",
8482
):
8583
import autowrap.CodeGenerator
8684

@@ -92,11 +90,10 @@ def generate_code(
9290
extra_cimports=extra_cimports,
9391
all_decl=all_decl,
9492
add_relative=add_relative,
95-
shared_ptr=shared_ptr,
9693
)
9794
gen.include_numpy = include_numpy
9895
gen.create_pyx_file(debug)
99-
includes = gen.get_include_dirs(include_boost)
96+
includes = gen.get_include_dirs()
10097
print(
10198
"Autowrap has wrapped %s classes, %s methods and %s enums"
10299
% (gen.wrapped_classes_cnt, gen.wrapped_methods_cnt, gen.wrapped_enums_cnt)
@@ -111,11 +108,10 @@ def parse_and_generate_code(
111108
debug,
112109
manual_code=None,
113110
extra_cimports=None,
114-
include_boost=True,
115111
):
116112
print("Autowrap will start to parse and generate code. " "Will parse %s files" % len(files))
117113
decls, instance_map = parse(files, root)
118114
print("Done parsing the files, will generate the code...")
119115
return generate_code(
120-
decls, instance_map, target, debug, manual_code, extra_cimports, include_boost
116+
decls, instance_map, target, debug, manual_code, extra_cimports
121117
)

tests/test_code_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def test_number_conv():
107107

108108
def test_shared_ptr():
109109
target = os.path.join(test_files, "shared_ptr_test.pyx")
110-
include_dirs = autowrap.CodeGenerator.fixed_include_dirs(True) + [test_files]
110+
include_dirs = autowrap.CodeGenerator.fixed_include_dirs() + [test_files]
111111
m = autowrap.Utils.compile_and_import(
112112
"m",
113113
[

tests/test_full_library.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ def test_full_lib(tmpdir):
222222
debug=False,
223223
manual_code=manual_code,
224224
extra_cimports=cimports,
225-
include_boost=True,
226225
all_decl=masterDict,
227226
add_relative=True,
228227
)

0 commit comments

Comments
 (0)