From 388d8900a2855638621f3d11cba6805c8ad5dea3 Mon Sep 17 00:00:00 2001 From: virgesmith Date: Sun, 27 Aug 2023 09:56:46 +0100 Subject: [PATCH 1/6] packaging changes --- .github/workflows/pypi-release.yml | 6 ++--- R/humanleague.R | 2 +- README.md | 10 ++++---- humanleague/__init__.py | 6 ++++- pyproject.toml | 37 ++++++++++++++++++++++++++++++ setup.cfg | 8 +++++++ setup.py | 32 +------------------------- src/module.cpp | 5 ---- 8 files changed, 61 insertions(+), 45 deletions(-) diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index 1f9db52..e70f9b1 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -22,11 +22,11 @@ jobs: current_version: "${{ env.current_version }}" files: DESCRIPTION commit_name: Version autobump - commit_email: andrew@friarswood.net - login: virgesmith + commit_email: devops@friarswood.net + login: "${{ secrets.REPO_LOGIN }}" token: "${{ secrets.REPO_PAT }}" # part defaults to patch - part: minor + # part: minor - name: Create dist run: | pip install pybind11 diff --git a/R/humanleague.R b/R/humanleague.R index 57a316a..5c4b9e5 100644 --- a/R/humanleague.R +++ b/R/humanleague.R @@ -54,7 +54,7 @@ #' #' @docType package #' @name humanleague -NULL +"_PACKAGE" #' @useDynLib humanleague #' @importFrom Rcpp sourceCpp diff --git a/README.md b/README.md index 795d451..88591f2 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,14 @@ [![License](https://img.shields.io/github/license/mashape/apistatus.svg)](https://opensource.org/licenses/MIT) +[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/humanleague)](https://pypi.org/project/humanleague/) [![PyPI version](https://badge.fury.io/py/humanleague.svg)](https://badge.fury.io/py/humanleague) [![CRAN\_Status\_Badge](https://www.r-pkg.org/badges/version/humanleague)](https://CRAN.R-project.org/package=humanleague) -[![CRAN Downloads](https://cranlogs.r-pkg.org/badges/grand-total/humanleague?color=black)](https://cran.r-project.org/package=humanleague) [![DOI](https://zenodo.org/badge/95961787.svg)](https://zenodo.org/badge/latestdoi/95961787) [![status](https://joss.theoj.org/papers/d5aaf6e1c2efed431c506762622473b4/status.svg)](https://joss.theoj.org/papers/d5aaf6e1c2efed431c506762622473b4) -[![python (pip) build](https://github.com/virgesmith/humanleague/actions/workflows/pip-package.yml/badge.svg)](https://github.com/virgesmith/humanleague/actions/workflows/pip-package.yml/badge.svg) +[![python (pip) build](https://github.com/virgesmith/humanleague/actions/workflows/python-test.yml/badge.svg)](https://github.com/virgesmith/humanleague/actions/workflows/python-test.yml/badge.svg) [![r-cmd-check](https://github.com/virgesmith/humanleague/actions/workflows/r-cmd-check.yml/badge.svg)](https://github.com/virgesmith/humanleague/actions/workflows/r-cmd-check/badge.svg) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/430da36db15f46978bfccd1ad3243ae9)](https://www.codacy.com/gh/virgesmith/humanleague/dashboard?utm_source=github.com&utm_medium=referral&utm_content=virgesmith/humanleague&utm_campaign=Badge_Grade) @@ -57,10 +57,12 @@ Requires Python 3.9 or newer. The package can be installed using `pip`, e.g. python -m pip install humanleague --user ``` -### Build, install and test (from cloned repo) +#### Development + +Fork or clone the repo, then ```bash -pip install -e . +pip install -e .[dev] pytest ``` diff --git a/humanleague/__init__.py b/humanleague/__init__.py index 74a0c35..cd98eea 100644 --- a/humanleague/__init__.py +++ b/humanleague/__init__.py @@ -1 +1,5 @@ -from _humanleague import flatten, integerise, ipf, qis, qisi, SobolSequence, __version__ +import importlib.metadata + +__version__ = importlib.metadata.version("humanleague") + +from _humanleague import flatten, integerise, ipf, qis, qisi, SobolSequence diff --git a/pyproject.toml b/pyproject.toml index 5f76df5..cad9f7c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,8 +8,45 @@ requires = [ build-backend = "setuptools.build_meta" +[project] +name = "humanleague" +version = "2.3.0" +authors = [ + { name="Andrew Smith", email="andrew@friarswood.net" }, +] +license = {file = "LICENSE.md"} +description = "Microsynthesis using quasirandom sampling and/or IPF" +readme = "README.md" +requires-python = ">=3.9" +classifiers = [ + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", +] +dependencies = [ + "numpy>=1.19.1" +] + +[project.optional-dependencies] +dev = [ + "pybind11>=2.10.3", + "pytest>=7.1.3", + "mypy>=1.5.0", + "mypy-extensions>=1.0.0", + "ruff>=0.0.286" +] + [tool.pytest.ini_options] minversion = "6.0" testpaths = [ "tests" ] + +[tool.ruff] +select = ["E", "F"] +ignore = ["E501"] + +[tool.ruff.per-file-ignores] +"**/__init__.py" = ["F401", "F403"] \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 8641c40..889f591 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,14 @@ [bumpversion] current_version = 2.3.0 +[bumpversion:file:pyproject.toml] +search = version = "{current_version}" +replace = version = "{new_version}" + +[bumpversion:file:DESCRIPTION] +search = Version: "{current_version}" +replace = version: "{new_version}" + [aliases] test = pytest diff --git a/setup.py b/setup.py index 215b362..64eca22 100755 --- a/setup.py +++ b/setup.py @@ -5,20 +5,6 @@ from pybind11.setup_helpers import Pybind11Extension, ParallelCompile -def readme(): - with open('README.md') as f: - return f.read() - - -def version(): - """ The R file DESCRIPTION in the project root is now the single source of version info """ - with open("DESCRIPTION") as fd: - lines = fd.readlines() - for line in lines: - if line.startswith("Version:"): - return line.rstrip().split(":")[1].lstrip() - - def source_files(): sources = glob.glob("src/*.cpp") # can't use compile skips as some files are auto-generated @@ -35,7 +21,6 @@ def header_files(): def defines(): return [ - ("HUMANLEAGUE_VERSION", version()), ("PYTHON_MODULE", None) ] @@ -46,7 +31,7 @@ def defines(): sources=source_files(), include_dirs=["src"], define_macros=defines(), - depends=["setup.py", "DESCRIPTION", "src/docstr.inl"] + header_files(), + depends=["setup.py", "src/docstr.inl"] + header_files(), cxx_std=20, ) ] @@ -56,23 +41,8 @@ def defines(): setup( name='humanleague', - version=version(), - description='Microsynthesis using quasirandom sampling and/or IPF', - author='Andrew P Smith', - author_email='andrew@friarswood.net', - url='http://github.com/virgesmith/humanleague', - long_description=readme(), - long_description_content_type="text/markdown", packages=["humanleague"], package_data={"humanleague": ["py.typed", "*.pyi"]}, ext_modules=ext_modules, - install_requires=['numpy>=1.19.1'], - setup_requires=['pybind11>=2.5.0', 'pytest-runner'], - tests_require=['pytest'], - classifiers=[ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - ], zip_safe=False, ) diff --git a/src/module.cpp b/src/module.cpp index cf114c3..e4e5cbc 100644 --- a/src/module.cpp +++ b/src/module.cpp @@ -15,9 +15,6 @@ namespace py = pybind11; -#define STR2(x) #x -#define STR(x) STR2(x) - using namespace py::literals; @@ -298,8 +295,6 @@ PYBIND11_MODULE(_humanleague, m) { m.doc() = module_docstr; - m.attr("__version__") = STR(HUMANLEAGUE_VERSION); - m.def("flatten", hl::flatten, flatten_docstr, From 240bc82c0d590ca0f461d88b9cf85686644abfc1 Mon Sep 17 00:00:00 2001 From: virgesmith Date: Sun, 5 Nov 2023 13:10:04 +0000 Subject: [PATCH 2/6] bump python versions --- .github/workflows/coverage.yml | 2 +- .github/workflows/python-test.yml | 2 +- .github/workflows/r-cmd-check.yml | 2 ++ pyproject.toml | 9 +++++---- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 4783e29..1b91ddf 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [ "3.10" ] + python-version: [ "3.11" ] steps: - uses: actions/checkout@v3 - name: "pip: Python ${{ matrix.python-version }} coverage" diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml index bab1a44..13f16bc 100644 --- a/.github/workflows/python-test.yml +++ b/.github/workflows/python-test.yml @@ -19,7 +19,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.10", "3.11"] + python-version: ["3.10", "3.11", "3.12"] os: [ubuntu-latest, windows-latest, macos-latest] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/r-cmd-check.yml b/.github/workflows/r-cmd-check.yml index b1b2754..6aa5c2f 100644 --- a/.github/workflows/r-cmd-check.yml +++ b/.github/workflows/r-cmd-check.yml @@ -1,5 +1,7 @@ on: push: + branches: + - main pull_request: branches: - main diff --git a/pyproject.toml b/pyproject.toml index cad9f7c..1447e09 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ requires = [ "setuptools>=42", "wheel", - "pybind11>=2.6.0", + "pybind11>=2.10.3", "pytest" ] @@ -19,9 +19,9 @@ description = "Microsynthesis using quasirandom sampling and/or IPF" readme = "README.md" requires-python = ">=3.9" classifiers = [ - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ] @@ -35,7 +35,8 @@ dev = [ "pytest>=7.1.3", "mypy>=1.5.0", "mypy-extensions>=1.0.0", - "ruff>=0.0.286" + "ruff>=0.0.286", + "build>=0.10.0" ] [tool.pytest.ini_options] @@ -49,4 +50,4 @@ select = ["E", "F"] ignore = ["E501"] [tool.ruff.per-file-ignores] -"**/__init__.py" = ["F401", "F403"] \ No newline at end of file +"**/__init__.py" = ["F401", "F403"] From fe0f30c74d354c59840057444ea5a268dbf09eaa Mon Sep 17 00:00:00 2001 From: virgesmith Date: Sun, 5 Nov 2023 14:06:00 +0000 Subject: [PATCH 3/6] trigger CI From f2ec4ac58f23f732bcde8779dd3558790c48f594 Mon Sep 17 00:00:00 2001 From: virgesmith Date: Fri, 16 Feb 2024 18:46:27 +0000 Subject: [PATCH 4/6] fix gcc13 issue --- .gitignore | 5 ++--- pyproject.toml | 2 +- scripts/create-conda-env.sh | 11 ----------- src/NDArray.h | 1 + 4 files changed, 4 insertions(+), 15 deletions(-) delete mode 100755 scripts/create-conda-env.sh diff --git a/.gitignore b/.gitignore index 77dbbab..b24ea73 100644 --- a/.gitignore +++ b/.gitignore @@ -3,12 +3,11 @@ .RData .Ruserdata build/ -node_modules/ stubs/ *.o *.d -src/*.so -src/*.dll +*.so +*.dll *.log dist/ diff --git a/pyproject.toml b/pyproject.toml index 1447e09..11226ac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ authors = [ license = {file = "LICENSE.md"} description = "Microsynthesis using quasirandom sampling and/or IPF" readme = "README.md" -requires-python = ">=3.9" +requires-python = ">=3.10" classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", diff --git a/scripts/create-conda-env.sh b/scripts/create-conda-env.sh deleted file mode 100755 index 517d2b7..0000000 --- a/scripts/create-conda-env.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -# For use in CI scripts for conda builds. PYTHON env var must be set, to e.g. "3.8" - -wget -O miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -bash miniconda.sh -b -p ${HOME}/.miniconda -source "${HOME}/.miniconda/etc/profile.d/conda.sh" -conda config --set always_yes yes --set changeps1 no -conda update -q conda -conda info -a -conda create -q -n conda-env python=$PYTHON gxx_linux-64 numpy pybind11 pytest diff --git a/src/NDArray.h b/src/NDArray.h index 7df4535..bb45f3c 100644 --- a/src/NDArray.h +++ b/src/NDArray.h @@ -8,6 +8,7 @@ #if __cplusplus <= 201703l #include #endif +#include #include // The array storage From 73de67867a52777729e7cf42fda46feb05d0f486 Mon Sep 17 00:00:00 2001 From: virgesmith Date: Sat, 24 Feb 2024 09:28:55 +0000 Subject: [PATCH 5/6] update action --- .github/workflows/coverage.yml | 2 +- .github/workflows/pypi-release.yml | 2 +- .github/workflows/python-test.yml | 29 +---------------------------- .github/workflows/r-cmd-check.yml | 2 +- 4 files changed, 4 insertions(+), 31 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 1b91ddf..f8fffb0 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -15,7 +15,7 @@ jobs: matrix: python-version: [ "3.11" ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "pip: Python ${{ matrix.python-version }} coverage" uses: actions/setup-python@v4 with: diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index e70f9b1..26a3308 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -11,7 +11,7 @@ jobs: if: "!contains(github.event.head_commit.message, 'Bump version')" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: persist-credentials: false - name: current_version diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml index 13f16bc..3ac0383 100644 --- a/.github/workflows/python-test.yml +++ b/.github/workflows/python-test.yml @@ -22,7 +22,7 @@ jobs: python-version: ["3.10", "3.11", "3.12"] os: [ubuntu-latest, windows-latest, macos-latest] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "pip: Python ${{ matrix.python-version }} / ${{ matrix.os }}" uses: actions/setup-python@v4 with: @@ -44,30 +44,3 @@ jobs: run: | python -m pytest - # package: - # needs: build - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v3 - # - name: "pip: Python 3.11 / ubuntu-latest" - # uses: actions/setup-python@v4 - # with: - # python-version: "3.11" - # - name: Bump version - # run: | - # python -m pip install bump2version pybind11 - # bump2version patch - # - name: Create dist - # run: | - # python setup.py sdist - # - name: artifacts - # uses: actions/upload-artifact@v3 - # with: - # name: dt_utils_${{ matrix.python-version }} - # path: | - # dist - # - name: Publish - # uses: pypa/gh-action-pypi-publish@release/v1 - # with: - # password: ${{ secrets.TEST_PYPI_API_TOKEN }} - # repository-url: https://test.pypi.org/legacy/ \ No newline at end of file diff --git a/.github/workflows/r-cmd-check.yml b/.github/workflows/r-cmd-check.yml index 6aa5c2f..18e3bbb 100644 --- a/.github/workflows/r-cmd-check.yml +++ b/.github/workflows/r-cmd-check.yml @@ -31,7 +31,7 @@ jobs: R_KEEP_PKG_SOURCE: yes steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: r-lib/actions/setup-r@v2 with: r-version: ${{ matrix.config.r }} From dbf4b9b5c149445dd0838b809f47c2eef3d669a6 Mon Sep 17 00:00:00 2001 From: virgesmith Date: Sat, 24 Feb 2024 09:53:23 +0000 Subject: [PATCH 6/6] update more actions --- .github/workflows/coverage.yml | 2 +- .github/workflows/python-test.yml | 2 +- .github/workflows/r-cmd-check.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index f8fffb0..004257e 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -17,7 +17,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: "pip: Python ${{ matrix.python-version }} coverage" - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml index 3ac0383..4ee9296 100644 --- a/.github/workflows/python-test.yml +++ b/.github/workflows/python-test.yml @@ -24,7 +24,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: "pip: Python ${{ matrix.python-version }} / ${{ matrix.os }}" - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies diff --git a/.github/workflows/r-cmd-check.yml b/.github/workflows/r-cmd-check.yml index 18e3bbb..a58de39 100644 --- a/.github/workflows/r-cmd-check.yml +++ b/.github/workflows/r-cmd-check.yml @@ -48,6 +48,6 @@ jobs: check-dir: '"check"' - name: artifacts if: ${{ matrix.config.r == 'release' && matrix.config.os == 'ubuntu-latest' }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: path: check \ No newline at end of file