From 2435c476ecc1d6f290433c1ed3aee1b0efd42fec Mon Sep 17 00:00:00 2001 From: Andrew Hearin Date: Tue, 26 Sep 2023 10:51:48 -0500 Subject: [PATCH 01/12] Add .git files to assist automated package tooling --- .git_archival.txt | 4 ++++ .gitattributes | 1 + 2 files changed, 5 insertions(+) create mode 100644 .git_archival.txt create mode 100644 .gitattributes diff --git a/.git_archival.txt b/.git_archival.txt new file mode 100644 index 0000000..8ff2455 --- /dev/null +++ b/.git_archival.txt @@ -0,0 +1,4 @@ +node: $Format:%H$ +node-date: $Format:%cI$ +describe-name: $Format:%(describe:tags=true)$ +ref-names: $Format:%D$ \ No newline at end of file diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..82bf71c --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +.git_archival.txt export-subst \ No newline at end of file From 183f3c66ae583de5b4fc9d243385302b6721036f Mon Sep 17 00:00:00 2001 From: Andrew Hearin Date: Tue, 26 Sep 2023 11:02:52 -0500 Subject: [PATCH 02/12] Add rst extension to LICENSE --- LICENSE => LICENSE.rst | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename LICENSE => LICENSE.rst (100%) diff --git a/LICENSE b/LICENSE.rst similarity index 100% rename from LICENSE rename to LICENSE.rst From 243e5521aa7575cc1aa110e54d65fd391485ab5c Mon Sep 17 00:00:00 2001 From: Andrew Hearin Date: Tue, 26 Sep 2023 11:03:56 -0500 Subject: [PATCH 03/12] Update package tooling to pyproject.toml --- diffmah/_version.py | 1 - pyproject.toml | 49 +++++++++++++++++++++++++++++++++++++++++++++ setup.py | 24 ++-------------------- 3 files changed, 51 insertions(+), 23 deletions(-) delete mode 100644 diffmah/_version.py create mode 100644 pyproject.toml diff --git a/diffmah/_version.py b/diffmah/_version.py deleted file mode 100644 index a052d3a..0000000 --- a/diffmah/_version.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = "0.4.1" # noqa diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..87729c1 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,49 @@ +[build-system] +requires = [ + "setuptools>=45", + "setuptools_scm>=7", + "tomli>=1.0.0; python_version < '3.11'", +] +build-backend = "setuptools.build_meta" + +[tool.setuptools_scm] +write_to = "diffmah/_version.py" +write_to_template = "__version__ = '{version}'\n" + +[tool.setuptools] +include-package-data = true +packages = {find = {exclude=["tests*", "scripts*", "docs*", "notebooks*"]}} +package-data = {diffmah = ["data/*.dat", "tests/testing_data/*.dat"]} +package-dir = {diffmah = "diffmah"} + +[project.urls] +home = "https://github.com/ArgonneCPAC/diffmah" + +[project] +name = "diffmah" +authors = [ + {name = "Andrew Hearin", email = "ahearin@anl.gov"}, +] +description = "Differentiable model of dark matter halo assembly" +readme = "README.md" +requires-python = ">=3.9" +license = {file = "LICENSE.rst"} +classifiers = [ + "Programming Language :: Python :: 3", +] +dependencies = ["numpy", "jax"] +dynamic = ["version"] + +[tool.black] +line-length = 88 + +[tool.isort] +profile = "black" + +[tool.flake8] +ignore = ["E231", "E241", "E501", "W503"] +per-file-ignores = [ + "__init__.py:F401", +] +max-line-length = 88 +count = true \ No newline at end of file diff --git a/setup.py b/setup.py index c242a85..6068493 100644 --- a/setup.py +++ b/setup.py @@ -1,23 +1,3 @@ -import os -from setuptools import setup, find_packages +from setuptools import setup - -__version__ = None -pth = os.path.join( - os.path.dirname(os.path.realpath(__file__)), "diffmah", "_version.py" -) -with open(pth, "r") as fp: - exec(fp.read()) - - -setup( - name="diffmah", - version=__version__, - author="Andrew Hearin", - author_email="ahearin@anl.gov", - description="Differentiable model of dark matter halo assembly", - install_requires=["numpy", "jax"], - packages=find_packages(), - url="https://github.com/ArgonneCPAC/diffmah", - package_data={"diffmah": ("data/*.dat", "tests/testing_data/*.dat")}, -) +setup() From e51ca9062d8f176834e4d691ed978a15c93975bb Mon Sep 17 00:00:00 2001 From: Andrew Hearin Date: Tue, 26 Sep 2023 11:04:03 -0500 Subject: [PATCH 04/12] Update changelog. Preparing to release 0.4.2 on conda-forge and pip --- CHANGES.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index b7a8d3b..200499a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,7 +1,10 @@ -0.5.0 (in progress) +0.4.2 (in progress) ------------------ - Remove optional mah_type argument of mc_halo_population function - Implement differentiable kernel for mc_halo_population function +- Update requirement to python>=3.9 +- Update packaging structure to pyproject.toml +- Remove diffmah/_version.py and switch to dynamic versioning 0.4.1 (2022-09-17) ------------------ From 77550c59d2ca4fc65adbb59b013c627c9fe437c1 Mon Sep 17 00:00:00 2001 From: Andrew Hearin Date: Tue, 26 Sep 2023 11:06:21 -0500 Subject: [PATCH 05/12] gitignore dynamically created diffmah/_version.py --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 894a44c..0db5d92 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +diffmah/_version.py + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] From f84c0387da5655ae986c886e9c01dd0cc2ce894c Mon Sep 17 00:00:00 2001 From: Andrew Hearin Date: Tue, 26 Sep 2023 11:18:55 -0500 Subject: [PATCH 06/12] Update RTD configuration files --- .readthedocs.yml | 10 ++++++++-- docs/source/conf.py | 13 +++++++++---- docs/source/requirements.txt | 4 ---- docs/source/rtd_environment.yaml | 18 ++++++++++++++++++ 4 files changed, 35 insertions(+), 10 deletions(-) delete mode 100644 docs/source/requirements.txt create mode 100644 docs/source/rtd_environment.yaml diff --git a/.readthedocs.yml b/.readthedocs.yml index 9d6a9eb..b563df3 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -3,9 +3,15 @@ version: 2 sphinx: configuration: docs/source/conf.py +build: + os: "ubuntu-22.04" + tools: + python: "mambaforge-22.9" + +conda: + environment: docs/source/rtd_environment.yaml + python: - version: 3 install: - method: pip path: . - - requirements: docs/source/requirements.txt diff --git a/docs/source/conf.py b/docs/source/conf.py index ffe9742..dc1ca85 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -1,15 +1,20 @@ # Configuration file for the Sphinx documentation builder. # -# For the full list of built-in configuration values, see the documentation: -# https://www.sphinx-doc.org/en/master/usage/configuration.html +""" +""" +from pkg_resources import DistributionNotFound, get_distribution -# -- Project information ----------------------------------------------------- -# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information +try: + __version__ = get_distribution("diffstar").version +except DistributionNotFound: + __version__ = "unknown version" project = "diffmah" copyright = "2022, Andrew Hearin" author = "Andrew Hearin" release = "0.4.1" +version = __version__ +release = __version__ # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration diff --git a/docs/source/requirements.txt b/docs/source/requirements.txt deleted file mode 100644 index a6ab95a..0000000 --- a/docs/source/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -nbsphinx -jupyter -matplotlib -sphinx-copybutton \ No newline at end of file diff --git a/docs/source/rtd_environment.yaml b/docs/source/rtd_environment.yaml new file mode 100644 index 0000000..bd3ef1d --- /dev/null +++ b/docs/source/rtd_environment.yaml @@ -0,0 +1,18 @@ +name: rtd311 +channels: + - conda-forge + - defaults +dependencies: + - python=3.10 + - pip + - pandoc>=3.1,<4.0 + - nbsphinx + - jupyter + - matplotlib + - sphinx=7.2.4 + - sphinx-copybutton + - numpy + - jax + - jaxlib + - diffmah + - h5py \ No newline at end of file From ff464b9eaf03985802953f75fd68ae8ae79a6862 Mon Sep 17 00:00:00 2001 From: Andrew Hearin Date: Tue, 26 Sep 2023 11:22:11 -0500 Subject: [PATCH 07/12] Fix copy and pasta bug in conf.py --- docs/source/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index dc1ca85..77dcbe8 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -5,7 +5,7 @@ from pkg_resources import DistributionNotFound, get_distribution try: - __version__ = get_distribution("diffstar").version + __version__ = get_distribution("diffmah").version except DistributionNotFound: __version__ = "unknown version" From 583464b8aae0c881235a88694848a434c5fd536c Mon Sep 17 00:00:00 2001 From: Andrew Hearin Date: Tue, 26 Sep 2023 11:49:12 -0500 Subject: [PATCH 08/12] Add test versions workflow to tests.yml by pattern-matching code suggested by @beckermr in https://github.com/regro/conda-forge-metadata/blob/dffd4c4664321270bfe4bcac11b2481a5e285acf/.github/workflows/tests.yml --- .github/workflows/tests.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6add4be..35d739e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -48,3 +48,27 @@ jobs: - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 + + - name: test versions + shell: bash -el {0} + run: | + pip uninstall diffmah --yes + [[ $(python setup.py --version) != "0.0.0" ]] || exit 1 + + rm -rf dist/* + python setup.py sdist + pip install --no-deps --no-build-isolation dist/*.tar.gz + pushd .. + python -c "import diffmah; assert diffmah.__version__ != '0.0.0'" + popd + pip uninstall diffmah --yes + + rm -rf dist/* + python -m build --sdist . --outdir dist + pip install --no-deps --no-build-isolation dist/*.tar.gz + pushd .. + python -c "import diffmah; assert diffmah.__version__ != '0.0.0'" + popd + pip uninstall diffmah --yes + + python -m pip install -v --no-deps --no-build-isolation -e . From 175e32d3a37c263d24594f01b99821b4502b83db Mon Sep 17 00:00:00 2001 From: "Matthew R. Becker" Date: Tue, 26 Sep 2023 12:12:07 -0500 Subject: [PATCH 09/12] Try to get all the tags --- .github/workflows/tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 35d739e..9592f01 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,6 +13,8 @@ jobs: steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - uses: conda-incubator/setup-miniconda@v2 with: From 36c5482cb3d64e4d26beed057403a190e8cd0377 Mon Sep 17 00:00:00 2001 From: beckermr Date: Tue, 26 Sep 2023 14:40:50 -0500 Subject: [PATCH 10/12] BUG make sure to have install tools in env --- .github/workflows/tests.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9592f01..7aa9450 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -31,12 +31,15 @@ jobs: conda config --set always_yes yes conda install --quiet \ --file=requirements.txt - python -m pip install --no-deps -e . conda install -y -q \ flake8 \ pytest \ pytest-xdist \ - pytest-cov + pytest-cov \ + pip \ + setuptools \ + "setuptools_scm>=7" + python -m pip install --no-build-isolation --no-deps -e . - name: lint shell: bash -l {0} From 1d8dae8cda1f04812356cd92a59f819c6e4328f1 Mon Sep 17 00:00:00 2001 From: beckermr Date: Tue, 26 Sep 2023 14:44:30 -0500 Subject: [PATCH 11/12] BUG need python build --- .github/workflows/tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7aa9450..3d44f9e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -38,7 +38,8 @@ jobs: pytest-cov \ pip \ setuptools \ - "setuptools_scm>=7" + "setuptools_scm>=7,<8" \ + python-build python -m pip install --no-build-isolation --no-deps -e . - name: lint From 2fc35c49b34516aa5d7ee7ddd97ad06f9d625e0f Mon Sep 17 00:00:00 2001 From: beckermr Date: Tue, 26 Sep 2023 14:48:26 -0500 Subject: [PATCH 12/12] try again with mamba --- .github/workflows/tests.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3d44f9e..fcf7cee 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -24,14 +24,15 @@ jobs: show-channel-urls: true miniforge-version: latest miniforge-variant: Mambaforge + use-mamba: true - name: configure conda and install code shell: bash -l {0} run: | conda config --set always_yes yes - conda install --quiet \ + mamba install --quiet \ --file=requirements.txt - conda install -y -q \ + mamba install -y -q \ flake8 \ pytest \ pytest-xdist \