Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update diffmah packaging to pyproject.toml #109

Merged
merged 12 commits into from
Sep 26, 2023
Merged
4 changes: 4 additions & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true)$
ref-names: $Format:%D$
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git_archival.txt export-subst
39 changes: 35 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- uses: conda-incubator/setup-miniconda@v2
with:
Expand All @@ -22,19 +24,24 @@ 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
python -m pip install --no-deps -e .
conda install -y -q \
mamba install -y -q \
flake8 \
pytest \
pytest-xdist \
pytest-cov
pytest-cov \
pip \
setuptools \
"setuptools_scm>=7,<8" \
python-build
python -m pip install --no-build-isolation --no-deps -e .

- name: lint
shell: bash -l {0}
Expand All @@ -48,3 +55,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 .
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
diffmah/_version.py

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
10 changes: 8 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 4 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -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)
------------------
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion diffmah/_version.py

This file was deleted.

13 changes: 9 additions & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -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("diffmah").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
Expand Down
4 changes: 0 additions & 4 deletions docs/source/requirements.txt

This file was deleted.

18 changes: 18 additions & 0 deletions docs/source/rtd_environment.yaml
Original file line number Diff line number Diff line change
@@ -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
49 changes: 49 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]"},
]
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
24 changes: 2 additions & 22 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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="[email protected]",
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()
Loading