File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -194,7 +194,23 @@ def _customize_site(self) -> None:
194194 if self ._sitecustomize is not None :
195195 contents += "\n " + self ._sitecustomize
196196 sitecustomize = self .site / "sitecustomize.py"
197+
198+ # Ensure the site directory exists before writing files
199+ sitecustomize .parent .mkdir (parents = True , exist_ok = True )
200+
197201 sitecustomize .write_text (contents )
202+
203+ # Ubuntu 24.04 compatibility: Also create a .pth file that imports our customizations
204+ # This ensures our customizations run even if system sitecustomize is loaded first
205+ if self ._sitecustomize is not None :
206+ # Create a separate module for our customizations
207+ customizations_module = self .site / "_venv_customizations.py"
208+ customizations_module .write_text (self ._sitecustomize )
209+
210+ # Create a .pth file that imports this module
211+ pth_file = self .site / "venv_customizations.pth"
212+ pth_file .write_text ("import _venv_customizations" )
213+
198214 # Make sure bytecode is up-to-date too.
199215 assert compileall .compile_file (str (sitecustomize ), quiet = 1 , force = True )
200216
You can’t perform that action at this time.
0 commit comments