fix(package): resolve source paths relative to package root
This commit is contained in:
1 parent
f859ff536c
commit
1afb3a2b73
6 files changed
+31
-10
No files matched your search
@@ -49,16 +49,19 @@ REQUIRED_VENDOR_FILES = (
|
||||
|
||||
|
||||
def _source_directory():
|
||||
"""Find package root and return it relative to the current working directory."""
|
||||
candidates = []
|
||||
if globals().get('__file__'):
|
||||
candidates.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
for name in ('basedir', 'package_dir'):
|
||||
if globals().get(name):
|
||||
candidates.append(os.path.abspath(globals()[name]))
|
||||
candidates.append(os.getcwd())
|
||||
current_directory = os.getcwd()
|
||||
candidates.append(current_directory)
|
||||
for candidate in candidates:
|
||||
if os.path.isfile(os.path.join(candidate, 'WAPT', 'control')):
|
||||
return candidate
|
||||
relative_candidate = os.path.relpath(os.path.abspath(candidate), current_directory)
|
||||
if os.path.isfile(os.path.join(relative_candidate, 'WAPT', 'control')):
|
||||
return relative_candidate
|
||||
raise RuntimeError('Cannot locate WAPT source directory (WAPT/control not found).')
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user