Transcrypt fails to find relative imports

Open
#260 12 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript, python
Domain
compilers

Research direction

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.

Written by the indexing model from the issue text.

Description

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
Dominant language
Python
Stars
2.9k
Forks
218
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from TranscryptOrg/Transcrypt

All issues in TranscryptOrg/Transcrypt

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.