Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 25 additions & 12 deletions src/portable_python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,10 +497,10 @@ def cfg_url(self, version):
url_template = Template(config_url)
return url_template.substitute(version=version)

def cfg_configure(self, deps_lib):
def cfg_configure(self, deps_lib_dir, deps_lib64_dir):
if configure := PPG.config.get_value("%s-configure" % self.m_name):
configure_template = Template(configure)
return configure_template.substitute(deps_lib=deps_lib)
return configure_template.substitute(lib_dir=deps_lib_dir, lib64_dir=deps_lib64_dir)

def cfg_patches(self):
return PPG.config.get_value("%s-patches" % self.m_name)
Expand All @@ -521,9 +521,20 @@ def deps(self):
return self.setup.folders.deps

@property
def deps_lib(self):
def deps_lib_dir(self):
return self.deps / "lib"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This leads to a lot of places to adapt with previous PR #59 because self.deps_lib is used quite a bit from c_configure_args().

I'll try and get my hands on a Centos7 instance (or Rocky9?) to try and see what's up with the lib64 thing.

I was also able to use the system libffi internally, so the need to statically compile libffi is gone for me. Ideally it would absolutely keep working of course, it's just that I haven't had to directly deal with it.

Try and merge main here to see what to do with the deps_lib -> deps_lib_dir rename. The rename may be actually helpful (will help spot out missed places that weren't adapted)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See 58ae22b for change


@property
def deps_lib64_dir(self):
return self.deps / "lib64"

@property
def deps_lib_dirs(self):
lib_dirs = [self.deps_lib_dir]
if self.deps_lib64_dir.exists():
lib_dirs.append(self.deps_lib64_dir)
return lib_dirs

def xenv_CPATH(self):
folder = self.deps / "include"
if folder.exists():
Expand All @@ -536,7 +547,7 @@ def xenv_CPATH(self):

def xenv_LDFLAGS(self):
if self.modules.selected:
yield f"-L{self.deps_lib}"
yield from (f"-L{lib_dir}" for lib_dir in self.deps_lib_dirs)

def xenv_PATH(self):
yield f"{self.deps}/bin"
Expand All @@ -550,7 +561,7 @@ def xenv_LD_LIBRARY_PATH(self):
def xenv_PKG_CONFIG_PATH(self):
yield from os.environ.get("PKG_CONFIG_PATH", "").split(":")
if self.modules.selected:
yield f"{self.deps_lib}/pkgconfig"
yield from (f"{lib_dir}/pkgconfig" for lib_dir in self.deps_lib_dirs)

def _do_run(self, program, *args, fatal=True, env=None):
return runez.run(program, *args, passthrough=self._log_handler, stdout=None, stderr=None, fatal=fatal, env=env)
Expand Down Expand Up @@ -771,10 +782,12 @@ def _prepare(self):
# Some libs get funky permissions for some reason
super()._prepare()
self.setup.ensure_clean_folder(self.install_folder)
for path in runez.ls_dir(self.deps_lib):
if not path.name.endswith(".la"):
expected = 0o755 if path.is_dir() else 0o644
current = path.stat().st_mode & 0o777
if current != expected:
LOG.info("Corrected permissions for %s (was %s)", runez.short(path), oct(current))
path.chmod(expected)

for lib_dir in self.deps_lib_dirs:
for path in runez.ls_dir(lib_dir):
if not path.name.endswith(".la"):
expected = 0o755 if path.is_dir() else 0o644
current = path.stat().st_mode & 0o777
if current != expected:
LOG.info("Corrected permissions for %s (was %s)", runez.short(path), oct(current))
path.chmod(expected)
10 changes: 7 additions & 3 deletions src/portable_python/cpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def url(self):
return f"https://www.python.org/ftp/python/{self.version.main}/Python-{self.version}.tar.xz"

def xenv_LDFLAGS_NODIST(self):
yield f"-L{self.deps_lib}"
yield from (f"-L{lib_dir}" for lib_dir in self.deps_lib_dirs)
if PPG.target.is_linux:
yield "-Wl,-z,origin"
# rpath intentionally long to give 'patchelf' some room
Expand Down Expand Up @@ -142,7 +142,7 @@ def c_configure_args(self):

if not self.has_configure_opt("--with-system-ffi"):
if self.active_module(LibFFI):
yield f"LIBFFI_INCLUDEDIR={self.deps_lib}"
yield f"LIBFFI_INCLUDEDIR={self.deps_lib_dir}"
yield "--with-system-ffi=no"

else:
Expand All @@ -166,7 +166,11 @@ def c_configure_args(self):
# TODO: this doesn't seem to be enough, on macos cpython's ./configure still picks up the shared macos tcl/tk libs
version = Version(tkinter.version)
yield f"--with-tcltk-includes=-I{self.deps}/include"
yield f"--with-tcltk-libs=-L{self.deps_lib} -ltcl{version.mm} -ltk{version.mm}"

lib_dir_flags = " ".join(f"-L{lib_dir}" for lib_dir in self.deps_lib_dirs)
yield f"--with-tcltk-libs={lib_dir_flags}"
yield f"-ltcl{version.mm}"
yield f"-ltk{version.mm}"

@runez.cached_property
def prefix_lib_folder(self):
Expand Down
22 changes: 11 additions & 11 deletions src/portable_python/external/xcpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def version(self):
return self.cfg_version("6.2.32")

def c_configure_args(self):
if config_args := self.cfg_configure(self.deps_lib):
if config_args := self.cfg_configure(self.deps_lib_dir, self.deps_lib64_dir):
yield config_args

else:
Expand Down Expand Up @@ -87,7 +87,7 @@ def version(self):
return self.cfg_version("1.24")

def c_configure_args(self):
if config_args := self.cfg_configure(self.deps_lib):
if config_args := self.cfg_configure(self.deps_lib_dir, self.deps_lib64_dir):
yield config_args

else:
Expand Down Expand Up @@ -132,7 +132,7 @@ def version(self):
return self.cfg_version("3.4.6")

def c_configure_args(self):
if config_args := self.cfg_configure(self.deps_lib):
if config_args := self.cfg_configure(self.deps_lib_dir, self.deps_lib64_dir):
yield config_args

else:
Expand Down Expand Up @@ -179,7 +179,7 @@ def version(self):
return self.cfg_version("3.0.15")

def c_configure_args(self):
if config_args := self.cfg_configure(self.deps_lib):
if config_args := self.cfg_configure(self.deps_lib_dir, self.deps_lib64_dir):
yield config_args

else:
Expand Down Expand Up @@ -208,7 +208,7 @@ def version(self):
return self.cfg_version("6.5")

def c_configure_args(self):
if config_args := self.cfg_configure(self.deps_lib):
if config_args := self.cfg_configure(self.deps_lib_dir, self.deps_lib64_dir):
yield config_args

else:
Expand All @@ -219,7 +219,7 @@ def c_configure_args(self):
yield "--without-manpages"
yield "--without-progs"
yield "--without-tests"
yield f"--with-pkg-config-libdir={self.deps_lib}/pkgconfig"
yield f"--with-pkg-config-libdir={self.deps_lib_dir}/pkgconfig"
yield "--enable-pc-files"
yield "--with-debug=no"
yield "--with-gpm=no"
Expand Down Expand Up @@ -265,7 +265,7 @@ def version(self):
return self.cfg_version("8.2.13")

def c_configure_args(self):
if config_args := self.cfg_configure(self.deps_lib):
if config_args := self.cfg_configure(self.deps_lib_dir, self.deps_lib64_dir):
yield config_args

else:
Expand Down Expand Up @@ -309,7 +309,7 @@ def version(self):
return self.cfg_version("3.47.0")

def c_configure_args(self):
if config_args := self.cfg_configure(self.deps_lib):
if config_args := self.cfg_configure(self.deps_lib_dir, self.deps_lib64_dir):
yield config_args

else:
Expand Down Expand Up @@ -346,7 +346,7 @@ def version(self):
return self.cfg_version("1.0.3")

def c_configure_args(self):
if config_args := self.cfg_configure(self.deps_lib):
if config_args := self.cfg_configure(self.deps_lib_dir, self.deps_lib64_dir):
yield config_args

else:
Expand Down Expand Up @@ -376,7 +376,7 @@ def version(self):
return self.cfg_version("5.6.3")

def c_configure_args(self):
if config_args := self.cfg_configure(self.deps_lib):
if config_args := self.cfg_configure(self.deps_lib_dir, self.deps_lib64_dir):
yield config_args

else:
Expand Down Expand Up @@ -419,7 +419,7 @@ def version(self):
return self.cfg_version("1.3.1")

def c_configure_args(self):
if config_args := self.cfg_configure(self.deps_lib):
if config_args := self.cfg_configure(self.deps_lib_dir, self.deps_lib64_dir):
yield config_args

else:
Expand Down
6 changes: 3 additions & 3 deletions src/portable_python/external/xtkinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def xenv_CFLAGS(self):
def c_configure_args(self):
yield "--enable-shared=no"
yield "--enable-threads"
yield f"--with-tcl={self.deps_lib}"
yield f"--with-tcl={self.deps_lib_dir}"
yield "--without-x"
if PPG.target.is_macos: # pragma: no cover, tcl/tk is "best effort"
yield "--enable-aqua=yes"
Expand Down Expand Up @@ -89,8 +89,8 @@ def xenv_CFLAGS(self):
def c_configure_args(self):
yield "--enable-shared=no"
yield "--enable-threads"
yield f"--with-tcl={self.deps_lib}"
yield f"--with-tk={self.deps_lib}"
yield f"--with-tcl={self.deps_lib_dir}"
yield f"--with-tk={self.deps_lib_dir}"
yield "--without-x"

def _do_linux_compile(self):
Expand Down