Skip to content

Implement import by using importlib #958

@BenLewis-Seequent

Description

@BenLewis-Seequent

The standard library for Python contains importlib, which contains a pure* Python implementation of the import machinery. This is lucky as we then don't have to implement it all in Rust. But we have to bootstrap it and implement all of the functionality it uses from builtin modules.

This is blocked by the following:

  • compile should accept bytes as well as strings
  • _os.fspath - https://docs.python.org/3/library/os.html#os.fspath
  • sys.implementation.cache_tag - This just needs to exist we don't support caching bytecode at the moment
  • sys.pycache_prefix - same as above
  • sys.flags
  • str.endswith needs to support tuple argument
  • _io.FileIO __enter__ and __exit__ methods
  • sys.platform
  • os.getcwd
  • os.stat st_mtime attribute
  • _warnings module
  • possibly more

* Uses built-in module _imp to actually create module objects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-compatA discrepancy between RustPython and CPython

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions