From e43784d6cc6fa60806dd13fafc792cf5abe5acf4 Mon Sep 17 00:00:00 2001 From: Dan Porter Date: Thu, 21 Nov 2024 18:57:31 +0000 Subject: [PATCH] Version 3.3.2 Updated pyproject.toml Added github workflows. --- .github/workflows/pypi-publish.yml | 42 ++++++++++++++++++++++++++++++ .github/workflows/tests.yml | 37 ++++++++++++++++++++++++++ Examples/README.md | 3 +++ pyproject.toml | 7 +++-- setup.py | 2 +- 5 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/pypi-publish.yml create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml new file mode 100644 index 0000000..decd41c --- /dev/null +++ b/.github/workflows/pypi-publish.yml @@ -0,0 +1,42 @@ +name: Code CI + +on: + push: + pull_request: + +jobs: + dist: + runs-on: "ubuntu-latest" + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Build sdist and wheel + run: pipx run build + + - name: Upload sdist and wheel as artifacts + uses: actions/upload-artifact@v3 + with: + name: dist + path: dist + + pypi: + # upload to PyPI and make a release on every tag + if: github.ref_type == 'tag' + needs: [dist] + + runs-on: ubuntu-latest + permissions: + # this permission is mandatory for trusted publishing To PyPI + id-token: write + # Specify the GitHub Environment to publish to + environment: release + + steps: + # download sdist and wheel from dist job + - uses: actions/download-artifact@v3 + + # publish to PyPI using trusted publishing + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..a8e17fb --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,37 @@ +name: Run Tests + +on: + push: + pull_request: + +jobs: + build: + # Deduplicate jobs from pull requests and branch pushes within the same repo. + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.11"] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Upgrade pip + run: python -m pip install --upgrade pip + + - name: Install dependencies + run: python -m pip install . + + - name: Install pytest + run: python -m pip install pytest + + - name: Dans_Diffraction Version + run: python -c "import Dans_Diffraction; print(Dans_Diffraction.module_info())" + + - name: Run tests + run: python -m pytest diff --git a/Examples/README.md b/Examples/README.md index 67d1a75..ce4a3f3 100644 --- a/Examples/README.md +++ b/Examples/README.md @@ -23,7 +23,10 @@ $ ipython -i --matplotlib tk ./example_plot_powder.py |-------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | example_build_crystal.py | Build your very own crystal structure, using lattice parameters and atomic coordinates | | example_calculate_intensities.py | Calculate list of reflections using different methods Makes use of the new scattering functionality in Dans_Diffraction 2.0.0+ Requires Dans_Diffraction version >2.0.0 | +| example_cell_basis.py | Select different cell basis options, requires Dans_Diffraction >V3.3 | +| example_cell_sliders.py | Plot different cell basis options, requires Dans_Diffraction >V3.3 | | example_coherent_diffraction.py | Simulate coherent diffraction by creating a large crystallite of many unit cells. Use one of two methods to define a random crystallite shape: 1. random distribution of cells around a central point - cells are not always neighboring but creates a nice ellipsoid 2. random walk of cells - each cell has a direct neighbor but the shapes can be very odd Requires Dans_Diffraction version >2.0.0 | +| example_complex_neutron_scattering.py | Calculate neutron scattering from isotopes using complex neutron scattering lengths | | example_crysalispro_cuts.py | Example Read recirpocal space cuts from CrysAlisPro | | example_crystal_orientation.py | Set and change the orientation of the crystal Makes use of the new orientation functionality in Dans_Diffraction 2.1.0+ Requires Dans_Diffraction version >2.1.0 | | example_cxro.py | Simulate the functionality of the CXRO website: https://henke.lbl.gov/optical_constants/ Use formulas from: B.L. Henke, E.M. Gullikson, and J.C. Davis, X-ray interactions: photoabsorption, scattering, transmission, and reflection at E=50-30000 eV, Z=1-92, Atomic Data and Nuclear Data Tables 54 no.2, 181-342 (July 1993). | diff --git a/pyproject.toml b/pyproject.toml index 71f4ed5..247a7a5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,10 @@ [build-system] -requires = ["setuptools >= 61.0", "wheel", "numpy", "matplotlib"] +requires = ["setuptools >= 61.0", "wheel", "pytest", "numpy", "matplotlib"] build-backend = "setuptools.build_meta" [project] name = "Dans_Diffraction" -version = "3.3.0" +dynamic = ['version'] dependencies = [ "numpy", "matplotlib", @@ -44,3 +44,6 @@ dansdiffraction = "Dans_Diffraction:start_gui" [project.gui-scripts] dansdiffraction = "Dans_Diffraction:start_gui" + +[tool.setuptools.dynamic] +version = {attr = "Dans_Diffraction.__version__"} \ No newline at end of file diff --git a/setup.py b/setup.py index 874ae01..83ff573 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ def readme(): setup( name='Dans_Diffraction', packages=['Dans_Diffraction', 'Dans_Diffraction.tkgui'], - version='3.2.1', + version='3.3.2', description='Generate diffracted intensities from crystals', long_description_content_type='text/markdown', long_description=readme(),