Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions docs/examples/distanceprinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ def _addPairContribution(self, bnds, sumscale):


def get_pyobjcryst_sphalerite():
from pyobjcryst import loadCrystal
from pyobjcryst.crystal import create_crystal_from_cif

crst = loadCrystal("datafiles/sphalerite.cif")
crst = create_crystal_from_cif("datafiles/sphalerite.cif")
return crst


Expand Down
4 changes: 2 additions & 2 deletions docs/examples/parallelPDF.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
if opts.pyobjcryst:
# use pyobjcryst if requested by the user
from numpy import pi
from pyobjcryst import loadCrystal
from pyobjcryst.crystal import create_crystal_from_cif

menthol = loadCrystal(mentholcif)
menthol = create_crystal_from_cif(mentholcif)
for sc in menthol.GetScatteringComponentList():
sp = sc.mpScattPow
sp.Biso = sp.Biso or 8 * pi**2 * Uisodefault
Expand Down
2 changes: 2 additions & 0 deletions requirements/pip.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
setuptools
numpy
38 changes: 25 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,26 @@


def get_boost_libraries():
base_lib = "boost_python"
major, minor = str(sys.version_info[0]), str(sys.version_info[1])
tags = [f"{major}{minor}", major, ""]
mttags = ["", "-mt"]
candidates = [base_lib + tag for tag in tags for mt in mttags] + [base_lib]
for lib in candidates:
if find_library(lib):
return [lib]
major, minor = sys.version_info[:2]
candidates = [
f"boost_python{major}{minor}",
f"boost_python{major}",
"boost_python",
]

conda_prefix = os.environ.get("CONDA_PREFIX")
if conda_prefix:
libdir = os.path.join(conda_prefix, "lib")
for name in candidates:
so = f"lib{name}.so"
if os.path.isfile(os.path.join(libdir, so)):
return [name]

# fallback to ldconfig
for name in candidates:
found = find_library(name)
if found:
return [name]
raise RuntimeError("Cannot find a suitable Boost.Python library.")


Expand Down Expand Up @@ -111,11 +123,11 @@ def create_extensions():


# Extensions not included in pyproject.toml
setup_args = dict(
ext_modules=[],
)
def ext_modules():
if set(sys.argv) & {"build_ext", "bdist_wheel", "install"}:
return create_extensions()
return []


if __name__ == "__main__":
setup_args["ext_modules"] = create_extensions()
setup(**setup_args)
setup(ext_modules=ext_modules())
10 changes: 8 additions & 2 deletions src/diffpy/srreal/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@
# __all__ = ["__date__", "__git_commit__", "__timestamp__", "__version__"]

# obtain version information
from importlib.metadata import version
from importlib.metadata import PackageNotFoundError, version

FALLBACK_VERSION = "1.3.0"

try:
__version__ = version("diffpy.srreal")
except PackageNotFoundError:
__version__ = FALLBACK_VERSION

__version__ = version("diffpy.srreal")

# End of file
2 changes: 1 addition & 1 deletion tests/test_bondcalculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def test_setTypeMask(self):
class TestBondCalculatorObjCryst(unittest.TestCase):

@pytest.fixture(autouse=True)
def _check_periodictable(self, has_pyobjcryst, _msg_nopyobjcryst):
def _check_pyobjcryst(self, has_pyobjcryst, _msg_nopyobjcryst):
if not has_pyobjcryst:
pytest.skip(_msg_nopyobjcryst)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_overlapcalculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def test_neighborhoods(self):
class TestOverlapCalculatorObjCryst(unittest.TestCase):

@pytest.fixture(autouse=True)
def _check_periodictable(self, has_pyobjcryst, _msg_nopyobjcryst):
def _check_pyobjcryst(self, has_pyobjcryst, _msg_nopyobjcryst):
if not has_pyobjcryst:
pytest.skip(_msg_nopyobjcryst)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_pdfcalcobjcryst.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _makePDFCalculator(crst, cfgdict):
class TestPDFCalcObjcryst(unittest.TestCase):

@pytest.fixture(autouse=True)
def _check_periodictable(self, has_pyobjcryst, _msg_nopyobjcryst):
def _check_pyobjcryst(self, has_pyobjcryst, _msg_nopyobjcryst):
if not has_pyobjcryst:
pytest.skip(_msg_nopyobjcryst)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_sfaverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_fromComposition(self):
class TestSFAverageObjCryst(unittest.TestCase):

@pytest.fixture(autouse=True)
def _check_periodictable(self, has_pyobjcryst, _msg_nopyobjcryst):
def _check_pyobjcryst(self, has_pyobjcryst, _msg_nopyobjcryst):
if not has_pyobjcryst:
pytest.skip(_msg_nopyobjcryst)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_structureadapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def test_nosymmetry_pickling(self):
class TestPyObjCrystAdapter(unittest.TestCase):

@pytest.fixture(autouse=True)
def _check_periodictable(self, has_pyobjcryst, _msg_nopyobjcryst):
def _check_pyobjcryst(self, has_pyobjcryst, _msg_nopyobjcryst):
if not has_pyobjcryst:
pytest.skip(_msg_nopyobjcryst)

Expand Down
4 changes: 2 additions & 2 deletions tests/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ def datafile(filename):


def loadObjCrystCrystal(filename):
from pyobjcryst import loadCrystal
from pyobjcryst.crystal import create_crystal_from_cif

fullpath = datafile(filename)
crst = loadCrystal(fullpath)
crst = create_crystal_from_cif(fullpath)
return crst


Expand Down
Loading