Skip to content

Commit 4e093c7

Browse files
committed
Add comment on windows support + switch to shutil
1 parent 41acf8a commit 4e093c7

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ from python_mscl import mscl
2525

2626
### Windows support:
2727

28-
The latest mscl version (v67.0.0) only has a .zip for python 3.11. It is not confirmed if this will work with other python versions.
28+
The latest mscl version (v67.0.0) only has a .zip for python 3.11. It has been confirmed that it does not work on other python versions (You would get an import error). However the build itself would still go through.
2929

3030

3131
### Versioning system:

hatch_build.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Specifies a hatch build hook to create the wheel for mscl."""
22

33
import platform
4-
import subprocess
4+
import shutil
55
import sys
66
from pathlib import Path
77

@@ -92,13 +92,25 @@ def initialize(self, version, build_data):
9292
)
9393

9494
self.app.display_success("Downloaded files successfully.")
95-
build_data["artifacts"] = ["_mscl.so", "mscl.py"]
9695

9796
# --- STEP 3: Copy the files ("_mscl.so" & "mscl.py") to the src/mscl/ directory: ---
9897
# Move from root (i.e. cwd) to src/mscl
99-
subprocess.run(["mv", "mscl.py", "src/python_mscl/"], check=True)
98+
# Use shutil.move() to move the files.
99+
100+
self.remove_existing_files(Path("src/python_mscl/"), ["_mscl.so", "_mscl.pyd", "mscl.py"])
101+
shutil.move("mscl.py", "src/python_mscl/")
100102
if platform.system() == "Windows":
101-
subprocess.run(["mv", "_mscl.pyd", "src/python_mscl/"], check=True)
103+
shutil.move("_mscl.pyd", "src/python_mscl/")
104+
build_data["artifacts"] = ["_mscl.pyd", "mscl.py"]
102105
else:
103-
subprocess.run(["mv", "_mscl.so", "src/python_mscl/"], check=True)
106+
shutil.move("_mscl.so", "src/python_mscl/")
107+
build_data["artifacts"] = ["_mscl.so", "mscl.py"]
108+
104109
self.app.display_success("Moved files to src/python_mscl/ successfully. Building wheel...")
110+
111+
def remove_existing_files(self, directory: Path, files: list[str]) -> None:
112+
"""Remove the existing files from the directory."""
113+
for file in files:
114+
file_path = directory / file
115+
if file_path.exists():
116+
file_path.unlink()

0 commit comments

Comments
 (0)