Skip to content

site.addsitedir order is incorrect #1338

Closed

Description

@mhsmith

Originally reported by @timrid in beeware/briefcase#2173 (comment)


When processing the .pth file I get the following error before the main module is even started. On windows executing the startup code via .pth is no problem. I guess that java.chaquopy.import_override modifies some behavior, so that _socket is not loaded when executing my startup code.

...
W/python.stderr: Error processing line 1 of /data/data/com.example.helloworld/files/chaquopy/AssetFinder/app/__briefcase_startup__.pth:
W/python.stderr: 
W/python.stderr:   Traceback (most recent call last):
W/python.stderr:     File "<frozen site>", line 206, in addpackage
W/python.stderr:     File "<string>", line 1, in <module>
W/python.stderr:     File "import.pxi", line 60, in java.chaquopy.import_override
W/python.stderr:     File "/data/data/com.example.helloworld/files/chaquopy/AssetFinder/app/__briefcase_startup__.py", line 4, in <module>
W/python.stderr:       import socket
W/python.stderr:     File "stdlib/socket.py", line 52, in <module>
W/python.stderr:   ModuleNotFoundError: No module named '_socket'
W/python.stderr:
W/python.stderr: Remainder of file ignored
D/MainActivity: Running main module helloworld
...

Activity

  1. added this to the 17.0 milestone on Mar 3, 2025
  2. mhsmith commented on Mar 3, 2025

    @mhsmith
    MemberAuthor

    sys.path correctly follows the dependency order (app, requirements, stdlib). However, initialization should happen in the reverse order, low level to high level. And in case .pth files scan the whole of sys.path, maybe we should create all path entries before running any .pth files. In which case, the order would be:

    • Add all sys.path entries, without running any code from those paths.
    • Run site.addsitedir in the order (stdlib, requirements, app)
  3. changed the title [-]site.addsitedir order is incorrect[/-] [+]`site.addsitedir` order is incorrect[/+] on Mar 3, 2025
  4. modified the milestones: 17.0, 16.1 on Apr 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions