pynt icon indicating copy to clipboard operation
pynt copied to clipboard

imp.load_source makes it hard to import build utilities

Open matthewdeanmartin opened this issue 6 years ago • 0 comments

I have some functions I wanted to get out of the build.py file because they were getting bigger than the build script. I tried importing, e.g. import foo, but this line in pynt prevents it:

module = imp.load_source(path.splitext(path.basename(args.file))[0], args.file)

This is some weird loading that allows loading from pip installed, but not from code in the same directory as build.py.

The above line is also deprecated in python 3.

Here is a nasty hack to get around it.

sys.path.append(os.path.join(os.path.dirname(__file__), '.'))
from build_utils import check_is_aws, skip_if_no_change, execute_with_environment

I don't know the motivation was for using imp.load_source, but it makes pynt more difficult to use. When I get a chance I'll review navio's version & see if it has been solved there.

matthewdeanmartin avatar Jul 17 '18 12:07 matthewdeanmartin