it would be nice if we could import the runcard directly from a given path, independent of its location, i.e. both pyHepGrid man /some/path/to/a/runcard/runcard.py -B and cd /some/path/to/a/runcard && pyHepGrid man runcard.py -B should give the same result.
Currently only the latter works. The first version throws:
Traceback (most recent call last):
File "/bin/pyHepGrid", line 11, in <module>
load_entry_point('pyHepGrid', 'console_scripts', 'pyHepGrid')()
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 476, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2700, in load_entry_point
return ep.load()
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2318, in load
return self.resolve()
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2324, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/pyHepGrid/src/pyHepGrid/main.py", line 5, in <module>
from pyHepGrid.src.header import arctable, diractable, arcprodtable, slurmprodtable, \
File "/pyHepGrid/src/pyHepGrid/src/header.py", line 94, in <module>
runcard = importlib.import_module(runcard_file.replace(".py","").replace("/","."))
File "/usr/lib64/python3.6/importlib/__init__.py", line 121, in import_module
raise TypeError(msg.format(name))
TypeError: the 'package' argument is required to perform a relative import for '..................some.path.to.a.runcard.runcard'
it would be nice if we could import the runcard directly from a given path, independent of its location, i.e. both
pyHepGrid man /some/path/to/a/runcard/runcard.py -B
andcd /some/path/to/a/runcard && pyHepGrid man runcard.py -B
should give the same result.Currently only the latter works. The first version throws: