Transcrypt fails to find relative imports

Aperta
#260 12 commenti 2 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
38/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript, python
Ambito
compilers

Direzione di ricerca

Reproduce the failure with main.py, parentmod/init.py, and parentmod/childmod.py, first comparing Python execution with transpiling main.py. Trace how the compiler resolves the relative import from parentmod/init.py and make the example compile and run successfully without the 'could not find' error.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

IS: limitation

Of a low priority to me, but thought I'd report this anyways. Relative imports (from .mod import ...) don't seem to work in Transcrypt, and produce a 'could not find' error.

Test case:

main.py:

import parentmod

parentmod.afunc()

parentmod/__init__.py:

from .childmod import afunc

parentmod/childmod.py:

def afunc():
    print('childmod: afunc!')

Running python main.py works as expected, but trying to transcrypt main.py results in the following error:

Transcrypt (TM) Python to JavaScript Small Sane Subset Transpiler Version 3.6.4
Copyright (C) Geatec Engineering. License: Apache 2.0


Error in program main.py, module childmod, line 1: 
	Attempt to load module: childmod
	Can't find any of:
		/home/daboross/Projects/Python/TranscryptTest/src/__javascript__/childmod.mod.js
		/home/daboross/Projects/Python/TranscryptTest/src/__javascript__/childmod.mod.js
		/home/daboross/Projects/Python/TranscryptTest/env/lib/python3.5/site-packages/transcrypt/modules/__javascript__/childmod.mod.js
		/home/daboross/Projects/Python/TranscryptTest/env/lib/python3.5/site-packages/transcrypt/modules/__javascript__/childmod.mod.js
		/home/daboross/Projects/Python/TranscryptTest/env/bin/__javascript__/childmod.mod.js
		/home/daboross/Projects/Python/TranscryptTest/env/bin/__javascript__/childmod.mod.js
		/home/daboross/Projects/Python/TranscryptTest/env/lib64/python35.zip/__javascript__/childmod.mod.js
		/home/daboross/Projects/Python/TranscryptTest/env/lib64/python35.zip/__javascript__/childmod.mod.js
		/home/daboross/Projects/Python/TranscryptTest/env/lib64/python3.5/__javascript__/childmod.mod.js
		/home/daboross/Projects/Python/TranscryptTest/env/lib64/python3.5/__javascript__/childmod.mod.js
		/home/daboross/Projects/Python/TranscryptTest/env/lib64/python3.5/plat-linux/__javascript__/childmod.mod.js
		/home/daboross/Projects/Python/TranscryptTest/env/lib64/python3.5/plat-linux/__javascript__/childmod.mod.js
		/home/daboross/Projects/Python/TranscryptTest/env/lib64/python3.5/lib-dynload/__javascript__/childmod.mod.js
		/home/daboross/Projects/Python/TranscryptTest/env/lib64/python3.5/lib-dynload/__javascript__/childmod.mod.js
		/usr/lib64/python3.5/__javascript__/childmod.mod.js
		/usr/lib64/python3.5/__javascript__/childmod.mod.js
		/usr/lib/python3.5/__javascript__/childmod.mod.js
		/usr/lib/python3.5/__javascript__/childmod.mod.js
		/usr/lib/python3.5/plat-linux/__javascript__/childmod.mod.js
		/usr/lib/python3.5/plat-linux/__javascript__/childmod.mod.js
		/home/daboross/Projects/Python/TranscryptTest/env/lib/python3.5/site-packages/__javascript__/childmod.mod.js
		/home/daboross/Projects/Python/TranscryptTest/env/lib/python3.5/site-packages/__javascript__/childmod.mod.js
		/usr/lib/python3.5/site-packages/__javascript__/childmod.mod.js
		/usr/lib/python3.5/site-packages/__javascript__/childmod.mod.js


Aborted
Lingua principale
Python
Stelle
2.9k
Fork
218
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TranscryptOrg/Transcrypt

Tutte le issue di TranscryptOrg/Transcrypt

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.