2222class PostgreSQLBinaries :
2323 """Manages PostgreSQL binary installation and versioning."""
2424
25+ PLATFORM = platform .machine ().lower ()
26+ SYSTEM = platform .system ().lower ()
27+
2528 # PostgreSQL versions supported (from pg-embed)
2629 SUPPORTED_VERSIONS = {
2730 "17" : "17.2.0" ,
@@ -50,7 +53,7 @@ def __init__(self, cache_dir: Optional[Path] = None):
5053
5154 def _detect_os (self ) -> str :
5255 """Detect the operating system."""
53- system = platform . system (). lower ()
56+ system = self . SYSTEM
5457 if system == "darwin" :
5558 return "darwin"
5659 elif system == "windows" :
@@ -63,7 +66,7 @@ def _detect_os(self) -> str:
6366
6467 def _detect_arch (self ) -> str :
6568 """Detect the CPU architecture."""
66- machine = platform . machine (). lower ()
69+ machine = self . PLATFORM
6770 if machine in ["x86_64" , "amd64" ]:
6871 return "amd64"
6972 elif machine in ["i386" , "i686" ]:
@@ -81,6 +84,17 @@ def _get_platform_string(self) -> str:
8184 """Get the platform string for binary downloads."""
8285 return f"{ self .os_name } -{ self .arch } "
8386
87+ @staticmethod
88+ def _get_binary_path (
89+ manager : "PostgreSQLBinaries" , version : str , binary_name : str
90+ ) -> str :
91+ install_dir = manager ._get_install_dir (version )
92+ binary_path = install_dir / "bin" / binary_name
93+
94+ if manager .SYSTEM == "windows" :
95+ binary_path = binary_path .with_suffix (".exe" )
96+ return binary_path
97+
8498 @classmethod
8599 def ensure_version (cls , version : str ) -> Path :
86100 """
@@ -142,9 +156,7 @@ def get_binary_path(cls, binary_name: str, version: str = None) -> Path:
142156 return Path (system_binary )
143157
144158 # Check our installation
145- install_dir = manager ._get_install_dir (version )
146- binary_path = install_dir / "bin" / binary_name
147-
159+ binary_path = cls ._get_binary_path (manager , version , binary_name )
148160 if binary_path .exists () and os .access (binary_path , os .X_OK ):
149161 return binary_path
150162
@@ -311,8 +323,8 @@ def _is_version_installed(self, version: str) -> bool:
311323 install_dir = self ._get_install_dir (version )
312324
313325 # Check if all required binaries exist
314- for binary in self .REQUIRED_BINARIES :
315- binary_path = install_dir / "bin" / binary
326+ for binary_name in self .REQUIRED_BINARIES :
327+ binary_path = self . _get_binary_path ( self , version , binary_name )
316328 if not (binary_path .exists () and os .access (binary_path , os .X_OK )):
317329 return False
318330
@@ -366,6 +378,9 @@ def _verify_installation(self, install_dir: Path) -> None:
366378
367379 for binary in self .REQUIRED_BINARIES :
368380 binary_path = bin_dir / binary
381+ if self .SYSTEM == "windows" :
382+ binary_path = binary_path .with_suffix (".exe" )
383+
369384 if not (binary_path .exists () and os .access (binary_path , os .X_OK )):
370385 raise BinaryNotFoundError (f"Binary { binary } not found in installation" )
371386
0 commit comments