diff --git a/.cruft.json b/.cruft.json index 2f4a4046..6c44a3f1 100644 --- a/.cruft.json +++ b/.cruft.json @@ -1,6 +1,6 @@ { "template": "https://github.com/wpk-nist-gov/cookiecutter-pypackage.git", - "commit": "cb20a32f67dadb4142be54898a87de1efdce6bd6", + "commit": "10a9fe1a4f0b341184e41953433c344020f92c72", "checkout": "feature/markdown", "skip": [ "src/thermoextrap/__init__.py", @@ -24,8 +24,8 @@ "docs/_templates/autodocsumm/*.rst", "docs/_static/css/*", "docs/_static/js/*", - "changelog.d/templates/*", - "changelog.d/templates/auto-changlog/*" + "changelog.d/templates/*.j2", + "changelog.d/templates/auto-changelog/*.jinja2" ], "project_short_description": "Thermodynamic extrapolation", "version": "0.0.1", diff --git a/.recipe-append.yaml b/.recipe-append.yaml new file mode 100644 index 00000000..fe267135 --- /dev/null +++ b/.recipe-append.yaml @@ -0,0 +1,19 @@ +test: + imports: + - thermoextrap + commands: + - pip check + requires: + - pip + +about: + home: https://github.com/usnistgov/thermoextrap + summary: Thermodynamic extrapolation + description: | + A package to perform thermodynamic extrapolation of molecular simulations. + license: NIST-PD + license_file: LICENSE + +extra: + recipe-maintainers: + - wpk-nist-gov diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 347650eb..7d3332b4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -389,3 +389,14 @@ Versioning is handled with [setuptools_scm].The pacakge version is set by the git tag. For convenience, you can override the version in the makefile (calling tox) by setting `version=v{major}.{minor}.{micro}`. This is useful for updating the docs, etc. + +## Creating conda recipe + +[grayskull]: https://github.com/conda/grayskull + +For the most part, we use [grayskull] to create the conda recipe. However, I've +had issues getting it to play nice with `pyproject.toml` for some of the 'extra' +variables. So, we use grayskull to build the majority of the recipe, and append +the file `.recipe-append.yaml`. For some edge cases (install name different from +package name, etc), you'll need to manually edit this file to create the final +recipe. diff --git a/docs/examples/create-symlinks.sh b/docs/examples/create-symlinks.sh deleted file mode 100644 index b9528817..00000000 --- a/docs/examples/create-symlinks.sh +++ /dev/null @@ -1,46 +0,0 @@ -# this creates symlinks to files in thermoextrap/examples directory. - -exts=(ipynb md) - - -rm -rf usage -for path in $(cat *.md | grep '^usage/'); do - - target="../../examples/"${path} - name=$(basename $target) - - if [ -f $target ]; then - # has extension - - base=${name%.*} - ext=${name##*.} - - else - # no extension. Try to add one - for ext in ${exts[@]}; do - tmp=${target}.${ext} - if [ -f "${tmp}" ] ; then - base=$name - target=$tmp - break - fi - done - fi - - - new_dir=$(dirname $path) - mkdir -p $new_dir - - total_target=$(realpath --relative-to=${new_dir} $target) - - # echo "target $target" - # echo "base $base" - # echo "ext $ext" - echo "target $total_target" - echo "new_dir $new_dir" - echo "" - - - ln -s $total_target $new_dir - -done diff --git a/pyproject.toml b/pyproject.toml index eff3eab3..4ca5cfe0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ authors = [ { name = "Jacob Monroe", email = "jacob.monroe@nist.gov" }, { name = "William Krekelberg", email = "wpk@nist.gov" } ] -license = { text = '"NIST license https://www.nist.gov/director/licensing"' } +license = { text = "NIST-PD" } description = "Thermodynamic extrapolation" # if using markdown # long_description_content_type = text/markdown @@ -60,16 +60,16 @@ test = ["pytest"] # dev = [] # docs = [] -## Defer this to setup.cfg -## Will transition when everything works (grayskull in particular) -## and will remove setup.py -# [tool.setuptools] -# zip-safe = true # if using mypy, must be False -# include-package-data = true -# license-files = ["LICENSE"] -# [tool.setuptools.packages.find] -# namespaces = true -# where = ["src"] +## grayskull still messes some things up, but use scripts/recipe-append.sh for this +[tool.setuptools] +zip-safe = true # if using mypy, must be False +include-package-data = true +license-files = ["LICENSE"] + +[tool.setuptools.packages.find] +namespaces = true +where = ["src"] + ## include = [] ## exclude = [] ## diff --git a/scripts/dist-conda.mk b/scripts/dist-conda.mk index 7f5628ca..3dda1bdb 100644 --- a/scripts/dist-conda.mk +++ b/scripts/dist-conda.mk @@ -1,21 +1,32 @@ + project_name?=thermoextrap +sdist_path?=$(project_name) -.PHONY: help clean-recipe clean-build recipe build command +.PHONY: help clean-recipe clean-build grayskull recipe-append recipe build command help: @echo Makefile for building conda dist clean-recipe: - rm -rf $(project_name) + rm -rf dist-conda/$(project_name) clean-build: rm -rf build -recipe: clean-recipe - grayskull pypi $(project_name) && \ - cat $(project_name)/meta.yaml +# by default, only use a few sections +grayskull_args ?= --maintainers wpk-nist-gov --sections package source build requirements +grayskull: clean-recipe + grayskull pypi $(sdist_path) $(grayskull_args) -o dist-conda + +# append the rest +recipe_base_path ?= dist-conda/$(project_name)/meta.yaml +recipe_append_path ?= .recipe-append.yaml +recipe-append: + bash scripts/recipe-append.sh $(recipe_base_path) $(recipe_append_path) + +recipe: grayskull recipe-append build: clean-build - conda mambabuild --output-folder=build --no-anaconda-upload . + conda mambabuild --output-folder=dist-conda/build --no-anaconda-upload dist-conda command: $(command) diff --git a/scripts/recipe-append.sh b/scripts/recipe-append.sh new file mode 100644 index 00000000..f8b8c7c6 --- /dev/null +++ b/scripts/recipe-append.sh @@ -0,0 +1,34 @@ +# This is to fix issues using grayskull with pyproject.toml only projects +# We fall back to using grayskull to create the majority of the recipe +# but add in the final sections +# Edit .recipe-append.yaml +if [ $# -lt 2 ]; then + echo "need recipe_base_path, recipe_append_path" + exit 1 +fi + +base_path=$1 +append_path=$2 + + +if [ ! -f $base_path ]; then + echo "no $base_path" + exit 1 +fi + +if [ ! -f $append_path ]; then + echo "no $append_path" + exit +fi + + +tmp_file=$(mktemp) +cp $base_path $tmp_file + +echo "" >> $tmp_file + +cat $append_path >> $tmp_file + +mv $tmp_file $base_path + +cat $base_path diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 9f33c56d..00000000 --- a/setup.cfg +++ /dev/null @@ -1,26 +0,0 @@ -# TODO : remove all of this when I can -# -# For now, need metadata.url and options.* (as well as setup.py) -# to make grayskull correctly parse the repo for a recipe. -# That's the only reason. When grayskull better handles [tool.setuptools] -# in pyproject.toml, I'll remove those sections, and `setup.py`. -# -# -# * I need metadata.url to get the homepage correct in the generated meta.yaml -# -# * I need options.* to get the subpackages (lnpy and lnPi) correctly -# * This is due to the project `tmmc-lnpy` being different to the package(s). - -[metadata] -url = https://github.com/usnistgov/thermoextrap -license_files = LICENSE - -[options] -packages = find_namespace: -package_dir= - =src -include_package_data = True -zip_safe = True # if using mypy, must be False - -[options.packages.find] -where=src diff --git a/setup.py b/setup.py deleted file mode 100644 index 2a1d6537..00000000 --- a/setup.py +++ /dev/null @@ -1,12 +0,0 @@ -# noqa -from setuptools import setup - -setup() -# use_scm_version={"fallback_version": "999"}, -# license_files=["LICENSE"], -# zip_safe=True, -# packages=find_namespace_packages(where="src"), -# package_dir={"": "src"}, -# include_package_data=True, -# url="https://github.com/usnistgov/tmmc-lnpy", -# ) diff --git a/tox.ini b/tox.ini index b0fdddca..d7dab231 100644 --- a/tox.ini +++ b/tox.ini @@ -32,13 +32,20 @@ commands_test_check = [testenv] passenv = SETUPTOOLS_SCM_PRETEND_VERSION + TEST_VERSION + # general command command + # linting mypy_args pyright_args pytype_args release_args + # dist-conda stuff project_name - TEST_VERSION + sdist_path + grayskull_args + recipe_base_path + recipe_append_path usedevelop = test: True conda_env = @@ -95,9 +102,9 @@ skip_install = True envdir = {toxworkdir}/dist-conda basepython = {[base]build_python} conda_env = {[base]conda_env_dist_conda} -changedir = {toxinidir}/dist-conda +changedir = {toxinidir} commands = - make -f {toxinidir}/scripts/dist-conda.mk {posargs} project_name={[base]package_name} + make -f {toxinidir}/scripts/dist-conda.mk {posargs} project_name={env:project_name:{[base]package_name}} [testenv:testdist-{pypi, conda}-{local,remote}-py3{8, 9, 10, 11}] conda_channels =