install pymedphys using the built wheels
@@ -21,6 +21,7 @@ GET_PIP_URL = "https://bootstrap.pypa.io/get-pip.py"
GET_PIP_PATH = DOWNLOADS.joinpath("get-pip.py")
BUILD = REPO_ROOT.joinpath("build")
+BUILD_PYTHON_EMBED = BUILD.joinpath("python-embed")
def read_pyproject():
@@ -43,28 +44,52 @@ def main():
else:
prepend = "wine "
- subprocess.check_call(
- f"{prepend} pip wheel -r requirements-deploy.txt -w wheels",
- shell=True,
- cwd=REPO_ROOT,
- )
- subprocess.check_call("poetry build -f wheel", shell=True, cwd=REPO_ROOT)
+ # subprocess.check_call(
+ # f"{prepend}pip wheel -r requirements-deploy.txt -w wheels",
+ # shell=True,
+ # cwd=REPO_ROOT,
+ # )
+ # subprocess.check_call("poetry build -f wheel", shell=True, cwd=REPO_ROOT)
+
+ # version_string = get_version_string().replace("-", ".")
+ # pymedphys_wheel = f"pymedphys-{version_string}-py3-none-any.whl"
+
+ # shutil.copy(DIST.joinpath(pymedphys_wheel), WHEELS.joinpath(pymedphys_wheel))
+
+ # DOWNLOADS.mkdir(exist_ok=True)
+ # if not PYTHON_EMBED_PATH.exists():
+ # urllib.request.urlretrieve(PYTHON_EMBED_URL, PYTHON_EMBED_PATH)
+
+ # if not GET_PIP_PATH.exists():
+ # urllib.request.urlretrieve(GET_PIP_URL, GET_PIP_PATH)
+
+ # BUILD_PYTHON_EMBED.mkdir(exist_ok=True, parents=True)
+ # with zipfile.ZipFile(PYTHON_EMBED_PATH, "r") as zip_ref:
+ # zip_ref.extractall(BUILD_PYTHON_EMBED)
- version_string = get_version_string().replace("-", ".")
- pymedphys_wheel = f"pymedphys-{version_string}-py3-none-any.whl"
+ path_file = list(BUILD_PYTHON_EMBED.glob("*._pth"))
+ if len(path_file) != 1:
+ raise ValueError("Only one _pth file should exist.")
- shutil.copy(DIST.joinpath(pymedphys_wheel), WHEELS.joinpath(pymedphys_wheel))
+ path_file = path_file[0]
- DOWNLOADS.mkdir(exist_ok=True)
- if not PYTHON_EMBED_PATH.exists():
- urllib.request.urlretrieve(PYTHON_EMBED_URL, PYTHON_EMBED_PATH)
+ with open(path_file) as f:
+ path_file_contents = f.read()
- if not GET_PIP_PATH.exists():
- urllib.request.urlretrieve(GET_PIP_URL, GET_PIP_PATH)
+ path_file_contents = path_file_contents.replace("#import site", "import site")
- BUILD.mkdir(exist_ok=True)
- with zipfile.ZipFile(PYTHON_EMBED_PATH, "r") as zip_ref:
- zip_ref.extractall(BUILD)
+ with open(path_file, "w") as f:
+ f.write(path_file_contents)
+
+ subprocess.check_call(
+ f"{prepend}python.exe {GET_PIP_PATH}", shell=True, cwd=BUILD_PYTHON_EMBED
+ )
+
+ subprocess.check_call(
+ f"{prepend}python.exe -m pip install pymedphys[user] --no-index --find-links file://{WHEELS}",
+ shell=True,
+ cwd=BUILD_PYTHON_EMBED,
+ )
if __name__ == "__main__":
