Skip to content

Commit 5219ca8

Browse files
committed
Automatically run pywin32_postinstall.py for local/from source installs (pip install .)
- Also respect the verbose flag instead of always running quiet - Added support for relative path for the `-destination` argument
1 parent 1311c41 commit 5219ca8

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

pywin32_postinstall.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,9 +642,12 @@ def uninstall(lib_dir):
642642
# Out of principle, we're still not using system exits.
643643

644644

645-
def verify_destination(location):
645+
def verify_destination(location: str) -> str:
646+
location = os.path.abspath(location)
646647
if not os.path.isdir(location):
647-
raise argparse.ArgumentTypeError(f'Path "{location}" does not exist!')
648+
raise argparse.ArgumentTypeError(
649+
f'Path "{location}" is not an existing directory!'
650+
)
648651
return location
649652

650653

setup.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -856,16 +856,6 @@ def run(self):
856856
This is only run for local installs. Wheel-based installs won't run this code.
857857
"""
858858
install.run(self)
859-
# If self.root has a value, it means we are being "installed" into some other
860-
# directory than Python itself - in which case we must *not* run our installer.
861-
# bdist_wininst used to trigger this by using a temp directory.
862-
# Is this still a concern ?
863-
if self.root:
864-
print(
865-
"Not executing post install script when "
866-
+ f"not installing in Python itself (self.root={self.root})"
867-
)
868-
return
869859
self.execute(self._postinstall, (), msg="Executing post install script...")
870860

871861
def _postinstall(self):
@@ -874,17 +864,17 @@ def _postinstall(self):
874864
raise RuntimeError(f"Can't find '{filename}'")
875865
# As of setuptools>=74.0.0, we no longer need to
876866
# be concerned about distutils calling win32api
877-
subprocess.Popen(
878-
[
867+
subprocess.check_call(
868+
(
879869
sys.executable,
880870
filename,
881871
"-install",
882872
"-destination",
883873
self.install_lib,
884-
"-quiet",
874+
*([] if self.verbose else ["-quiet"]),
885875
"-wait",
886876
str(os.getpid()),
887-
]
877+
)
888878
)
889879

890880

0 commit comments

Comments
 (0)