Skip to content

Commit

Permalink
Fix pyobjcryst for windows with (c)python>=3.8. Fixes #33 .
Browse files Browse the repository at this point in the history
Update doc, add pyproject.toml and add 'packaging' to requirement.
  • Loading branch information
vincefn committed Mar 13, 2023
1 parent 55084bd commit 0ae5d21
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 15 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Release notes

## Version 2.2.6

### Fixes

- fix for windows and python>=3.8
- Fix for matplotlib >=3.7.0 when removing hkl labels

## Version 2.2.5

### Changes
Expand Down
4 changes: 0 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ INSTALLATION
------------
pyobjcryst is available for Python 3.7 (deprecated), and 3.8 to 3.11.

Note regarding windows: on conda-forge, pyobjcryst 2.2.3 is available
for python3.7 only, and versions >=2.2.4 are available for python 3.8 and
3.9 using a `pypy` environment rather than the regular cpython interpreter.

Using conda (recommended)
^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def pyconfigvar(name):

# copy system environment variables related to compilation
DefaultEnvironment(ENV=subdictionary(os.environ, '''
PATH PYTHONPATH GIT_DIR
PATH PYTHONPATH GIT_DIR HOMEPATH HOMEDRIVE
CPATH CPLUS_INCLUDE_PATH LIBRARY_PATH LD_RUN_PATH
LD_LIBRARY_PATH DYLD_LIBRARY_PATH DYLD_FALLBACK_LIBRARY_PATH
MACOSX_DEPLOYMENT_TARGET LANG
Expand Down
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# pyproject.toml
[build-system]
requires = ["setuptools", "numpy"]
build-backend = "setuptools.build_meta"

[project]
name = "pyobjcryst" # as it would appear on PyPI
version = "2.2.6"
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import platform
from setuptools import setup
from setuptools import Extension
from numpy.distutils.misc_util import get_numpy_include_dirs
import numpy as np

# Use this version when git data are not available as in a git zip archive.
# Update when tagging a new release.
Expand All @@ -27,7 +27,7 @@
'libraries': ['ObjCryst'],
'extra_compile_args': ['-std=c++11', '-DBOOST_ERROR_CODE_HEADER_ONLY'],
'extra_link_args': [],
'include_dirs': get_numpy_include_dirs(),
'include_dirs': [np.get_include()],
'library_dirs': []
}
if platform.system() == 'Windows':
Expand All @@ -36,6 +36,7 @@
ext_kws['include_dirs'] += [pjoin(os.environ['CONDA_PREFIX'], 'include'),
pjoin(os.environ['CONDA_PREFIX'], 'Library', 'include')]
ext_kws['library_dirs'] += [pjoin(os.environ['CONDA_PREFIX'], 'Library', 'lib'),
pjoin(os.environ['CONDA_PREFIX'], 'Library', 'bin'),
pjoin(os.environ['CONDA_PREFIX'], 'libs')]
ext_kws['libraries'] = ['libObjCryst']
elif platform.system() == 'Darwin':
Expand Down Expand Up @@ -168,7 +169,7 @@ def getversioncfg():
url="https://github.com/diffpy/pyobjcryst",

# Required python packages
install_requires=['numpy'],
install_requires=['numpy', 'packaging'],
extras_require={'gui': ['ipywidgets', 'jupyter', 'matplotlib', 'ipympl', 'py3dmol'],
'doc': ['sphinx', 'm2r2', 'sphinx_py3doc_enhanced_theme',
'nbsphinx', 'nbsphinx-link']},
Expand Down
7 changes: 2 additions & 5 deletions src/extensions/SConscript
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import numpy as np
Import('env', 'pyoutput')

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

# configure the boost_python library, which may have different extensions
if not (GetOption('clean') or env.GetOption('help')):
Expand Down
5 changes: 5 additions & 0 deletions src/extensions/SConscript.configure
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import platform
from os.path import join as pjoin
Import('env', 'pyconfigvar', 'pyversion')

# Helper functions -----------------------------------------------------------

env.Append(LIBPATH=pjoin(env['prefix'], 'Library', 'bin'))
env.Append(LIBPATH=pjoin(env['prefix'], 'Library', 'lib'))
env.Append(CPPPATH=[pjoin(env['prefix'], 'include')])
env.Append(CPPPATH=[pjoin(env['prefix'], 'Library', 'include')])

def CheckOptimizerFlag(context, flag):
ccflags_save = context.env['CCFLAGS']
Expand Down
4 changes: 2 additions & 2 deletions src/extensions/registerconverters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,7 @@ void _deleteMAV(MolAtomVec& mav, size_t i)

/* Exception translation */

PyObject* pyobjcryst_ObjCrystException =
PyErr_NewException((char*)"pyobjcryst.ObjCrystException", 0, 0);
PyObject* pyobjcryst_ObjCrystException;


void translateException(const ObjCrystException& e)
Expand Down Expand Up @@ -277,6 +276,7 @@ void wrap_registerconverters()
{

/* Exceptions */
pyobjcryst_ObjCrystException = PyErr_NewException((char*)"pyobjcryst.ObjCrystException", 0, 0);
register_exception_translator<ObjCrystException>(translateException);
// We want silent exceptions
ObjCrystException::verbose = false;
Expand Down

0 comments on commit 0ae5d21

Please sign in to comment.