Skip to content

Commit 61269cd

Browse files
authored
Merge pull request #68 from Tieqiong/test
update setup.py for wheels
2 parents 8f68bf6 + c88a7ea commit 61269cd

File tree

11 files changed

+46
-26
lines changed

11 files changed

+46
-26
lines changed

docs/examples/distanceprinter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ def _addPairContribution(self, bnds, sumscale):
4747

4848

4949
def get_pyobjcryst_sphalerite():
50-
from pyobjcryst import loadCrystal
50+
from pyobjcryst.crystal import create_crystal_from_cif
5151

52-
crst = loadCrystal("datafiles/sphalerite.cif")
52+
crst = create_crystal_from_cif("datafiles/sphalerite.cif")
5353
return crst
5454

5555

docs/examples/parallelPDF.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
if opts.pyobjcryst:
3939
# use pyobjcryst if requested by the user
4040
from numpy import pi
41-
from pyobjcryst import loadCrystal
41+
from pyobjcryst.crystal import create_crystal_from_cif
4242

43-
menthol = loadCrystal(mentholcif)
43+
menthol = create_crystal_from_cif(mentholcif)
4444
for sc in menthol.GetScatteringComponentList():
4545
sp = sc.mpScattPow
4646
sp.Biso = sp.Biso or 8 * pi**2 * Uisodefault

requirements/pip.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
setuptools
2+
numpy

setup.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,26 @@
1717

1818

1919
def get_boost_libraries():
20-
base_lib = "boost_python"
21-
major, minor = str(sys.version_info[0]), str(sys.version_info[1])
22-
tags = [f"{major}{minor}", major, ""]
23-
mttags = ["", "-mt"]
24-
candidates = [base_lib + tag for tag in tags for mt in mttags] + [base_lib]
25-
for lib in candidates:
26-
if find_library(lib):
27-
return [lib]
20+
major, minor = sys.version_info[:2]
21+
candidates = [
22+
f"boost_python{major}{minor}",
23+
f"boost_python{major}",
24+
"boost_python",
25+
]
26+
27+
conda_prefix = os.environ.get("CONDA_PREFIX")
28+
if conda_prefix:
29+
libdir = os.path.join(conda_prefix, "lib")
30+
for name in candidates:
31+
so = f"lib{name}.so"
32+
if os.path.isfile(os.path.join(libdir, so)):
33+
return [name]
34+
35+
# fallback to ldconfig
36+
for name in candidates:
37+
found = find_library(name)
38+
if found:
39+
return [name]
2840
raise RuntimeError("Cannot find a suitable Boost.Python library.")
2941

3042

@@ -111,11 +123,11 @@ def create_extensions():
111123

112124

113125
# Extensions not included in pyproject.toml
114-
setup_args = dict(
115-
ext_modules=[],
116-
)
126+
def ext_modules():
127+
if set(sys.argv) & {"build_ext", "bdist_wheel", "install"}:
128+
return create_extensions()
129+
return []
117130

118131

119132
if __name__ == "__main__":
120-
setup_args["ext_modules"] = create_extensions()
121-
setup(**setup_args)
133+
setup(ext_modules=ext_modules())

src/diffpy/srreal/version.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@
1818
# __all__ = ["__date__", "__git_commit__", "__timestamp__", "__version__"]
1919

2020
# obtain version information
21-
from importlib.metadata import version
21+
from importlib.metadata import PackageNotFoundError, version
22+
23+
FALLBACK_VERSION = "1.3.0"
24+
25+
try:
26+
__version__ = version("diffpy.srreal")
27+
except PackageNotFoundError:
28+
__version__ = FALLBACK_VERSION
2229

23-
__version__ = version("diffpy.srreal")
2430

2531
# End of file

tests/test_bondcalculator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def test_setTypeMask(self):
255255
class TestBondCalculatorObjCryst(unittest.TestCase):
256256

257257
@pytest.fixture(autouse=True)
258-
def _check_periodictable(self, has_pyobjcryst, _msg_nopyobjcryst):
258+
def _check_pyobjcryst(self, has_pyobjcryst, _msg_nopyobjcryst):
259259
if not has_pyobjcryst:
260260
pytest.skip(_msg_nopyobjcryst)
261261

tests/test_overlapcalculator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ def test_neighborhoods(self):
344344
class TestOverlapCalculatorObjCryst(unittest.TestCase):
345345

346346
@pytest.fixture(autouse=True)
347-
def _check_periodictable(self, has_pyobjcryst, _msg_nopyobjcryst):
347+
def _check_pyobjcryst(self, has_pyobjcryst, _msg_nopyobjcryst):
348348
if not has_pyobjcryst:
349349
pytest.skip(_msg_nopyobjcryst)
350350

tests/test_pdfcalcobjcryst.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def _makePDFCalculator(crst, cfgdict):
6262
class TestPDFCalcObjcryst(unittest.TestCase):
6363

6464
@pytest.fixture(autouse=True)
65-
def _check_periodictable(self, has_pyobjcryst, _msg_nopyobjcryst):
65+
def _check_pyobjcryst(self, has_pyobjcryst, _msg_nopyobjcryst):
6666
if not has_pyobjcryst:
6767
pytest.skip(_msg_nopyobjcryst)
6868

tests/test_sfaverage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def test_fromComposition(self):
7979
class TestSFAverageObjCryst(unittest.TestCase):
8080

8181
@pytest.fixture(autouse=True)
82-
def _check_periodictable(self, has_pyobjcryst, _msg_nopyobjcryst):
82+
def _check_pyobjcryst(self, has_pyobjcryst, _msg_nopyobjcryst):
8383
if not has_pyobjcryst:
8484
pytest.skip(_msg_nopyobjcryst)
8585

tests/test_structureadapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def test_nosymmetry_pickling(self):
286286
class TestPyObjCrystAdapter(unittest.TestCase):
287287

288288
@pytest.fixture(autouse=True)
289-
def _check_periodictable(self, has_pyobjcryst, _msg_nopyobjcryst):
289+
def _check_pyobjcryst(self, has_pyobjcryst, _msg_nopyobjcryst):
290290
if not has_pyobjcryst:
291291
pytest.skip(_msg_nopyobjcryst)
292292

0 commit comments

Comments
 (0)