Skip to content

Commit 8ef0436

Browse files
committed
test_conditional_import and installation
1 parent 0fdce76 commit 8ef0436

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

pyproject.toml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,18 @@ dependencies = [
2626
"distlib==0.3.9"
2727
]
2828

29-
30-
31-
[tool.deptry.per_rule_ignores]
32-
DEP002 = ["openpyxl"]
33-
DEP001 = ["mpl_toolkits", "xylib"]
34-
35-
[tool.setuptools]
36-
ext-modules = [{name = "_xylib",sources = ["xylib/philips_udf.cpp","xylib/uxd.cpp","xylib/winspec_spe.cpp","xylib/xrdml.cpp","xylib/xfit_xdd.cpp","xylib/cache.cpp","xylib/bruker_raw.cpp","xylib/spectra.cpp","xylib/riet7.cpp","xylib/csv.cpp","xylib/specsxy.cpp","xylib/bruker_spc.cpp","xylib/pdcif.cpp","xylib/canberra_mca.cpp","xylib/xylib.cpp","xylib/philips_raw.cpp","xylib/vamas.cpp","xylib/rigaku_dat.cpp","xylib/util.cpp","xylib/cpi.cpp","xylib/text.cpp","xylib/dbws.cpp","xylib/canberra_cnf.cpp","xylib/xsyg.cpp","xylib/chiplot.cpp", "xylib.i"],include-dirs = ["."],language = "c++",swig-opts = ["-c++"]}]
37-
py-modules = ["xylib"]
29+
#Uncomment the following lines to enable to use of xylib
30+
#xylib is a C++ library for reading and writing various X-ray diffraction file formats
31+
#xylib is not a Python package, but a C++ library that can be used
32+
#through a Python wrapper. The wrapper is generated using SWIG.
33+
34+
#[tool.deptry.per_rule_ignores]
35+
#DEP002 = ["openpyxl"]
36+
#DEP001 = ["mpl_toolkits", "xylib"]
37+
38+
#[tool.setuptools]
39+
#ext-modules = [{name = "_xylib",sources = ["xylib/philips_udf.cpp","xylib/uxd.cpp","xylib/winspec_spe.cpp","xylib/xrdml.cpp","xylib/xfit_xdd.cpp","xylib/cache.cpp","xylib/bruker_raw.cpp","xylib/spectra.cpp","xylib/riet7.cpp","xylib/csv.cpp","xylib/specsxy.cpp","xylib/bruker_spc.cpp","xylib/pdcif.cpp","xylib/canberra_mca.cpp","xylib/xylib.cpp","xylib/philips_raw.cpp","xylib/vamas.cpp","xylib/rigaku_dat.cpp","xylib/util.cpp","xylib/cpi.cpp","xylib/text.cpp","xylib/dbws.cpp","xylib/canberra_cnf.cpp","xylib/xsyg.cpp","xylib/chiplot.cpp", "xylib.i"],include-dirs = ["."],language = "c++",swig-opts = ["-c++"]}]
40+
#py-modules = ["xylib"]
3841

3942

4043
[tool.setuptools.packages.find]

xrdpattern/parsing/xylib/xylib_repr.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@
55
from tempfile import NamedTemporaryFile
66
from typing import Optional
77

8-
import xylib
8+
try:
9+
import xylib
10+
except ImportError:
11+
import warnings
12+
warnings.warn("""xylib is not installed. Setting xylib module to None.
13+
This will result in errors when using this module.
14+
Please install xylib to use this module.""")
15+
xylib = None
916

1017
__version__ = xylib.xylib_get_version()
1118

0 commit comments

Comments
 (0)