Skip to content

Commit cd50c7f

Browse files
committed
wheels: trim setup.py comments and move LICENSE copy near setup()
The post-install cleanup blocks were carrying redundant inline annotations that just listed what the dev_paths literal already names. Collapse the static-archives loop into the same dev_paths list (one audience filter, one pass) and shrink the comment to the actual "why". Also relocate the LICENSE materialization from the module top to immediately before setup(), so the side-effect-at-import sits next to the license_files= consumer that needs it. Cannot move into CMakeBuild.run() — egg_info reads license_files before build_ext fires.
1 parent 2f1dcef commit cd50c7f

1 file changed

Lines changed: 18 additions & 32 deletions

File tree

utils/mlir_aie_wheels/setup.py

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -305,47 +305,33 @@ def build_extension(self, ext: CMakeExtension) -> None:
305305
check=True,
306306
)
307307

308-
# Static archives (lib/*.a) only matter to anyone linking C++ code
309-
# against AIE/MLIR. PyPI consumers use the Python API, never these.
310-
for archive in (Path(install_dir) / "lib").glob("*.a"):
311-
archive.unlink()
312-
313-
# Same audience filter for the dev-only headers + cmake configs:
314-
# include/aie/ - MLIR C++ pass-author headers
315-
# include/aie-c/ - C API headers
316-
# include/bootgen_c_api.h - bootgen C API header
317-
# include/xaienginecdo_static/ - xaiengine headers, paired with
318-
# the static archives we just dropped
319-
# lib/cmake/ - find_package(AIE) configs for
320-
# downstream native builds
321-
# User-kernel-facing headers (aie_api/, aie_kernels/) stay — user
322-
# AIE kernels #include those at compile time.
308+
# C++-developer-only content: anyone pip installing this wheel
309+
# reaches the toolchain through Python, never through native
310+
# linking. aie_api/ and aie_kernels/ headers stay — user AIE
311+
# kernels #include those at compile time.
323312
dev_paths = [
324313
Path(install_dir) / "include" / "aie",
325314
Path(install_dir) / "include" / "aie-c",
326315
Path(install_dir) / "include" / "bootgen_c_api.h",
327316
Path(install_dir) / "include" / "xaienginecdo_static",
328317
Path(install_dir) / "lib" / "cmake",
318+
*(Path(install_dir) / "lib").glob("*.a"),
329319
]
330320
for p in dev_paths:
331321
if p.is_dir():
332322
shutil.rmtree(p)
333323
elif p.exists():
334324
p.unlink()
335325

336-
# CMake leaked build artifacts into the install prefix:
337-
# src/ - declare_mlir_python_sources staging,
338-
# full duplicate of python/
339-
# lib/objects-Release/ - intermediate .o files
340-
# **/__pycache__/ - bytecode caches generated by any python
341-
# run that happened during build
342-
# None of these belong in a shipped wheel.
343-
src_staging = Path(install_dir) / "src"
344-
if src_staging.exists():
345-
shutil.rmtree(src_staging)
346-
objects_dir = Path(install_dir) / "lib" / "objects-Release"
347-
if objects_dir.exists():
348-
shutil.rmtree(objects_dir)
326+
# CMake leaks staging directories, intermediate .o files, and
327+
# __pycache__ caches into the install prefix; none belong in a
328+
# shipped wheel.
329+
for leaked in [
330+
Path(install_dir) / "src",
331+
Path(install_dir) / "lib" / "objects-Release",
332+
]:
333+
if leaked.exists():
334+
shutil.rmtree(leaked)
349335
for pycache in Path(install_dir).rglob("__pycache__"):
350336
shutil.rmtree(pycache, ignore_errors=True)
351337

@@ -416,10 +402,6 @@ def run(self):
416402
)
417403
).absolute()
418404

419-
_license_src = MLIR_AIE_SOURCE_DIR / "LICENSE"
420-
if _license_src.exists():
421-
shutil.copy(_license_src, Path(__file__).parent / "LICENSE")
422-
423405

424406
def parse_requirements(filename):
425407
with open(filename) as f:
@@ -441,6 +423,10 @@ def parse_requirements(filename):
441423
return requirements
442424

443425

426+
_license = MLIR_AIE_SOURCE_DIR / "LICENSE"
427+
if _license.exists():
428+
shutil.copy(_license, Path(__file__).parent / "LICENSE")
429+
444430
setup(
445431
name="mlir-aie" if check_env("ENABLE_RTTI", 1) else "mlir-aie-no-rtti",
446432
version=get_version(),

0 commit comments

Comments
 (0)