diff --git a/.codecov.yml b/.codecov.yml index 86671410..04dd6510 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -1,2 +1,34 @@ -fixes: - - ".*/site-packages/::src/" +# codecov can find this file anywhere in the repo, so we don't need to clutter +# the root folder. +#comment: false + +codecov: + notify: + require_ci_to_pass: no + +coverage: + status: + patch: + default: + target: '70' + if_no_uploads: error + if_not_found: success + if_ci_failed: failure + project: + default: false + library: + target: auto + if_no_uploads: error + if_not_found: success + if_ci_failed: error + paths: '!*/tests/.*' + + tests: + target: 97.9% + paths: '*/tests/.*' + if_not_found: success + +flags: + tests: + paths: + - tests/ diff --git a/.coveragerc b/.coveragerc index 63f0ec9c..77556cdf 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,22 +1,13 @@ -# Configuration of the coverage.py tool for reporting test coverage. - -[report] -# 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() - if __name__ == .__main__.: - - [run] +source = + diffpy.pdfgui +[report] omit = - # exclude debug.py from codecov report - */tests/debug.py + */python?.?/* + */site-packages/nose/* + # ignore _version.py and versioneer.py + .*version.* + *_version.py + +exclude_lines = + if __name__ == '__main__': diff --git a/.gitattributes b/.gitattributes index 9d58a8cd..0caa8f9f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,7 +1 @@ -/.gitattributes export-ignore -/.gitignore export-ignore -/.travis.yml export-ignore -/conda-recipe/ export-ignore -/devutils export-ignore -.gitarchive.cfg export-subst -*.bat text eol=crlf +diffpy.pdfgui/_version.py export-subst diff --git a/.gitignore b/.gitignore index b1f18e26..a25212ea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,44 +1,99 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ *.py[cod] +*$py.class # C extensions *.so -# Packages -*.egg -*.egg-info -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 -.idea + +# 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 +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 /src/diffpy/*/version.cfg + +# Rever +rever/ diff --git a/CHANGELOG.rst b/CHANGELOG.rst index fc5d6241..4280491e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,6 @@ -========================= -Diffpy.pdfgui Change Log -========================= +============= +Release Notes +============= .. current developments diff --git a/README.rst b/README.rst index bb30e2e4..809d4f3c 100644 --- a/README.rst +++ b/README.rst @@ -1,11 +1,41 @@ -.. image:: https://travis-ci.org/diffpy/diffpy.pdfgui.svg?branch=master - :target: https://travis-ci.org/diffpy/diffpy.pdfgui +|Icon| |title|_ +=============== -.. image:: https://codecov.io/gh/diffpy/diffpy.pdfgui/branch/master/graph/badge.svg - :target: https://codecov.io/gh/diffpy/diffpy.pdfgui +.. |title| replace:: diffpy.pdfgui +.. _title: https://diffpy.github.io/diffpy.pdfgui +.. |Icon| image:: https://avatars.githubusercontent.com/diffpy + :target: https://diffpy.github.io/diffpy.pdfgui + :height: 100px -PDFgui +|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/diffpy.pdfgui/actions/workflows/main.yml/badge.svg + :target: https://github.com/diffpy/diffpy.pdfgui/actions/workflows/main.yml + +.. |Codecov| image:: https://codecov.io/gh/diffpy/diffpy.pdfgui/branch/main/graph/badge.svg + :target: https://codecov.io/gh/diffpy/diffpy.pdfgui + +.. |Forge| image:: https://img.shields.io/conda/vn/conda-forge/diffpy.pdfgui + :target: https://anaconda.org/conda-forge/diffpy.pdfgui + +.. |PR| image:: https://img.shields.io/badge/PR-Welcome-29ab47ff + +.. |PyPi| image:: https://img.shields.io/pypi/v/diffpy.pdfgui + :target: https://pypi.org/project/diffpy.pdfgui/ + +.. |PythonVersion| image:: https://img.shields.io/pypi/pyversions/diffpy.pdfgui + :target: https://pypi.org/project/diffpy.pdfgui/ + +.. |Tracking| image:: https://img.shields.io/badge/issue_tracking-github-blue + :target: https://github.com/diffpy/diffpy.pdfgui/issues + +diffpy.pdfgui ======================================================================== Graphical user interface program for structure refinements to atomic @@ -43,101 +73,76 @@ possible for it to read .ddp files that were saved by the Python2 PDFgui but it will sometimes fail to read these. We are working on a solution that will be available in a future version. -INSTALLATION ------------------------------------------------------------------------- - -The preferred method is to use Anaconda Python and install from the -"conda-forge" channel of Anaconda packages. `pdfgui` can be installed with `conda` :: - - conda install -c conda-forge diffpy.pdfgui - -PDFgui can be then started from a terminal ("Anaconda Prompt" on -Windows) by executing the "pdfgui" program. An alternative -method on Windows is to start PDFgui through the DiffPy start menu. - -If you don't use Anaconda or prefer to install from sources, make -sure the required software is all in place :: + diffpy.pdfgui Package, https://github.com/diffpy/diffpy.pdfgui - conda install -c conda-forge diffpy.utils diffpy.pdffit2 matplotlib wxpython +Installation +------------ -Then you are ready to install diffpy.pdfgui from source codes:: +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. - python setup.py install +To add "conda-forge" to the conda channels, run the following in a terminal. :: -By default the files are installed to standard system directories, -which may require the use of ``sudo`` for write privileges. If -administrator (root) access is not available, see the output from -``python setup.py install --help`` for options to install as a regular -user to user-writable locations. Note that installation to non-standard -directories may require adjustments to the PATH and PYTHONPATH -environment variables. The installation integrity can be verified by -changing to the HOME directory and running :: + conda config --add channels conda-forge - python -m diffpy.pdfgui.tests.rundeps +We want to install our packages in a suitable conda environment. +The following creates and activates a new environment named ``diffpy.pdfgui_env`` :: -To use PDFgui, you can simply type `pdfgui`, or run the following command :: + conda create -n diffpy.pdfgui_env python=3 + conda activate diffpy.pdfgui_env - python diffpy.pdfgui/src/diffpy/pdfgui/application/pdfgui.py +Then, to fully install ``diffpy.pdfgui`` in our active environment, run :: -If it shows some error like "This program needs access to the screen.". For Mac, you could install `python.app` from conda -(`conda install python.app`), then run as follows :: + conda install diffpy.pdfgui - python.app diffpy.pdfgui/src/diffpy/pdfgui/application/pdfgui.py +Another option is to use ``pip`` to download and install the latest release from +`Python Package Index <https://pypi.python.org>`_. +To install using ``pip`` into your ``diffpy.pdfgui_env`` environment, we will also have to install dependencies :: -With Anaconda PDFgui can be later upgraded to the latest released -version using :: + pip install -r https://raw.githubusercontent.com/diffpy/diffpy.pdfgui/main/requirements/run.txt - conda update -c conda-forge diffpy.pdfgui +and then install the package :: -With other Python distributions the program can be upgraded to -the latest version as follows :: + pip install diffpy.pdfgui - easy_install --upgrade diffpy.pdfgui +If you prefer to install from sources, after installing the dependencies, obtain the source archive from +`GitHub <https://github.com/diffpy/diffpy.pdfgui/>`_. Once installed, ``cd`` into your ``diffpy.pdfgui`` directory +and run the following :: -If you would like to use other Python distributions except Anaconda, -it is necessary to install the required software separately. As an -example, on Ubuntu Linux some of the required software can be -installed using :: + pip install . - sudo apt-get install \ - python-setuptools python-wxtools python-numpy \ - python-matplotlib +Support and Contribute +---------------------- -To install the remaining packages see the installation instructions -at their respective web pages. +`Diffpy user group <https://groups.google.com/g/diffpy-users>`_ is the discussion forum for general questions and discussions about the use of diffpy.pdfgui. Please join the diffpy.pdfgui users community by joining the Google group. The diffpy.pdfgui project welcomes your expertise and enthusiasm! -Other software -```````````````````````````````````````````````````````````````````````` +If you see a bug or want to request a feature, please `report it as an issue <https://github.com/diffpy/diffpy.pdfgui/issues>`_ and/or `submit a fix as a PR <https://github.com/diffpy/diffpy.pdfgui/pulls>`_. You can also post it to the `Diffpy user group <https://groups.google.com/g/diffpy-users>`_. -PDFgui can use an external structure viewer for displaying analyzed -structures. We have tested with several structure viewers such as +Feel free to fork the project and contribute. To install diffpy.pdfgui +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 :: -* AtomEye, http://li.mit.edu/A/Graphics/A/ -* PyMol, https://www.pymol.org -* VESTA, http://jp-minerals.org/vesta/en/ + pip install -e . -Other viewers should work as well, as long as they understand one of -the output structure formats supported by PDFgui. +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``. -DEVELOPMENT ------------------------------------------------------------------------- - -PDFgui is an open-source software available in a git repository at -https://github.com/diffpy/diffpy.pdfgui. - -Feel free to fork the project and contribute. To install PDFgui -in a development mode where the source files are used directly -rather than copied to a system directory, use :: +2. Initialize pre-commit (one time only) ``pre-commit install``. - python setup.py develop --user +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. +Improvements and fixes are always appreciated. -CONTACTS ------------------------------------------------------------------------- - -For more information on PDFgui please visit the project web-page: +Before contribuing, please read our `Code of Conduct <https://github.com/diffpy/diffpy.pdfgui/blob/main/CODE_OF_CONDUCT.rst>`_. -https://www.diffpy.org/products/pdfgui.html +Contact +------- -or email Prof. Simon Billinge at sb2896@columbia.edu +For more information on diffpy.pdfgui please visit the project `web-page <https://diffpy.github.io/>`_ or email Prof. Simon Billinge at sb2896@columbia.edu. diff --git a/pyproject.toml b/pyproject.toml index e537e24a..273ea25e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,52 @@ +[build-system] +requires = ["setuptools>=62.0", "setuptools-git-versioning<2"] +build-backend = "setuptools.build_meta" + +[project] +name = "diffpy.pdfgui" +dynamic=['version'] +authors = [ + { name="Simon J.L. Billinge group", email="simon.billinge@gmail.com" }, +] +maintainers = [ + { name="Simon J.L. Billinge group", email="simon.billinge@gmail.com" }, +] +description = "GUI for PDF simulation and structure refinement." +keywords = ['PDF structure refinement GUI'] +readme = "README.rst" +requires-python = ">=3.10" +classifiers = [ + 'Development Status :: 5 - Production/Stable', + 'Environment :: Console', + 'Intended Audience :: Developers', + 'Intended Audience :: Science/Research', + 'License :: OSI Approved :: BSD License', + 'Operating System :: MacOS :: MacOS X', + 'Operating System :: Microsoft :: Windows', + 'Operating System :: POSIX', + 'Operating System :: Unix', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Topic :: Scientific/Engineering :: Physics', + 'Topic :: Scientific/Engineering :: Chemistry', +] + +[project.urls] +Homepage = "https://github.com/diffpy/diffpy.pdfgui/" +Issues = "https://github.com/diffpy/diffpy.pdfgui/issues/" + +[tool.setuptools-git-versioning] +enabled = true +template = "{tag}" +dev_template = "{tag}" +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.pdfgui.tests*"] # exclude packages matching these glob patterns (empty by default) +namespaces = false # to disable scanning PEP 420 namespaces (true by default) + [tool.black] line-length = 115 include = '\.pyi?$'