diff --git a/.codecov.yml b/.codecov.yml index 505809d2..04dd6510 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -2,9 +2,6 @@ # the root folder. #comment: false -fixes: - - ".*/site-packages/::src/" - codecov: notify: require_ci_to_pass: no diff --git a/.coveragerc b/.coveragerc index 13b71cd9..edd0c0ba 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,9 +1,6 @@ [run] source = diffpy.pdffit2 -omit = - # exclude debug.py from codecov report - */tests/debug.py [report] omit = */python?.?/* @@ -11,16 +8,6 @@ omit = # ignore _version.py and versioneer.py .*version.* *_version.py -# RE patterns for lines to be excluded from consideration. -exclude_lines = - # Have to re-enable the standard pragma - pragma: no cover - # Don't complain if tests don't hit defensive assertion code: - raise AssertionError - raise NotImplementedError - ^[ ]*assert False - # Don't complain if non-runnable code isn't run: - ^[ ]*@unittest.skip\b - ^[ ]{4}unittest.main() +exclude_lines = if __name__ == '__main__': diff --git a/.github/workflows/check-news-item.yml b/.github/workflows/check-news-item.yml new file mode 100644 index 00000000..6a842da5 --- /dev/null +++ b/.github/workflows/check-news-item.yml @@ -0,0 +1,12 @@ +name: Check for News + +on: + pull_request_target: + branches: + - main + +jobs: + build: + uses: Billingegroup/release-scripts/.github/workflows/_check-news-item.yml@v0 + with: + project: diffpy.pdffit2 diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml deleted file mode 100644 index b2b039f2..00000000 --- a/.github/workflows/codecov.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: Gather coverage report and upload to codecov - -on: - push: - branches: - - main - release: - types: - - prereleased - - published - workflow_dispatch: - -defaults: - run: - shell: bash -l {0} - -jobs: - coverage: - runs-on: ubuntu-latest - steps: - - name: Check out diffpy.pdffit2 - uses: actions/checkout@v4 - - - name: Initialize miniconda - uses: conda-incubator/setup-miniconda@v3 - with: - activate-environment: test - auto-update-conda: true - environment-file: environment.yml - auto-activate-base: false - - - name: Conda config - run: >- - conda config --set always_yes yes - --set changeps1 no - - - name: Install diffpy.pdffit2 and requirements - run: | - conda install --file requirements/run.txt - conda install --file requirements/test.txt - conda install --file requirements/build.txt - python -m pip install -r requirements/pip.txt - python -m pip install . --no-deps - - - name: Validate diffpy.pdffit2 - run: | - coverage run -m pytest -vv -s - coverage report -m - codecov - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index 89ff2948..00000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Build and Deploy Documentation - -on: - release: - types: - - published - workflow_dispatch: - -defaults: - run: - shell: bash -l {0} - -jobs: - docs: - runs-on: ubuntu-latest - steps: - - name: Check out diffpy.pdffit2 - uses: actions/checkout@v4 - - - name: Initialize miniconda - uses: conda-incubator/setup-miniconda@v3 - with: - activate-environment: build - auto-update-conda: true - environment-file: environment.yml - auto-activate-base: false - - - name: Conda config - run: >- - conda config --set always_yes yes - --set changeps1 no - - - name: Install diffpy.pdffit2 and build requirements - run: | - conda install --file requirements/build.txt - conda install --file requirements/run.txt - conda install --file requirements/docs.txt - python -m pip install -r requirements/pip.txt - python -m pip install . --no-deps - - - name: build documents - run: make -C doc html - - - name: Deploy - uses: peaceiris/actions-gh-pages@v4 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./doc/build/html diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 30f4e0a4..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Test - -on: - push: - branches: - - main - pull_request: - workflow_dispatch: - -defaults: - run: - shell: bash -l {0} - -jobs: - validate: - runs-on: ubuntu-latest - steps: - - name: Check out diffpy.pdffit2 - uses: actions/checkout@v4 - - - name: Initialize miniconda - uses: conda-incubator/setup-miniconda@v3 - with: - activate-environment: test - auto-update-conda: true - environment-file: environment.yml - auto-activate-base: false - - - name: Conda config - run: >- - conda config --set always_yes yes - --set changeps1 no - - - name: Install diffpy.pdffit2 and requirements - run: | - conda install --file requirements/run.txt - conda install --file requirements/test.txt - conda install --file requirements/build.txt - python -m pip install -r requirements/pip.txt - python -m pip install . --no-deps - - - name: Validate diffpy.pdffit2 - run: python -m pytest diff --git a/.github/workflows/matrix-and-codecov-on-merge-to-main.yml b/.github/workflows/matrix-and-codecov-on-merge-to-main.yml new file mode 100644 index 00000000..0270fdf4 --- /dev/null +++ b/.github/workflows/matrix-and-codecov-on-merge-to-main.yml @@ -0,0 +1,21 @@ +name: CI + +on: + push: + branches: + - main + release: + types: + - prereleased + - published + workflow_dispatch: + +jobs: + coverage: + uses: Billingegroup/release-scripts/.github/workflows/_matrix-and-codecov-on-merge-to-main.yml@v0 + with: + project: diffpy.pdffit2 + c_extension: true + headless: false + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/matrix.yml b/.github/workflows/matrix.yml deleted file mode 100644 index 3c8c0f0d..00000000 --- a/.github/workflows/matrix.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Matrix test - -on: - push: - branches: - - main - workflow_dispatch: - -defaults: - run: - shell: bash -l {0} - -jobs: - test: - name: Python ${{ matrix.python-version }}, OS ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - python-version: ['3.10', '3.11', '3.12'] - os: ["macos-latest", "ubuntu-latest", "windows-latest"] - steps: - - name: check out diffpy.pdffit2 - uses: actions/checkout@v4 - - - name: Initialize miniconda - uses: conda-incubator/setup-miniconda@v3 - with: - activate-environment: test - auto-update-conda: true - environment-file: environment.yml - python-version: ${{ matrix.python-version }} - auto-activate-base: false - - - name: Conda config - run: >- - conda config --set always_yes yes - --set changeps1 no - - - name: Install diffpy.pdffit2 and requirements - run: | - conda install --file requirements/run.txt - conda install --file requirements/test.txt - conda install --file requirements/build.txt - python -m pip install -r requirements/pip.txt - python -m pip install . --no-deps - - - name: Validate diffpy.pdffit2 - run: python -m pytest diff --git a/.github/workflows/publish-docs-on-release.yml b/.github/workflows/publish-docs-on-release.yml new file mode 100644 index 00000000..ea18f1f0 --- /dev/null +++ b/.github/workflows/publish-docs-on-release.yml @@ -0,0 +1,14 @@ +name: Build and Deploy Docs + +on: + release: + types: + - published + workflow_dispatch: + +jobs: + docs: + uses: Billingegroup/release-scripts/.github/workflows/_publish-docs-on-release.yml@v0 + with: + project: diffpy.pdffit2 + c_extension: true diff --git a/.github/workflows/tests-on-pr.yml b/.github/workflows/tests-on-pr.yml new file mode 100644 index 00000000..31ad817a --- /dev/null +++ b/.github/workflows/tests-on-pr.yml @@ -0,0 +1,16 @@ +name: Tests on PR + +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +jobs: + validate: + uses: Billingegroup/release-scripts/.github/workflows/_tests-on-pr.yml@v0 + with: + project: diffpy.pdffit2 + c_extension: true + headless: false diff --git a/.gitignore b/.gitignore index 3298c515..a25212ea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,49 +1,99 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ *.py[cod] +*$py.class # C extensions *.so -# Packages -*.egg -*.egg-info -*.eggs -dist -build -eggs -parts -bin -var -sdist -temp -develop-eggs +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +venv/ +*.egg-info/ .installed.cfg -lib -lib64 -tags +*.egg +bin/ +temp/ +tags/ errors.err -# IDE configs -.idea -.vscode +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec # Installer logs pip-log.txt +pip-delete-this-directory.txt MANIFEST # Unit test / coverage reports +htmlcov/ +.tox/ .coverage -.tox +.coverage.* +.cache nosetests.xml -/libpdffit2/tests/alltests +coverage.xml +*,cover +.hypothesis/ # Translations *.mo +*.pot # Mr Developer .mr.developer.cfg .project .pydevproject +# Django stuff: +*.log + +# Sphinx documentation +docs/build/ +docs/source/generated/ + +# pytest +.pytest_cache/ + +# PyBuilder +target/ + +# Editor files +# mac +.DS_Store +*~ + +# vim +*.swp +*.swo + +# pycharm +.idea/ + +# VSCode +.vscode/ + +# Ipython Notebook +.ipynb_checkpoints + # version information setup.cfg -/diffpy/pdffit2/version.cfg +/src/diffpy/*/version.cfg + +# Rever +rever/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8aedd156..c4588061 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,7 +14,6 @@ repos: rev: v4.6.0 hooks: - id: check-yaml - exclude: ^conda-recipe/meta\.yaml$ - id: end-of-file-fixer - id: trailing-whitespace exclude: '\.(rst|txt)$' @@ -30,8 +29,7 @@ repos: rev: 5.13.2 hooks: - id: isort - args: ["--profile", "black", "--order-by-type"] - exclude: ^src/diffpy/pdffit2/__init__\.py$ + args: ["--profile", "black"] - repo: https://github.com/kynan/nbstripout rev: 0.7.1 hooks: diff --git a/LICENSE.rst b/LICENSE.rst index 0a1d4f66..5862f0d6 100644 --- a/LICENSE.rst +++ b/LICENSE.rst @@ -8,7 +8,7 @@ If you use this program to do productive scientific research that leads to publication, we ask that you acknowledge use of the program by citing the following paper in your publication: - C\. L. Farrow, P. Juhás, J. W. Liu, D. Bryndin, E. S. Božin, J. Bloch, Th. Proffen + C. L. Farrow, P. Juhás, J. W. Liu, D. Bryndin, E. S. Božin, J. Bloch, Th. Proffen and S. J. L. Billinge, PDFfit2 and PDFgui: computer programs for studying nanostructure in crystals (https://stacks.iop.org/0953-8984/19/335219), *J. Phys.: Condens. Matter*, 19, 335219 (2007) diff --git a/Makefile b/Makefile deleted file mode 100644 index dffbb2ca..00000000 --- a/Makefile +++ /dev/null @@ -1,106 +0,0 @@ -######################################################################## -# This Makefile should be used only for debugging purposes and is -# intended for strong-hearted developers. End users should use the -# setup.py script instead. -# -# Variables: -# -# DEBUG when defined, compile with debug options -# USESHARED when defined, link with shared gsl library -# PYTHON_INCLUDE path to Python include files used for compilation -# -######################################################################## - -ifndef PYTHON_INCLUDE -PYTHON_INCLUDE := $(shell python -c \ - 'from distutils import sysconfig; print(sysconfig.get_python_inc())') -endif - -######################################################################## - -INCLUDE = \ - -I$(PYTHON_INCLUDE) \ - -Ilibpdffit2 \ - -Ipdffit2module \ - -Ibuild -I. \ - $(GSL_INCLUDE) - -GSL_INCLUDE = $(shell gsl-config --cflags) - -GSL_LIBS_CONFIG = $(shell gsl-config --libs-without-cblas) -ifdef USESHARED -GSL_LIBS = $(GSL_LIBS_CONFIG) -else -GSL_LIBS = $(subst -L,,$(filter -L%, $(GSL_LIBS_CONFIG)))/libgsl.a -endif - -ifneq (,$(findstring darwin,$(OSTYPE))) -LDFLAGS = -bundle -undefined dynamic_lookup -else -LDFLAGS = -shared -endif - -COMMONFLAGS = -std=c++11 -Wall -Wno-write-strings -fPIC -OPTIMFLAGS = -O3 -funroll-loops -ffast-math $(COMMONFLAGS) -DEBUGFLAGS = -g $(COMMONFLAGS) - -ifdef DEBUG -CPPFLAGS = $(DEBUGFLAGS) $(INCLUDE) $(DEFINES) -else -CPPFLAGS = $(OPTIMFLAGS) $(INCLUDE) $(DEFINES) -endif - -PYTHON_XY := $(shell python -c 'import sys; print(sys.version[:3])') -BDIR := build/$(PYTHON_XY) - -.PHONY: all module clean test - -all: module - -module: $(BDIR)/pdffit2module.so - @test $< -ef diffpy/pdffit2/pdffit2.so || \ - ln -vf $< diffpy/pdffit2/pdffit2.so - -clean: - rm -rf -- build/$(PYTHON_XY) diffpy/pdffit2/pdffit2.so - -test: module - python -m diffpy.pdffit2.tests.run - -OBJS = \ - $(BDIR)/bindings.o \ - $(BDIR)/misc.o \ - $(BDIR)/pdffit2module.o \ - $(BDIR)/pyexceptions.o \ - $(BDIR)/Atom.o \ - $(BDIR)/LocalPeriodicTable.o \ - $(BDIR)/OutputStreams.o \ - $(BDIR)/PeriodicTable.o \ - $(BDIR)/PointsInSphere.o \ - $(BDIR)/StringUtils.o \ - $(BDIR)/fit.o \ - $(BDIR)/gaussj.o \ - $(BDIR)/metric.o \ - $(BDIR)/nrutil.o \ - $(BDIR)/output.o \ - $(BDIR)/parser.o \ - $(BDIR)/pdf.o \ - $(BDIR)/pdffit.o \ - $(BDIR)/pdflsmin.o \ - $(BDIR)/scatlen.o \ - $(BDIR)/stru.o \ - - -$(BDIR): - mkdir -p $@ - -$(BDIR)/pdffit2module.so: $(BDIR) $(OBJS) - $(CXX) -o $@ $(LDFLAGS) $(OBJS) $(GSL_LIBS) - -$(BDIR)/%.o : libpdffit2/%.cc - $(CXX) -c $(CPPFLAGS) -o $@ $< - -$(BDIR)/%.o : pdffit2module/%.cc - $(CXX) -c $(CPPFLAGS) -o $@ $< - -# End of file diff --git a/README.rst b/README.rst index 702131a4..fa90b318 100644 --- a/README.rst +++ b/README.rst @@ -15,8 +15,8 @@ .. |Black| image:: https://img.shields.io/badge/code_style-black-black :target: https://github.com/psf/black -.. |CI| image:: https://github.com/diffpy/diffpy.pdffit2/actions/workflows/main.yml/badge.svg - :target: https://github.com/diffpy/diffpy.pdffit2/actions/workflows/main.yml +.. |CI| image:: https://github.com/diffpy/diffpy.pdffit2/actions/workflows/matrix-and-codecov-on-merge-to-main.yml/badge.svg + :target: https://github.com/diffpy/diffpy.pdffit2/actions/workflows/matrix-and-codecov-on-merge-to-main.yml .. |Codecov| image:: https://codecov.io/gh/diffpy/diffpy.pdffit2/branch/main/graph/badge.svg :target: https://codecov.io/gh/diffpy/diffpy.pdffit2 @@ -35,7 +35,7 @@ .. |Tracking| image:: https://img.shields.io/badge/issue_tracking-github-blue :target: https://github.com/diffpy/diffpy.pdffit2/issues -Real space structure refinement to atomic pair distribution function. +PDFfit2 - real space structure refinement to atomic pair distribution function The diffpy.pdffit2 package provides functions for calculation and refinement of atomic Pair Distribution Function (PDF) from crystal @@ -58,12 +58,14 @@ To learn more about diffpy.pdffit2 library, see the examples directory included in this distribution or the API documentation at http://www.diffpy.org/doc/pdffit2. +For more information about the diffpy.pdffit2 library, please consult our `online documentation `_. + Citation -------- If you use diffpy.pdffit2 in a scientific publication, we would like you to cite the following paper: - C\. L. Farrow, P. Juhás, J. W. Liu, D. Bryndin, E. S. Božin, J. Bloch, Th. Proffen + C. L. Farrow, P. Juhás, J. W. Liu, D. Bryndin, E. S. Božin, J. Bloch, Th. Proffen and S. J. L. Billinge, PDFfit2 and PDFgui: computer programs for studying nanostructure in crystals (https://stacks.iop.org/0953-8984/19/335219), *J. Phys.: Condens. Matter*, 19, 335219 (2007) @@ -100,22 +102,28 @@ Then, to fully install ``diffpy.pdffit2`` in our active environment, run :: conda install diffpy.pdffit2 -Another option is to use ``pip`` to download and install the latest release from -`Python Package Index `_. -To install using ``pip`` into your ``diffpy.pdffit2_env`` environment, we will also have to install dependencies :: +The less preferred approach is the install using ``pip`` to download and install the latest release from `Python Package Index `_. In this case you currently have to build the codes on your computer from the sources and you will have to have a C++ installer available. + +To install the C++ compiler and required dependencies in your ``diffpy.pdffit2_env`` environment, type :: - pip install -r https://raw.githubusercontent.com/diffpy/diffpy.pdffit2/main/requirements/run.txt + conda install \ + --file requirements/run.txt \ + --file requirements/build.txt -and then install the package :: +And then type :: pip install diffpy.pdffit2 -If you prefer to install from sources, after installing the dependencies, obtain the source archive from +If you prefer to install from sources, use the above ``conda install \ ..`` instruction to install the dependencies in ``run.txt`` and ``build.txt`` in ``diffpy.pdffit2_env`` , obtain the source archive from `GitHub `_. Once installed, ``cd`` into your ``diffpy.pdffit2`` directory and run the following :: pip install . +To confirm that the installation was successful, run the following in a terminal :: + + python -c "import diffpy.pdffit2; print(diffpy.pdffit2.__version__)" + Support and Contribute ---------------------- diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.txt similarity index 100% rename from conda-recipe/meta.yaml rename to conda-recipe/meta.txt diff --git a/doc/make.bat b/doc/make.bat index 2be83069..ac53d5bd 100644 --- a/doc/make.bat +++ b/doc/make.bat @@ -1,36 +1,36 @@ -@ECHO OFF - -pushd %~dp0 - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set SOURCEDIR=source -set BUILDDIR=build -set SPHINXPROJ=PackagingScientificPython - -if "%1" == "" goto help - -%SPHINXBUILD% >NUL 2>NUL -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.http://sphinx-doc.org/ - exit /b 1 -) - -%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% -goto end - -:help -%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% - -:end -popd +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build +set SPHINXPROJ=PackagingScientificPython + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% + +:end +popd diff --git a/doc/source/index.rst b/doc/source/index.rst index 3ff032fe..7ae9b3aa 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -50,14 +50,14 @@ https://github.com/diffpy/diffpy.pdffit2/graphs/contributors. Reference ========= -If you use this program for a scientific research that leads to publication, -we ask that you acknowledge use of the program by citing the following paper +If you use this program for a scientific research that leads to publication, +we ask that you acknowledge use of the program by citing the following paper in your publication: C. L. Farrow, P. Juhás, J. W. Liu, D. Bryndin, E. S. Božin, J. Bloch, Th. Proffen and S. J. L. Billinge, PDFfit2 and PDFgui: computer programs for studying nanostructure in crystals (https://stacks.iop.org/0953-8984/19/335219), *J. Phys.: Condens. Matter*, 19, 335219 (2007) - + ============ Installation ============ diff --git a/doc/source/license.rst b/doc/source/license.rst index 421a9ed7..38f918c6 100644 --- a/doc/source/license.rst +++ b/doc/source/license.rst @@ -2,4 +2,55 @@ .. index:: license -.. include:: ../../LICENSE.rst +License +####### + +This program is part of the DiffPy and DANSE open-source projects +and is available subject to the conditions and terms laid out below. + +If you use this program to do productive scientific research that leads +to publication, we ask that you acknowledge use of the program by citing +the following paper in your publication: + + C. L. Farrow, P. Juhás, J. W. Liu, D. Bryndin, E. S. Božin, J. Bloch, Th. Proffen + and S. J. L. Billinge, PDFfit2 and PDFgui: computer programs for studying nanostructure + in crystals (https://stacks.iop.org/0953-8984/19/335219), *J. Phys.: Condens. Matter*, 19, 335219 (2007) + +Copyright 2006-2007, Board of Trustees of Michigan State University, +Copyright 2008-2024, Board of Trustees of Columbia University in the +city of New York. (Copyright holder indicated in each source file). + +For more information please visit the project web-page: + http://www.diffpy.org/ +or email Prof. Simon Billinge at sb2896@columbia.edu + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER "AS IS". COPYRIGHT HOLDER +EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES AND CONDITIONS, EITHER +EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY, TITLE, FITNESS, ADEQUACY OR SUITABILITY +FOR A PARTICULAR PURPOSE, AND ANY WARRANTIES OF FREEDOM FROM +INFRINGEMENT OF ANY DOMESTIC OR FOREIGN PATENT, COPYRIGHTS, TRADE +SECRETS OR OTHER PROPRIETARY RIGHTS OF ANY PARTY. IN NO EVENT SHALL +COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE OR RELATING TO THIS AGREEMENT, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/environment.yml b/environment.yml index 5fb2f044..3979d3cb 100644 --- a/environment.yml +++ b/environment.yml @@ -2,6 +2,5 @@ name: diffpy.pdffit2 channels: - conda-forge dependencies: - - python>=3.10 + - python=3 - pip - - conda diff --git a/news/recut.rst b/news/recut.rst new file mode 100644 index 00000000..e006ae7b --- /dev/null +++ b/news/recut.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* Re-cookiecutter to group's package standard + +**Security:** + +* diff --git a/pyproject.toml b/pyproject.toml index 0ee80217..56742459 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,7 +45,7 @@ dirty_template = "{tag}" [tool.setuptools.packages.find] where = ["src"] # list of folders that contain the packages (["."] by default) include = ["*"] # package names should match these glob patterns (["*"] by default) -exclude = ["diffpy.pdffit2.tests*"] # exclude packages matching these glob patterns (empty by default) +exclude = [] # exclude packages matching these glob patterns (empty by default) namespaces = false # to disable scanning PEP 420 namespaces (true by default) [tool.setuptools.dynamic] diff --git a/requirements/test.txt b/requirements/test.txt index 6f9ccf84..a7277865 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -2,4 +2,5 @@ flake8 pytest codecov coverage +pytest-cov pytest-env diff --git a/src/diffpy/pdffit2/__init__.py b/src/diffpy/pdffit2/__init__.py index fe3fbce3..61af1f1d 100644 --- a/src/diffpy/pdffit2/__init__.py +++ b/src/diffpy/pdffit2/__init__.py @@ -17,13 +17,22 @@ """PDFfit2 - real space structure refinement program.""" -# package version +# WARNING: Do NOT remove the isort: off/on comments in this file. +# These tags are used to prevent isort from reordering imports in this file. +# __version__ must be initialized before importing C++ extensions. + +# isort: off +# Import the package version before C++ extensions are loaded. from diffpy.pdffit2.output import redirect_stdout -from diffpy.pdffit2.version import __version__, __date__ +from diffpy.pdffit2.version import __date__, __version__ + +# Import C++ related modules since the __version__ attribute is used. from diffpy.pdffit2.pdffit import PdfFit from diffpy.pdffit2.pdffit2 import is_element -# silence the pyflakes syntax checker +# isort: on + +# Ensure all necessary components are imported and initialized assert __version__ or True assert __date__ or True assert all((PdfFit, redirect_stdout, is_element)) diff --git a/tests/test_version.py b/tests/test_version.py new file mode 100644 index 00000000..e3ac3668 --- /dev/null +++ b/tests/test_version.py @@ -0,0 +1,10 @@ +"""Unit tests for __version__.py +""" + +import diffpy.pdffit2 + + +def test_package_version(): + """Ensure the package version is defined and not set to the initial placeholder.""" + assert hasattr(diffpy.pdffit2, "__version__") + assert diffpy.pdffit2.__version__ != "0.0.0"