exaloop / codon

A high-performance, zero-overhead, extensible Python compiler using LLVM
https://docs.exaloop.io/codon
Other
15.12k stars 521 forks source link

No Module Named 'foo' #176

Closed obrunodelgado closed 1 year ago

obrunodelgado commented 1 year ago

Hey guys, I have a python project that I'm trying to experiment using Codon but when I try to execute my main.py I got these errors:

(base) brunodelgado@foo:~/folder $ codon run main.py 
main.py:4:6-35: error: no module named 'aplicacao.calculadora_da_vwap'
main.py:5:6-29: error: no module named 'aplicacao.configuracoes'
main.py:11:21-40: error: name 'obter_configuracoes' is not defined
main.py:12:5-18: error: name 'calcular_vwap' is not defined

main.py

import time
from datetime import datetime

from aplicacao.calculadora_da_vwap import calcular_vwap
from aplicacao.configuracoes import obter_configuracoes

if __name__ == '__main__':
    tic = time.perf_counter()

    data = datetime.strptime("20230111", "%Y%m%d")
    configuracoes = obter_configuracoes()
    calcular_vwap(data, configuracoes)

    toc = time.perf_counter()
    print(f"Processado em {toc - tic:0.4f} segundos")

I have my CODON_PYTHON environment variable pointing to the my conda env /home/brunodelgado/anaconda3.

Project Structure

├── main.py
├── aplicacao
│   ├── calculadora_da_vwap.py
│   ├── configuracoes.py
│   ├── __init__.py
├── dominio
│   ├── calculo_vwap.py
│   ├── dicionario_de_colunas.py
│   ├── __init__.py
├── repositorio
│   ├── conversor_para_estrutura_csv.py
│   ├── __init__.py
│   ├── negocios_intradiarios_repository.py
├── requirements.txt

Can you give me some hints on how to solve this problem?

arshajii commented 1 year ago

This is the same issue as https://github.com/exaloop/codon/issues/159 -- it seems Codon doesn't recognize *.py files in imports and only looks at *.codon files. We'll fix it shortly!

arshajii commented 1 year ago

This should be fixed in the latest release (0.15.4); please let us know if you encounter any other issues with this.

coolcoder613eb commented 1 year ago

@arshajii i have this problem version is 0.15.5

coolcoder613eb commented 1 year ago

I have:

@python
def run_code(code):
   import embed
   embed.run_code(bytes(code,'utf-8'))

which throws

PyError: No module named 'embed'

when i have an embed.py in the same directory

coolcoder613eb commented 1 year ago

fixed with PYTHONPATH=., why doesn't codon use sys.modules?