Skip to content

Commit 0ae5d21

Browse files
committed
Fix pyobjcryst for windows with (c)python>=3.8. Fixes #33 .
Update doc, add pyproject.toml and add 'packaging' to requirement.
1 parent 55084bd commit 0ae5d21

File tree

8 files changed

+29
-15
lines changed

8 files changed

+29
-15
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Release notes
22

3+
## Version 2.2.6
4+
5+
### Fixes
6+
7+
- fix for windows and python>=3.8
8+
- Fix for matplotlib >=3.7.0 when removing hkl labels
9+
310
## Version 2.2.5
411

512
### Changes

README.rst

-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ INSTALLATION
1717
------------
1818
pyobjcryst is available for Python 3.7 (deprecated), and 3.8 to 3.11.
1919

20-
Note regarding windows: on conda-forge, pyobjcryst 2.2.3 is available
21-
for python3.7 only, and versions >=2.2.4 are available for python 3.8 and
22-
3.9 using a `pypy` environment rather than the regular cpython interpreter.
23-
2420
Using conda (recommended)
2521
^^^^^^^^^^^^^^^^^^^^^^^^^
2622

SConstruct

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def pyconfigvar(name):
5252

5353
# copy system environment variables related to compilation
5454
DefaultEnvironment(ENV=subdictionary(os.environ, '''
55-
PATH PYTHONPATH GIT_DIR
55+
PATH PYTHONPATH GIT_DIR HOMEPATH HOMEDRIVE
5656
CPATH CPLUS_INCLUDE_PATH LIBRARY_PATH LD_RUN_PATH
5757
LD_LIBRARY_PATH DYLD_LIBRARY_PATH DYLD_FALLBACK_LIBRARY_PATH
5858
MACOSX_DEPLOYMENT_TARGET LANG

pyproject.toml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# pyproject.toml
2+
[build-system]
3+
requires = ["setuptools", "numpy"]
4+
build-backend = "setuptools.build_meta"
5+
6+
[project]
7+
name = "pyobjcryst" # as it would appear on PyPI
8+
version = "2.2.6"

setup.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import platform
1717
from setuptools import setup
1818
from setuptools import Extension
19-
from numpy.distutils.misc_util import get_numpy_include_dirs
19+
import numpy as np
2020

2121
# Use this version when git data are not available as in a git zip archive.
2222
# Update when tagging a new release.
@@ -27,7 +27,7 @@
2727
'libraries': ['ObjCryst'],
2828
'extra_compile_args': ['-std=c++11', '-DBOOST_ERROR_CODE_HEADER_ONLY'],
2929
'extra_link_args': [],
30-
'include_dirs': get_numpy_include_dirs(),
30+
'include_dirs': [np.get_include()],
3131
'library_dirs': []
3232
}
3333
if platform.system() == 'Windows':
@@ -36,6 +36,7 @@
3636
ext_kws['include_dirs'] += [pjoin(os.environ['CONDA_PREFIX'], 'include'),
3737
pjoin(os.environ['CONDA_PREFIX'], 'Library', 'include')]
3838
ext_kws['library_dirs'] += [pjoin(os.environ['CONDA_PREFIX'], 'Library', 'lib'),
39+
pjoin(os.environ['CONDA_PREFIX'], 'Library', 'bin'),
3940
pjoin(os.environ['CONDA_PREFIX'], 'libs')]
4041
ext_kws['libraries'] = ['libObjCryst']
4142
elif platform.system() == 'Darwin':
@@ -168,7 +169,7 @@ def getversioncfg():
168169
url="https://github.com/diffpy/pyobjcryst",
169170

170171
# Required python packages
171-
install_requires=['numpy'],
172+
install_requires=['numpy', 'packaging'],
172173
extras_require={'gui': ['ipywidgets', 'jupyter', 'matplotlib', 'ipympl', 'py3dmol'],
173174
'doc': ['sphinx', 'm2r2', 'sphinx_py3doc_enhanced_theme',
174175
'nbsphinx', 'nbsphinx-link']},

src/extensions/SConscript

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1+
import numpy as np
12
Import('env', 'pyoutput')
23

34
# make sure numpy headers are available
4-
npdirs = pyoutput(
5-
'from numpy.distutils.misc_util import get_numpy_include_dirs\n'
6-
'print("\\n".join(get_numpy_include_dirs()))')
7-
npdirs = [d.strip() for d in npdirs.split('\n')]
8-
env.AppendUnique(CPPPATH=npdirs)
5+
env.AppendUnique(CPPPATH=[np.get_include()])
96

107
# configure the boost_python library, which may have different extensions
118
if not (GetOption('clean') or env.GetOption('help')):

src/extensions/SConscript.configure

+5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import platform
2+
from os.path import join as pjoin
23
Import('env', 'pyconfigvar', 'pyversion')
34

45
# Helper functions -----------------------------------------------------------
56

7+
env.Append(LIBPATH=pjoin(env['prefix'], 'Library', 'bin'))
8+
env.Append(LIBPATH=pjoin(env['prefix'], 'Library', 'lib'))
9+
env.Append(CPPPATH=[pjoin(env['prefix'], 'include')])
10+
env.Append(CPPPATH=[pjoin(env['prefix'], 'Library', 'include')])
611

712
def CheckOptimizerFlag(context, flag):
813
ccflags_save = context.env['CCFLAGS']

src/extensions/registerconverters.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,7 @@ void _deleteMAV(MolAtomVec& mav, size_t i)
224224

225225
/* Exception translation */
226226

227-
PyObject* pyobjcryst_ObjCrystException =
228-
PyErr_NewException((char*)"pyobjcryst.ObjCrystException", 0, 0);
227+
PyObject* pyobjcryst_ObjCrystException;
229228

230229

231230
void translateException(const ObjCrystException& e)
@@ -277,6 +276,7 @@ void wrap_registerconverters()
277276
{
278277

279278
/* Exceptions */
279+
pyobjcryst_ObjCrystException = PyErr_NewException((char*)"pyobjcryst.ObjCrystException", 0, 0);
280280
register_exception_translator<ObjCrystException>(translateException);
281281
// We want silent exceptions
282282
ObjCrystException::verbose = false;

0 commit comments

Comments
 (0)