Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 0 additions & 82 deletions bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
'include', # load and jit a header file
'c_include', # load and jit a C header file
'load_library', # load a shared library
'nullptr', # unique pointer representing NULL

Check failure on line 43 in bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F405)

bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py:43:5: F405 `nullptr` may be undefined, or defined from star imports
'sizeof', # size of a C++ type
'typeid', # typeid of a C++ type
'multi', # helper for multiple inheritance
Expand All @@ -64,27 +64,27 @@
ispypy = False

from . import _typemap
from ._version import __version__

Check failure on line 67 in bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F401)

bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py:67:23: F401 `._version.__version__` imported but unused; consider removing, adding to `__all__`, or using a redundant alias

# import separately instead of in the above try/except block for easier to
# understand tracebacks
if ispypy:
from ._pypy_cppyy import *

Check failure on line 72 in bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F403)

bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py:72:5: F403 `from ._pypy_cppyy import *` used; unable to detect undefined names
else:
from ._cpython_cppyy import *

Check failure on line 74 in bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F403)

bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py:74:5: F403 `from ._cpython_cppyy import *` used; unable to detect undefined names


#- allow importing from gbl --------------------------------------------------
sys.modules['cppyy.gbl'] = gbl

Check failure on line 78 in bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F405)

bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py:78:28: F405 `gbl` may be undefined, or defined from star imports
sys.modules['cppyy.gbl.std'] = gbl.std

Check failure on line 79 in bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F405)

bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py:79:32: F405 `gbl` may be undefined, or defined from star imports


#- external typemap ----------------------------------------------------------
_typemap.initialize(_backend) # also creates (u)int8_t mapper

Check failure on line 83 in bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F405)

bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py:83:21: F405 `_backend` may be undefined, or defined from star imports

try:
gbl.std.int8_t = gbl.int8_t # ensures same _integer_ type

Check failure on line 86 in bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F405)

bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py:86:23: F405 `gbl` may be undefined, or defined from star imports

Check failure on line 86 in bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F405)

bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py:86:5: F405 `gbl` may be undefined, or defined from star imports
gbl.std.uint8_t = gbl.uint8_t

Check failure on line 87 in bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F405)

bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py:87:5: F405 `gbl` may be undefined, or defined from star imports
except (AttributeError, TypeError):
pass

Expand Down Expand Up @@ -297,88 +297,6 @@
if os.path.exists(apipath) and os.path.exists(os.path.join(apipath, 'Python.h')):
add_include_path(apipath)

# add access to extra headers for dispatcher (CPyCppyy only (?))
if not ispypy:
try:
apipath_extra = os.environ['CPPYY_API_PATH']
if os.path.basename(apipath_extra) == 'CPyCppyy':
apipath_extra = os.path.dirname(apipath_extra)
except KeyError:
apipath_extra = None

if apipath_extra is None:
try:
if 0x30a0000 <= sys.hexversion:
import importlib.metadata as m

for p in m.files('CPyCppyy'):
if p.match('API.h'):
ape = p.locate()
break
del p, m
else:
import pkg_resources as pr

d = pr.get_distribution('CPyCppyy')
for line in d.get_metadata_lines('RECORD'):
if 'API.h' in line:
ape = os.path.join(d.location, line[0:line.find(',')])
break
del line, d, pr

if os.path.exists(ape):
apipath_extra = os.path.dirname(os.path.dirname(ape))
del ape
except Exception:
pass

if apipath_extra is None:
ldversion = sysconfig.get_config_var('LDVERSION')
if not ldversion:
ldversion = sys.version[:3]

apipath_extra = os.path.join(os.path.dirname(apipath), 'site', 'python'+ldversion)
if not os.path.exists(os.path.join(apipath_extra, 'CPyCppyy')):
import glob
import platform

if platform.system() == "Windows":
# Install locations are handled differently on Windows
import libcppyy

ape = os.path.dirname(libcppyy.__file__)
else:
import cppyy.libcppyy as libcppyy

ape = os.path.dirname(libcppyy.__file__)
# a "normal" structure finds the include directory up to 3 levels up,
# ie. dropping lib/pythonx.y[md]/site-packages
for i in range(3):
if os.path.exists(os.path.join(ape, 'include')):
break
ape = os.path.dirname(ape)

ape = os.path.join(ape, 'include')
if os.path.exists(os.path.join(ape, 'CPyCppyy')):
apipath_extra = ape
else:
# add back pythonx.y or site/pythonx.y if present
for p in glob.glob(os.path.join(ape, 'python'+sys.version[:3]+'*'))+\
glob.glob(os.path.join(ape, '*', 'python'+sys.version[:3]+'*')):
if os.path.exists(os.path.join(p, 'CPyCppyy')):
apipath_extra = p
break

if apipath_extra.lower() != 'none':
if not os.path.exists(os.path.join(apipath_extra, 'CPyCppyy')):
warnings.warn("CPyCppyy API not found (tried: %s); "
"set CPPYY_API_PATH envar to the 'CPyCppyy' API directory to fix"
% apipath_extra)
else:
add_include_path(apipath_extra)

del apipath_extra

if os.getenv('CONDA_PREFIX'):
# MacOS, Linux
include_path = os.path.join(os.getenv('CONDA_PREFIX'), 'include')
Expand Down
Loading