Metadata-Version: 2.1
Name: pyobjcryst
Version: 2026.2.0rc1
Summary: Python bindings to the ObjCryst++ library.
Keywords: objcryst,atom structure crystallography,powder diffraction
Author: Christopher Farrow, Pavol Juhás
Author-Email: Vincent-Favre-Nicolin <favre@esrf.fr>
Maintainer-Email: Simon Billinge <sbillinge@ucsb.edu>, Vincent-Favre-Nicolin <favre@esrf.fr>
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX
Classifier: Operating System :: Unix
Classifier: Programming Language :: C++
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Topic :: Scientific/Engineering :: Chemistry
Classifier: Topic :: Software Development :: Libraries
Project-URL: Homepage, https://github.com/diffpy/pyobjcryst/
Project-URL: Issues, https://github.com/diffpy/pyobjcryst/issues/
Requires-Python: <3.16,>=3.12
Requires-Dist: numpy
Requires-Dist: packaging
Description-Content-Type: text/x-rst

|Icon| |title|_
===============

.. |title| replace:: pyobjcryst
.. _title: https://diffpy.github.io/pyobjcryst

.. |Icon| image:: https://avatars.githubusercontent.com/diffpy
        :target: https://diffpy.github.io/pyobjcryst
        :height: 100px

|PyPI| |Forge| |PythonVersion| |PR|

|CI| |Codecov| |Black| |Tracking|

.. |Black| image:: https://img.shields.io/badge/code_style-black-black
        :target: https://github.com/psf/black

.. |CI| image:: https://github.com/diffpy/pyobjcryst/actions/workflows/matrix-and-codecov.yml/badge.svg
        :target: https://github.com/diffpy/pyobjcryst/actions/workflows/matrix-and-codecov.yml

.. |Codecov| image:: https://codecov.io/gh/diffpy/pyobjcryst/branch/main/graph/badge.svg
        :target: https://codecov.io/gh/diffpy/pyobjcryst

.. |Forge| image:: https://img.shields.io/conda/vn/conda-forge/pyobjcryst
        :target: https://anaconda.org/conda-forge/pyobjcryst

.. |PR| image:: https://img.shields.io/badge/PR-Welcome-29ab47ff
        :target: https://github.com/diffpy/pyobjcryst/pulls

.. |PyPI| image:: https://img.shields.io/pypi/v/pyobjcryst
        :target: https://pypi.org/project/pyobjcryst/

.. |PythonVersion| image:: https://img.shields.io/pypi/pyversions/pyobjcryst
        :target: https://pypi.org/project/pyobjcryst/

.. |Tracking| image:: https://img.shields.io/badge/issue_tracking-github-blue
        :target: https://github.com/diffpy/pyobjcryst/issues

Python bindings to ObjCryst++, the Object-Oriented Crystallographic Library.

For more information about the pyobjcryst library, please consult our `online documentation <https://diffpy.github.io/pyobjcryst>`_.

``pyobjcryst`` is an open-source software package originally developed as a part of the DiffPy-CMI
complex modeling initiative which originated in the DANSE project
at Columbia University. It was further developed at Brookhaven National Laboratory,
and Columbia University and the European Synchrotron Radiation Source (ESRF) and is now
maintained at University of California, Santa Barbara and ESRF.
The pyobjcryst sources are hosted at https://github.com/diffpy/pyobjcryst.

Citation
--------

If you use diffpy.srfit in a scientific publication, we would like you to cite this package as


   P. Juhás, C. L. Farrow, X. Yang, K. R. Knox and S. J. L. Billinge,
   `Complex modeling: a strategy and software program for combining
   multiple information sources to solve ill posed structure and
   nanostructure inverse problems
   <http://dx.doi.org/10.1107/S2053273315014473>`__,
   *Acta Crystallogr. A* **71**, 562-568 (2015).

and

   V. Favre-Nicolin and R. Cerný,
   `FOX, 'free objects for crystallography': a modular approach to
   ab initio structure determination from powder diffraction
   <https://doi.org/10.1107/S0021889802015236>`__,
   *J. Appl. Cryst.*  **35**, 734-743 (2002)

The second paper describes the c++ crystallographic objects in
``ObjCryst++`` that are wrapped by ``pyobjcryst``

Installation
------------

The latest release of ``pyobjcryst`` runs in python versions 3.12, 3.13, 3.14 and 3.15. You may
specify an earlier release if you need it to run in an earlier version of Python.

The preferred method is to use `Miniconda Python
<https://docs.conda.io/projects/miniconda/en/latest/miniconda-install.html>`_
and install from the "conda-forge" channel of Conda packages.

To permanently add "conda-forge" to the conda channels (recommended), run the following in a terminal. ::

        conda config --add channels conda-forge

We want to install our packages in a suitable conda environment.
The following creates and activates a new environment named ``pyobjcryst-env`` ::

        conda create -n pyobjcryst-env pyobjcryst
        conda activate pyobjcryst-env

To confirm that the installation was successful, type ::

        python -c "import pyobjcryst; print(pyobjcryst.__version__)"

The output should print the latest version displayed on the badges above.

pyobjcryst is also included in the ``diffpy.cmi`` collection of packages for
structure analysis and so can be installed by ::

        conda install -c conda-forge diffpy.cmi

and following the instructions in the `diffpy.cmi documentation <https://www.diffpy.org/diffpy.cmi/>`_ to install packs containing pyobjcryst
and its libraries.

Optional graphical dependencies for jupyter notebooks
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Some of the classes can produce graphical outputs, which can be
displayed in a jupyter notebook:

* a Crystal structure can be displayed in 3D: this requires the
  ``py3dmol`` and ``ipywidgets`` modules. See the notebook
  ``docs/examples/cystal_3d_widget.ipynb``
* a PowderPattern can be displayed (and live-updated) if
  ``matplotlib`` and ``ipympl`` are installed. See the
  notebook ``docs/examples/structure-solution-powder-cimetidine.ipynb``

Getting Started
---------------

You may consult our `online documentation <https://diffpy.github.io/pyobjcryst>`_ for tutorials and API references.

Alternative methods of installation
-----------------------------------

These approaches are not recommended but reproduced here for advanced users.
You can use ``pip`` to download and install the latest release from
`Python Package Index <https://pypi.python.org>`_. The PyPI wheels are
self-contained (ObjCryst++, cctbx and newmat are built in), so no compiler
or conda libraries are needed ::

        pip install pyobjcryst

The optional graphical dependencies can be installed with ::

        pip install ipywidgets matplotlib ipympl py3dmol

To build from source, a C++ compiler is required; CMake, nanobind and the
Boost headers are fetched automatically by ``pip``. ObjCryst++ is included
as a git submodule, so clone with ``--recursive`` (or run
``git submodule update --init`` in an existing clone) ::

        git clone --recursive https://github.com/diffpy/pyobjcryst.git
        cd pyobjcryst
        pip install .

Outside a conda environment, e.g. on Ubuntu Linux, the compiler and Boost
headers can be installed using ::

        sudo apt-get install build-essential python3-dev python3-pip libboost-dev

Boost headers can also be installed from conda-forge (``libboost-headers``),
or their location given explicitly with
``pip install . -Ccmake.define.BOOST_INCLUDE_DIR=<path>``.

Testing your installation
-------------------------

The installation integrity can be verified by executing the included tests.

First install test dependencies then type pytest::

        conda install --file requirements/tests.txt
        pytest


Support and Contribute
----------------------

If you see a bug or want to request a feature, please `report it as an issue <https://github.com/diffpy/pyobjcryst/issues>`_ and/or `submit a fix as a PR <https://github.com/diffpy/pyobjcryst/pulls>`_.

Feel free to fork the project and contribute. To install pyobjcryst
in a development mode, with its sources being directly used by Python
rather than copied to a package directory, use the following in the root
directory ::

        pip install -e .

To ensure code quality and to prevent accidental commits into the default branch, please set up the use of our pre-commit
hooks.

1. Install pre-commit in your working environment by running ``conda install pre-commit``.

2. Initialize pre-commit (one time only) ``pre-commit install``.

Thereafter your code will be linted by black and isort and checked against flake8 before you can commit.
If it fails by black or isort, just rerun and it should pass (black and isort will modify the files so should
pass after they are modified). If the flake8 test fails please see the error messages and fix them manually before
trying to commit again.

When developing it is preferable to compile the extension module with
debug information and C-assertions checks ::

        pip install -e . -Ccmake.build-type=Debug

Improvements and fixes are always appreciated.

Before contributing, please read our `Code of Conduct <https://github.com/diffpy/pyobjcryst/blob/main/CODE-OF-CONDUCT.rst>`_.

Contact
-------

For more information on pyobjcryst please visit the project `web-page <https://diffpy.github.io/>`_ or email Simon Billinge at sbillinge@ucsb.edu.

You can also contact Vincent Favre-Nicolin (favre@esrf.fr) if you are using pyobjcryst outside diffpy, e.g. to display structures in a notebook, refine powder patterns or solve structures using the global optimisation algorithms, etc..

Acknowledgements
----------------

This package bundles the following IUCr data files for bona fide research use:

- **cpd-1a.prn:** Powder diffraction dataset from the `IUCr CPD Round Robin on Quantitative Phase Analysis <https://www.iucr.org/__data/iucr/powder/QARR/index.html>`_.

  Source: https://www.iucr.org/__data/iucr/powder/QARR/col/cpd-1a.prn

  Round Robin on Quantitative Phase Analysis: Madsen, I. (1997) ‘Round Robin on Quantitative Phase Analysis’, Powder Diffraction, 12(1), pp. 1–2. Available at: https://doi.org/10.1017/S0885715600020212.


``pyobjcryst`` is built and maintained with `scikit-package <https://scikit-package.github.io/scikit-package/>`_.
