Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make module imports transparent #7

Open
fridex opened this issue May 13, 2016 · 3 comments
Open

Make module imports transparent #7

fridex opened this issue May 13, 2016 · 3 comments
Assignees

Comments

@fridex
Copy link
Contributor

fridex commented May 13, 2016

It is not possible to use module in a generic manner; reproducer:

$ git clone https://github.com/gofed/lib gofedlib
$ cat > test.py <<EOF
# extract API and dependencies

from gofedlib.go.functions import api, project_packages
from gofedlib.types import ExtractionError
import logging

source_code_directory = "~/Golang/etcd/etcd-5e6eb7e19d6385adfabb1f1caea03e732f9348ad"

try:
    etcd_api = api(source_code_directory)
    etcd_packages = project_packages(source_code_directory)
except ExtractionError as e:
    logging.error("Unable to extract %s: %s" % (source_code_directory, e))
    exit(1)

# print list of defined packages in etcd
print "Defined packages"
for package in etcd_packages["packages"]:
    print package
print ""

# print list of defined exported functions in etcd
print "Defined functions"
for package in etcd_api:
    print package["package"]
    for func in package["functions"]:
        print "\t%s" % func["name"]
print ""
EOF

$ python test.py
Traceback (most recent call last):
  File "./test.py", line 3, in <module>
    from gofedlib.go.functions import api, project_packages
  File "/tmp/gofedlib/go/functions.py", line 1, in <module>
    from .symbolsextractor.extractor import GoSymbolsExtractor
  File "/tmp/gofedlib/go/symbolsextractor/extractor.py", line 4, in <module>
    from lib.utils import getScriptDir, runCommand
ImportError: No module named lib.utils
@ingvagabund
Copy link
Contributor

ingvagabund commented May 13, 2016

  1. need to set PYTHONPATH to point to directory where you cloned gofed_lib repository is
  2. the cloned directory has to be named lib

@ingvagabund
Copy link
Contributor

Readme.md has to be updated.

@ingvagabund ingvagabund self-assigned this May 13, 2016
@fridex
Copy link
Contributor Author

fridex commented May 13, 2016

  1. need to set PYTHONPATH to point to directory where you cloned gofed_lib repository is
  2. the cloned directory has to be named lib

This does not conform to a library design. This should be transparent without additional hacks.

@fridex fridex mentioned this issue Jun 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants