Skip to content

fix windows dll directories #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 8, 2025
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
27 changes: 26 additions & 1 deletion project.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,37 @@
import os
from pathlib import Path

from pyqtbuild import PyQtBindings, PyQtProject
from pyqtbuild import PyQtBindings, PyQtProject, QmakeBuilder


class _Builder(QmakeBuilder):
# small hack to make a custom __init__ file
# not using Project.dunder_init... since that seems to affect PyQt6.__init__
def install_project(self, target_dir, *, wheel_tag=None):
super().install_project(target_dir, wheel_tag=wheel_tag)
package = Path(target_dir, "PyQt6Ads")
if os.name != "nt":
contents = "from ._ads import *\n"
else:
contents = """
try:
import PyQt6 # force addition of Qt6/bin to dll_directories
except ImportError:
raise ImportError("PyQt6 must be installed in order to use PyQt6Ads.") from None

from ._ads import *
del PyQt6
"""
(package / "__init__.py").write_text(contents)

# rename _ads.pyi to __init__.pyi
(package / "_ads.pyi").rename(package / "__init__.pyi")
(package / "py.typed").touch()

class PyQt6Ads(PyQtProject):
def __init__(self):
super().__init__()
self.builder_factory = _Builder
self.bindings_factories = [PyQt6Adsmod]
self.verbose = bool(os.getenv("CI") or os.getenv("CIBUILDWHEEL"))

Expand Down
4 changes: 2 additions & 2 deletions scripts/repair_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def main() -> None:
RPATH_RE_MAC = re.compile(r"^\s*path (.+) \(offset \d+\)$", re.MULTILINE)


def fix_rpath_macos(so: Path, new_rpath: str = "@loader_path/PyQt6/Qt6/lib") -> None:
def fix_rpath_macos(so: Path, new_rpath: str = "@loader_path/../PyQt6/Qt6/lib") -> None:
# delete all current rpaths
current_rpath = run(["otool", "-l", str(so)], capture_output=True, text=True)
for rpath in RPATH_RE_MAC.findall(current_rpath.stdout):
Expand All @@ -48,7 +48,7 @@ def fix_rpath_macos(so: Path, new_rpath: str = "@loader_path/PyQt6/Qt6/lib") ->
print(f"Updated RPATH for {so} to {new_rpath}")


def fix_rpath_linux(so: Path, new_rpath: str = "$ORIGIN/PyQt6/Qt6/lib") -> None:
def fix_rpath_linux(so: Path, new_rpath: str = "$ORIGIN/../PyQt6/Qt6/lib") -> None:
# delete all current rpaths
current_rpath = run(
["patchelf", "--print-rpath", str(so)], capture_output=True, text=True
Expand Down
2 changes: 1 addition & 1 deletion sip/PyQt6Ads.sip
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%Module(name=PyQt6Ads, call_super_init=True, keyword_arguments="Optional", use_limited_api=True)
%Module(name=PyQt6Ads._ads, call_super_init=True, keyword_arguments="Optional", use_limited_api=True)
%HideNamespace(name=ads)

%Import QtCore/QtCoremod.sip
Expand Down
1 change: 1 addition & 0 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from pathlib import Path
from unittest.mock import patch

import PyQt6Ads # noqa # import here to ensure that it works regardless of order
import pytest
from PyQt6.QtWidgets import QApplication

Expand Down