Skip to content

Commit 7f6cbee

Browse files
committed
upd
1 parent b18da8b commit 7f6cbee

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

build_backend.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def write_if_different(path: Path, content: str) -> None:
4848
path.write_text(content)
4949

5050

51-
def _create_data_dir():
51+
def _create_data_dir(use_symlinks=True):
5252
_data_dir.mkdir(parents=True, exist_ok=True)
5353

5454
def ln(source: str, target: str) -> None:
@@ -58,29 +58,47 @@ def ln(source: str, target: str) -> None:
5858
if dst.is_symlink():
5959
dst.unlink()
6060
elif dst.is_dir():
61-
dst.rmdir()
62-
dst.symlink_to(src, target_is_directory=True)
61+
shutil.rmtree(dst)
62+
else:
63+
dst.unlink()
64+
65+
if use_symlinks:
66+
dst.symlink_to(src, target_is_directory=True)
67+
else:
68+
# For wheel/sdist, copy actual files instead of symlinks
69+
if src.exists():
70+
shutil.copytree(src, dst, symlinks=False, dirs_exist_ok=True)
6371

6472
ln("3rdparty/cutlass", "cutlass")
6573
ln("3rdparty/spdlog", "spdlog")
6674
ln("csrc", "csrc")
6775
ln("include", "include")
6876

77+
# Always ensure version.txt is present
78+
version_file = _data_dir / "version.txt"
79+
if not version_file.exists() or not use_symlinks:
80+
shutil.copy(_root / "version.txt", version_file)
81+
6982

7083
def _prepare_for_wheel():
71-
# Remove data directory
84+
# For wheel, copy actual files instead of symlinks so they are included in the wheel
7285
if _data_dir.exists():
7386
shutil.rmtree(_data_dir)
87+
_create_data_dir(use_symlinks=False)
7488

7589

7690
def _prepare_for_editable():
77-
_create_data_dir()
91+
# For editable install, use symlinks so changes are reflected immediately
92+
if _data_dir.exists():
93+
shutil.rmtree(_data_dir)
94+
_create_data_dir(use_symlinks=True)
7895

7996

8097
def _prepare_for_sdist():
81-
# Remove data directory
98+
# For sdist, copy actual files instead of symlinks so they are included in the tarball
8299
if _data_dir.exists():
83100
shutil.rmtree(_data_dir)
101+
_create_data_dir(use_symlinks=False)
84102

85103

86104
def get_requires_for_build_wheel(config_settings=None):

0 commit comments

Comments
 (0)