Merge pull request #253 from jayvdb/hook-if-file-exists
Dont crash if __file__ is not set by importer
This commit is contained in:
@@ -4131,8 +4131,13 @@ def add_import_hook(additional_paths=[]):
|
|||||||
|
|
||||||
# Automatically include the system and built-in capnp paths
|
# Automatically include the system and built-in capnp paths
|
||||||
# Highest priority at position 0
|
# Highest priority at position 0
|
||||||
extra_paths = [
|
try:
|
||||||
_os.path.join(_os.path.dirname(__file__), '..'), # Built-in (only used if bundled)
|
this_file_path = __file__
|
||||||
|
except NameError:
|
||||||
|
this_file_path = None
|
||||||
|
extra_paths = ([
|
||||||
|
_os.path.join(_os.path.dirname(this_file_path), '..'), # Built-in (only used if bundled)
|
||||||
|
] if this_file_path else []) + [
|
||||||
# Common macOS brew location
|
# Common macOS brew location
|
||||||
'/usr/local/include/capnp',
|
'/usr/local/include/capnp',
|
||||||
'/usr/local/include',
|
'/usr/local/include',
|
||||||
|
|||||||
Reference in New Issue
Block a user