diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e3ade008..c26194af 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,31 +23,42 @@ jobs: path: . fetch-depth: 0 # avoid shallow clone with no tags - - name: Install Mamba - run: | - wget "https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh" -O mambaforge.sh - bash mambaforge.sh -b -p $HOME/mambaforge - echo "$HOME/mambaforge/bin" >> $GITHUB_PATH - source $HOME/mambaforge/etc/profile.d/conda.sh - conda init bash + - name: initialize miniconda + # this uses a marketplace action that sets up miniconda in a way that makes + # it easier to use. I tried setting it up without this and it was a pain + uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: test + # environment.yml file is needed by this action. Because I don't want + # maintain this but rather maintain the requirements files it just has + # basic things in it like conda and pip + environment-file: ./environment.yml + python-version: 3 + auto-activate-base: false - - name: Create conda environment + - name: install diffpy.pdfgui requirements + shell: bash -l {0} run: | - source $HOME/mambaforge/etc/profile.d/conda.sh - conda create -n test_env python=3.12 xonsh regolith -c conda-forge -y - conda activate test_env - pip install case_insensitive_dict + conda config --set always_yes yes --set changeps1 no + conda config --add channels conda-forge + conda activate test + conda install --file requirements/run.txt + conda install --file requirements/test.txt + pip install . + + - name: Install Xvfb + run: sudo apt-get install -y xvfb - - name: Install dependencies + - name: Start Xvfb run: | - source $HOME/mambaforge/etc/profile.d/conda.sh - conda activate test_env - mamba install --file requirements/run.txt - mamba install --file requirements/test.txt - pip install -e . + export DISPLAY=:99 + Xvfb :99 -screen 0 1024x768x16 & - - name: Use Xvfb Action - uses: GabrielBB/xvfb-action@v1 - with: - run: | - bash -c "source $HOME/mambaforge/etc/profile.d/conda.sh && conda activate test_env && python -m run_tests.py" + - name: Validate diffpy.pdfgui + shell: bash -l {0} + run: | + export DISPLAY=:99 + conda activate test + coverage run -m pytest -vv -s + coverage report -m + codecov diff --git a/run_tests.py b/run_tests.py deleted file mode 100644 index a2a69494..00000000 --- a/run_tests.py +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env python - -import diffpy.pdfgui.tests - -assert diffpy.pdfgui.tests.testdeps().wasSuccessful() diff --git a/setup.py b/setup.py deleted file mode 100755 index 1738fd08..00000000 --- a/setup.py +++ /dev/null @@ -1,161 +0,0 @@ -#!/usr/bin/env python - -# Installation script for diffpy.pdfgui - -"""PDFgui - graphical user interface for real space structure refinement. - -Packages: diffpy.pdfgui -Scripts: pdfgui -""" - -import os -import re -import sys - -from setuptools import find_packages, setup - -# Use this version when git data are not available, like in git zip archive. -# Update when tagging a new release. -FALLBACK_VERSION = "2.0.4" - -# determine if we run with Python 3. -PY3 = sys.version_info[0] == 3 - -# versioncfgfile holds version data for git commit hash and date. -# It must reside in the same directory as version.py. -MYDIR = os.path.dirname(os.path.abspath(__file__)) -versioncfgfile = os.path.join(MYDIR, "src/diffpy/pdfgui/version.cfg") -gitarchivecfgfile = os.path.join(MYDIR, ".gitarchive.cfg") - - -def gitinfo(): - from subprocess import PIPE, Popen - - kw = dict(stdout=PIPE, cwd=MYDIR, universal_newlines=True) - proc = Popen(["git", "describe", "--tags", "--match=v[[:digit:]]*"], **kw) - desc = proc.stdout.read() - proc = Popen(["git", "log", "-1", "--format=%H %ct %ci"], **kw) - glog = proc.stdout.read() - rv = {} - rv["version"] = ".post".join(desc.strip().split("-")[:2]).lstrip("v") - rv["commit"], rv["timestamp"], rv["date"] = glog.strip().split(None, 2) - return rv - - -def getversioncfg(): - if PY3: - from configparser import RawConfigParser - else: - from ConfigParser import RawConfigParser - vd0 = dict(version=FALLBACK_VERSION, commit="", date="", timestamp=0) - # first fetch data from gitarchivecfgfile, ignore if it is unexpanded - g = vd0.copy() - cp0 = RawConfigParser(vd0) - cp0.read(gitarchivecfgfile) - if len(cp0.get("DEFAULT", "commit")) > 20: - g = cp0.defaults() - mx = re.search(r"\btag: v(\d[^,]*)", g.pop("refnames")) - if mx: - g["version"] = mx.group(1) - # then try to obtain version data from git. - gitdir = os.path.join(MYDIR, ".git") - if os.path.exists(gitdir) or "GIT_DIR" in os.environ: - try: - g = gitinfo() - except OSError: - pass - # finally, check and update the active version file - cp = RawConfigParser() - cp.read(versioncfgfile) - d = cp.defaults() - rewrite = not d or (g["commit"] and (g["version"] != d.get("version") or g["commit"] != d.get("commit"))) - if rewrite: - cp.set("DEFAULT", "version", g["version"]) - cp.set("DEFAULT", "commit", g["commit"]) - cp.set("DEFAULT", "date", g["date"]) - cp.set("DEFAULT", "timestamp", g["timestamp"]) - with open(versioncfgfile, "w") as fp: - cp.write(fp) - return cp - - -versiondata = getversioncfg() - - -def dirglob(d, *patterns): - from glob import glob - - rv = [] - for p in patterns: - rv += glob(os.path.join(d, p)) - return rv - - -with open(os.path.join(MYDIR, "README.rst")) as fp: - long_description = fp.read() - -# define distribution -setup_args = dict( - name="diffpy.pdfgui", - version="3.0.5", - packages=find_packages(os.path.join(MYDIR, "src")), - package_dir={"": "src"}, - include_package_data=True, - test_suite="diffpy.pdfgui.tests", - entry_points={ - "gui_scripts": [ - "pdfgui=diffpy.pdfgui.applications.pdfgui:main", - ], - }, - data_files=[ - ("icons", dirglob("icons", "*.png", "*.ico")), - ("doc", dirglob("doc", "*.pdf")), - ("doc/manual", dirglob("doc/manual", "*.html", "*.pdf")), - ("doc/manual/images", dirglob("doc/manual/images", "*.png")), - ("doc/tutorial", dirglob("doc/tutorial", "*")), - ], - # manual and tutorial files should not be zipped - zip_safe=False, - install_requires=[ - "six", - "diffpy.structure>=3", - "diffpy.pdffit2", - "diffpy.utils", - ], - author="Simon J.L. Billinge", - author_email="sb2896@columbia.edu", - maintainer="Pavol Juhas", - maintainer_email="pavol.juhas@gmail.com", - url="https://github.com/diffpy/diffpy.pdfgui", - description="GUI for PDF simulation and structure refinement.", - long_description=long_description, - long_description_content_type="text/x-rst", - license="BSD", - keywords="PDF structure refinement GUI", - classifiers=[ - # List of possible values at - # http://pypi.python.org/pypi?:action=list_classifiers - "Development Status :: 5 - Production/Stable", - "Environment :: MacOS X", - "Environment :: Win32 (MS Windows)", - "Environment :: X11 Applications", - "Intended Audience :: Science/Research", - "License :: OSI Approved :: BSD License", - "Operating System :: MacOS", - "Operating System :: Microsoft :: Windows", - "Operating System :: POSIX", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.10", - "Topic :: Scientific/Engineering :: Chemistry", - "Topic :: Scientific/Engineering :: Physics", - ], -) - -if __name__ == "__main__": - setup(**setup_args) - -# End of file diff --git a/src/diffpy/pdfgui/tests/conftest.py b/src/diffpy/pdfgui/tests/conftest.py index e3b63139..fefe798b 100644 --- a/src/diffpy/pdfgui/tests/conftest.py +++ b/src/diffpy/pdfgui/tests/conftest.py @@ -1,9 +1,14 @@ import json +import subprocess from pathlib import Path import pytest +def pytest_collection_modifyitems(session, config, items): + subprocess.run(["python", "-m", "diffpy.pdfgui.tests.rundeps"], check=True) + + @pytest.fixture def user_filesystem(tmp_path): base_dir = Path(tmp_path) diff --git a/src/diffpy/pdfgui/tests/testaboutdialog.py b/src/diffpy/pdfgui/tests/test_aboutdialog.py similarity index 100% rename from src/diffpy/pdfgui/tests/testaboutdialog.py rename to src/diffpy/pdfgui/tests/test_aboutdialog.py diff --git a/src/diffpy/pdfgui/tests/testcalculation.py b/src/diffpy/pdfgui/tests/test_calculation.py similarity index 100% rename from src/diffpy/pdfgui/tests/testcalculation.py rename to src/diffpy/pdfgui/tests/test_calculation.py diff --git a/src/diffpy/pdfgui/tests/testconstraint.py b/src/diffpy/pdfgui/tests/test_constraint.py similarity index 100% rename from src/diffpy/pdfgui/tests/testconstraint.py rename to src/diffpy/pdfgui/tests/test_constraint.py diff --git a/src/diffpy/pdfgui/tests/testdatasetpanels.py b/src/diffpy/pdfgui/tests/test_datasetpanels.py similarity index 100% rename from src/diffpy/pdfgui/tests/testdatasetpanels.py rename to src/diffpy/pdfgui/tests/test_datasetpanels.py diff --git a/src/diffpy/pdfgui/tests/testdopingseriespanel.py b/src/diffpy/pdfgui/tests/test_dopingseriespanel.py similarity index 100% rename from src/diffpy/pdfgui/tests/testdopingseriespanel.py rename to src/diffpy/pdfgui/tests/test_dopingseriespanel.py diff --git a/src/diffpy/pdfgui/tests/testextendedplotframe.py b/src/diffpy/pdfgui/tests/test_extendedplotframe.py similarity index 100% rename from src/diffpy/pdfgui/tests/testextendedplotframe.py rename to src/diffpy/pdfgui/tests/test_extendedplotframe.py diff --git a/src/diffpy/pdfgui/tests/testfitdataset.py b/src/diffpy/pdfgui/tests/test_fitdataset.py similarity index 100% rename from src/diffpy/pdfgui/tests/testfitdataset.py rename to src/diffpy/pdfgui/tests/test_fitdataset.py diff --git a/src/diffpy/pdfgui/tests/testfitstructure.py b/src/diffpy/pdfgui/tests/test_fitstructure.py similarity index 100% rename from src/diffpy/pdfgui/tests/testfitstructure.py rename to src/diffpy/pdfgui/tests/test_fitstructure.py diff --git a/src/diffpy/pdfgui/tests/testinsertrowsdialog.py b/src/diffpy/pdfgui/tests/test_insertrowsdialog.py similarity index 100% rename from src/diffpy/pdfgui/tests/testinsertrowsdialog.py rename to src/diffpy/pdfgui/tests/test_insertrowsdialog.py diff --git a/src/diffpy/pdfgui/tests/testloadproject.py b/src/diffpy/pdfgui/tests/test_loadproject.py similarity index 100% rename from src/diffpy/pdfgui/tests/testloadproject.py rename to src/diffpy/pdfgui/tests/test_loadproject.py diff --git a/src/diffpy/pdfgui/tests/testmainframe.py b/src/diffpy/pdfgui/tests/test_mainframe.py similarity index 100% rename from src/diffpy/pdfgui/tests/testmainframe.py rename to src/diffpy/pdfgui/tests/test_mainframe.py diff --git a/src/diffpy/pdfgui/tests/testparameter.py b/src/diffpy/pdfgui/tests/test_parameter.py similarity index 100% rename from src/diffpy/pdfgui/tests/testparameter.py rename to src/diffpy/pdfgui/tests/test_parameter.py diff --git a/src/diffpy/pdfgui/tests/testparameterspanel.py b/src/diffpy/pdfgui/tests/test_parameterspanel.py similarity index 100% rename from src/diffpy/pdfgui/tests/testparameterspanel.py rename to src/diffpy/pdfgui/tests/test_parameterspanel.py diff --git a/src/diffpy/pdfgui/tests/testpdfdataset.py b/src/diffpy/pdfgui/tests/test_pdfdataset.py similarity index 100% rename from src/diffpy/pdfgui/tests/testpdfdataset.py rename to src/diffpy/pdfgui/tests/test_pdfdataset.py diff --git a/src/diffpy/pdfgui/tests/testpdfguicontrol.py b/src/diffpy/pdfgui/tests/test_pdfguicontrol.py similarity index 100% rename from src/diffpy/pdfgui/tests/testpdfguicontrol.py rename to src/diffpy/pdfgui/tests/test_pdfguicontrol.py diff --git a/src/diffpy/pdfgui/tests/testpdfstructure.py b/src/diffpy/pdfgui/tests/test_pdfstructure.py similarity index 100% rename from src/diffpy/pdfgui/tests/testpdfstructure.py rename to src/diffpy/pdfgui/tests/test_pdfstructure.py diff --git a/src/diffpy/pdfgui/tests/testphaseconfigurepanel.py b/src/diffpy/pdfgui/tests/test_phaseconfigurepanel.py similarity index 100% rename from src/diffpy/pdfgui/tests/testphaseconfigurepanel.py rename to src/diffpy/pdfgui/tests/test_phaseconfigurepanel.py diff --git a/src/diffpy/pdfgui/tests/teststructureviewer.py b/src/diffpy/pdfgui/tests/test_structureviewer.py similarity index 100% rename from src/diffpy/pdfgui/tests/teststructureviewer.py rename to src/diffpy/pdfgui/tests/test_structureviewer.py diff --git a/src/diffpy/pdfgui/tests/testtemperatureseriespanel.py b/src/diffpy/pdfgui/tests/test_temperatureseriespanel.py similarity index 100% rename from src/diffpy/pdfgui/tests/testtemperatureseriespanel.py rename to src/diffpy/pdfgui/tests/test_temperatureseriespanel.py