Skip to content

Import does not work from Cython #1890

Closed as not planned
Closed as not planned
@josephernest

Description

@josephernest

This code works from Python:

import clr
clr.AddReference("abc.dll")
from ABC import abc

But when compiled with Cython --embed, it fails:

cython test.py --embed
call vcvarsallbat x64
cl test.c /I C:\Python38\include /link C:\Python38\libs\python38.lib
test.exe

with:

Traceback (most recent call last):
File "test.py", line 3, in init test
ModuleNotFoundError: No module named 'ABC'

Is this related to #941?

Is there a temporary or permanent fix for this?
Thanks!

A good idea would be to have an import function that can be called on clr namespace:

import clr
clr.AddReference("abc.dll")
ABC = clr.ImportModule('ABC')

that would not need to use the overridden import built-in function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions