Skip to content

Commit 3df6d40

Browse files
committed
Replace os.path with pathlib in __init__
1 parent ae7000b commit 3df6d40

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

pytensor/__init__.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
# Set a default logger. It is important to do this before importing some other
2424
# pytensor code, since this code may want to log some messages.
2525
import logging
26-
import os
2726
import sys
2827
from functools import singledispatch
28+
from pathlib import Path
2929
from typing import Any, NoReturn, Optional
3030

3131
from pytensor.version import version as __version__
@@ -52,10 +52,8 @@ def disable_log_handler(logger=pytensor_logger, handler=logging_default_handler)
5252

5353
# Raise a meaningful warning/error if the pytensor directory is in the Python
5454
# path.
55-
rpath = os.path.realpath(__path__[0])
56-
for p in sys.path:
57-
if os.path.realpath(p) != rpath:
58-
continue
55+
rpath = Path(__file__).parent.resolve()
56+
if any(rpath == Path(p).resolve() for p in sys.path):
5957
raise RuntimeError("You have the pytensor directory in your Python path.")
6058

6159
from pytensor.configdefaults import config

0 commit comments

Comments
 (0)