After some discussion on the Python discussion forum (and some help from a LLM) it was determined that overriding the build_py
command instead of the install
command would provide the desired result. The amended setup.py
:
import subprocess
from setuptools import setup
from setuptools.command.build_py import build_py
class CustomBuild_Py(build_py):
def run(self):
with open("install.log", "w") as f:
subprocess.run(["./compile.sh"], stdout=f)
build_py.run(self)
setup(
name="mypkg",
packages=[“mypkg”],
cmdclass={"build_py": CustomBuild_Py},
include_package_data=True,
zip_safe=False,
)