Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • pygobject pygobject
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 302
    • Issues 302
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 31
    • Merge requests 31
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOMEGNOME
  • pygobjectpygobject
  • Issues
  • #545
Closed
Open
Issue created Sep 07, 2022 by Dan Yeaw@danyeawContributor

Unable to find DLL when loading PyGObject in Windows

In Python 3.8, a new os.add_dll_directory method was added to make loading DLLs in Windows more consistent.

!193 (closed) attempted to fix this by upstreaming gvsbuild patches, but was closed by !206 (merged). It looks like !206 (merged) added a function to set the DLL search path during initialization of the test environment. I don't think that fixed the issue.

The impact of this is that even if I compile GTK successfully with MSVC, and add it to the Path, INCLUDE, and LIB, I am still not able to pip install PyGObject in Windows.

Would explicitly calling the add_dll_directory in gi/__init__.py module prior to attempting to import _gi be an acceptable solution? If so I can create a MR.

if sys.platform == "win32" and sys.version_info >= (3, 8):
    env_path = os.environ.get("PATH", "").split(os.pathsep)
    first_gtk_path = next(
        filter(
            lambda path: path is not None
            and Path.is_file(Path(path) / "girepository-1.0-1.dll"),
            env_path,
        ),
        None,
    )
    if first_gtk_path:
        with os.add_dll_directory(first_gtk_path):
            from . import _gi


else:
    from . import _gi
Assignee
Assign to
Time tracking