diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 012f9d3..0257f9d 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -55,14 +55,17 @@ jobs: with: python-version: 3.7 + - name: Install build dependencies + run: | + pip install poetry build + - name: Fetch version id: fetch_version - run: echo "::set-output name=version_nr::$(cat VERSION)" + run: echo "::set-output name=version_nr::$(poetry version -s)" - name: Build a binary wheel and a source tarball run: | - pip install setuptools wheel - python setup.py sdist bdist_wheel --python-tag py37.py38.py39.py310 + python -m build - name: Create Release id: create_release diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 50abd09..7c4e831 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,11 +10,11 @@ repos: - id: check-added-large-files - id: check-case-conflict - id: check-merge-conflict -# - id: name-tests-test + # - id: name-tests-test - id: check-docstring-first - id: requirements-txt-fixer - id: detect-private-key -# - id: check-executables-have-shebangs + # - id: check-executables-have-shebangs - repo: https://github.com/pycqa/isort rev: 5.10.1 @@ -51,12 +51,12 @@ repos: - flake8-comprehensions - flake8-tidy-imports - # - repo: https://github.com/mgedmin/check-manifest - # rev: "0.47" - # hooks: - # - id: check-manifest - # args: [ "--no-build-isolation", "--ignore", "*.png,.travis/*,docs/*,paper/*,build_n_install.py,publish.py,readthedocs.yml" ] - # additional_dependencies: [ numpy ] + - repo: https://github.com/mgedmin/check-manifest + rev: "0.48" + hooks: + - id: check-manifest + args: [ "--no-build-isolation", "--ignore", "*.png,docs/*,paper/*,setup.py,publish.py,readthedocs.yml,poetry.lock" ] + additional_dependencies: [ numpy, poetry==1.1.11 ] # TODO sphinx check # - repo: https://github.com/myint/rstcheck diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0c774de..0000000 --- a/.travis.yml +++ /dev/null @@ -1,51 +0,0 @@ -sudo: false -language: python - - -# Test matrix spells out each supported version of Python explicitly: -matrix: - include: - # has to be the same py version specified in tox.ini - -# broken due to dependency incompatibilities (with pinned test dependency versions) -# - python: 3.6 -# env: TOXENV=py36 -# -# - python: 3.7 -# env: TOXENV=py37 - - - python: 3.8 - env: TOXENV=py38 - - -#allow_failures: -# # Tests with ... are allowed to fail -# - env: ... - - -install: - - ./.travis/install.sh - - -script: - - ./.travis/run.sh tox - - -#after_success: -# - coverage combine -# - coveralls - - -branches: - only: - - master - - dev - -notifications: - email: - recipients: - - python@michelfe.it - # options: [always|never|change] default: always - on_success: always - on_failure: always - on_start: never diff --git a/CHANGELOG.rst b/CHANGELOG.rst index fc9705c..ec9ba1e 100755 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,7 @@ Changelog TODOs +* build html docs and include with package: "docs/_build/html/*" * run speed and numerical tests with the new C evaluation method! * Improve tests * compare poly.num_ops of different factorisations. tests? @@ -53,6 +54,11 @@ idea: - the evaluation of subtrees is independent and could theoretically be done in parallel probably not worth the effort. more reasonable to just evaluate multiple polynomials in parallel +3.0.3 (2022-06-15) +__________________ + +* bugfix: packaging. now completely based on pyproject.toml (poetry) + 3.0.2 (2022-06-14) __________________ diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100755 index fdf75dd..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,18 +0,0 @@ -global-exclude *.py[cod] -global-exclude *.coverage - -include CHANGELOG.rst -include CONTRIBUTING.rst -include LICENSE -include README.rst -include VERSION -include .editorconfig -include tox.ini -include requirements* -include runtests.py -include .pre-commit-config.yaml - -recursive-include tests *.py - -recursive-exclude * __pycache__ -recursive-exclude * *.DS_Store diff --git a/VERSION b/VERSION deleted file mode 100644 index b502146..0000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -3.0.2 diff --git a/poetry.lock b/poetry.lock index 01889d5..65859d4 100644 --- a/poetry.lock +++ b/poetry.lock @@ -55,6 +55,27 @@ webencodings = "*" css = ["tinycss2 (>=1.1.0)"] dev = ["pip-tools (==6.5.1)", "pytest (==7.1.1)", "flake8 (==4.0.1)", "tox (==3.24.5)", "sphinx (==4.3.2)", "twine (==4.0.0)", "wheel (==0.37.1)", "hashin (==0.17.0)", "black (==22.3.0)", "mypy (==0.942)"] +[[package]] +name = "build" +version = "0.8.0" +description = "A simple, correct PEP 517 build frontend" +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.dependencies] +colorama = {version = "*", markers = "os_name == \"nt\""} +importlib-metadata = {version = ">=0.22", markers = "python_version < \"3.8\""} +packaging = ">=19.0" +pep517 = ">=0.9.1" +tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} + +[package.extras] +docs = ["furo (>=2021.08.31)", "sphinx (>=4.0,<5.0)", "sphinx-argparse-cli (>=1.5)", "sphinx-autodoc-typehints (>=1.10)"] +test = ["filelock (>=3)", "pytest (>=6.2.4)", "pytest-cov (>=2.12)", "pytest-mock (>=2)", "pytest-rerunfailures (>=9.1)", "pytest-xdist (>=1.34)", "toml (>=0.10.0)", "wheel (>=0.36.0)", "setuptools (>=42.0.0)", "setuptools (>=56.0.0)"] +typing = ["importlib-metadata (>=4.6.4)", "mypy (==0.950)", "typing-extensions (>=3.7.4.3)"] +virtualenv = ["virtualenv (>=20.0.35)"] + [[package]] name = "certifi" version = "2022.5.18.1" @@ -324,6 +345,19 @@ python-versions = ">=3.6" [package.dependencies] pyparsing = ">=2.0.2,<3.0.5 || >3.0.5" +[[package]] +name = "pep517" +version = "0.12.0" +description = "Wrappers to build Python packages using PEP 517 hooks" +category = "dev" +optional = false +python-versions = "*" + +[package.dependencies] +importlib_metadata = {version = "*", markers = "python_version < \"3.8\""} +tomli = {version = ">=1.1.0", markers = "python_version >= \"3.6\""} +zipp = {version = "*", markers = "python_version < \"3.8\""} + [[package]] name = "pkginfo" version = "1.8.3" @@ -872,7 +906,7 @@ numba = ["numba"] [metadata] lock-version = "1.1" python-versions = ">=3.7,<3.11" -content-hash = "9520d278549b5606b90cfb82e0fde27701efc874dc1076ee71e96364cbb31e6a" +content-hash = "2783f192802dd7f9e420dac467d14794b1427378e3c4650113d0809479c58821" [metadata.files] alabaster = [ @@ -895,6 +929,10 @@ bleach = [ {file = "bleach-5.0.0-py3-none-any.whl", hash = "sha256:08a1fe86d253b5c88c92cc3d810fd8048a16d15762e1e5b74d502256e5926aa1"}, {file = "bleach-5.0.0.tar.gz", hash = "sha256:c6d6cc054bdc9c83b48b8083e236e5f00f238428666d2ce2e083eaa5fd568565"}, ] +build = [ + {file = "build-0.8.0-py3-none-any.whl", hash = "sha256:19b0ed489f92ace6947698c3ca8436cb0556a66e2aa2d34cd70e2a5d27cd0437"}, + {file = "build-0.8.0.tar.gz", hash = "sha256:887a6d471c901b1a6e6574ebaeeebb45e5269a79d095fe9a8f88d6614ed2e5f0"}, +] certifi = [ {file = "certifi-2022.5.18.1-py3-none-any.whl", hash = "sha256:f1d53542ee8cbedbe2118b5686372fb33c297fcd6379b050cca0ef13a597382a"}, {file = "certifi-2022.5.18.1.tar.gz", hash = "sha256:9c5705e395cd70084351dd8ad5c41e65655e08ce46f2ec9cf6c2c08390f71eb7"}, @@ -1221,6 +1259,10 @@ packaging = [ {file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"}, {file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"}, ] +pep517 = [ + {file = "pep517-0.12.0-py2.py3-none-any.whl", hash = "sha256:dd884c326898e2c6e11f9e0b64940606a93eb10ea022a2e067959f3a110cf161"}, + {file = "pep517-0.12.0.tar.gz", hash = "sha256:931378d93d11b298cf511dd634cf5ea4cb249a28ef84160b3247ee9afb4e8ab0"}, +] pkginfo = [ {file = "pkginfo-1.8.3-py2.py3-none-any.whl", hash = "sha256:848865108ec99d4901b2f7e84058b6e7660aae8ae10164e015a6dcf5b242a594"}, {file = "pkginfo-1.8.3.tar.gz", hash = "sha256:a84da4318dd86f870a9447a8c98340aa06216bfc6f2b7bdc4b8766984ae1867c"}, diff --git a/publish.py b/publish.py deleted file mode 100755 index 07b6abd..0000000 --- a/publish.py +++ /dev/null @@ -1,179 +0,0 @@ -#!/usr/bin/env python -""" -in order to create virtual environment with the required (dev) dependencies: - - make venv - -TODO use bandit to check for vulnerabilities: - -conda install bandit -bandit ./multivar_horner/*.py - -""" - -import os -import re -import sys -from os.path import abspath, isfile, join, pardir - -PACKAGE = "multivar_horner" -VERSION_FILE = "VERSION" -VIRT_ENV_NAME = PACKAGE -VIRT_ENV_COMMAND = "poetry run" -PY_VERSION_IDS = [ - "37", - "38", - "39", -] # the supported python versions to create wheels for -PYTHON_TAG = ".".join([f"py{v}" for v in PY_VERSION_IDS]) - - -# TODO not required, set version in version file -def get_version(): - return open(VERSION_FILE, "r").read().strip() - - -def parse_version(new_version_input="", old_version_str="1.0.0"): - new_version_input = re.search(r"\d\.\d\.\d+", new_version_input) - - if new_version_input is None: - raise ValueError # will cause new input request - else: - new_version_input = new_version_input.group() - - # print(new_version_input) - - split_new_version = [int(x) for x in new_version_input.split(".")] - # print(split_new_version) - split_old_version = [int(x) for x in old_version_str.split(".")] - # print(split_old_version) - - for i in range(3): - if split_new_version[i] > split_old_version[i]: - break - if split_new_version[i] < split_old_version[i]: - raise ValueError # will cause new input request - - return new_version_input - - -def set_version(new_version_str): - with open(VERSION_FILE, "w") as version_file: - version_file.write(new_version_str) - - -def routine(cmd=None, message="", option1="next", option2="exit"): - while 1: - print(message) - - if cmd: - print("running command:", cmd) - os.system(cmd) - - print("__________\nDone. Options:") - print("1)", option1) - print("2)", option2) - print("anything else to repeat this step.") - try: - inp = int(input()) - - if inp == 1: - print("==============") - break - if inp == 2: - sys.exit() - - except ValueError: - pass - print("================") - - -if __name__ == "__main__": - old_version = get_version() - - print("The actual version number is:", old_version) - print("Enter new version number:") - version_input = None - while 1: - try: - version_input = input() - version_str = parse_version(version_input, old_version) - set_version(version_str) - break - except ValueError: - print( - f'Invalid version input. Should be of format "x.x.xxx" and higher than the old version {old_version}.' - ) - pass # try again - - version = get_version() - print("the version number has been set to:", version) - print("=====================") - - routine( - None, - f"Current py versions: {PY_VERSION_IDS}\n" - "Remember to properly specify all supported python versions in this file and setup.py", - ) - routine( - None, - "Have all pinned dependencies been listed in setup.py", - ) - routine(None, "Have all (new) features been documented?") - routine(None, f"Remember to write a changelog for version {version}") - routine(None, "Remember to update MANIFEST.in if the packate content has chanted") - - print("___________") - print("Running TESTS:") - - # TODO ask - # routine(VIRT_ENV_COMMAND + "pip-compile requirements_numba.in;pip-sync", - # 'pinning the requirements.txt and bringing virtualEnv to exactly the specified state:', 'next: build check') - - routine( - f"{VIRT_ENV_COMMAND} rstcheck *.rst", - "checking syntax of all .rst files:", - "next: build check", - ) - - print("generating documentation now...") - routine("make docs", "run tests") - - print("done.") - - routine(f"{VIRT_ENV_COMMAND} tox", "run tests") - print("Tests finished.") - - routine( - None, - "Please commit your changes, push, raise PR and wait if the GHA workflow is successful. " - "Only then merge PR into the master.", - "CI tests passed & merge into master complete. Build and upload now.", - ) - - print("=================") - print("PUBLISHING:") - - # routine("python3 setup.py sdist bdist_wheel upload", 'Uploading the package now.') # deprecated - # new twine publishing routine: - # https://packaging.python.org/tutorials/packaging-projects/ - # delete the build folder before to get a fresh build - routine( - f"rm -r -f build; python setup.py sdist bdist_wheel --python-tag {PYTHON_TAG}", - "building the package now.", - "build done. check the included files! test uploading.", - ) - - path = abspath(join(__file__, pardir, "dist")) - all_archives_this_version = [f for f in os.listdir(path) if isfile(join(path, f)) and version_str in f] - paths2archives = [abspath(join(path, f)) for f in all_archives_this_version] - command = "twine upload --repository-url https://test.pypi.org/legacy/ " + " ".join(paths2archives) - - # upload all archives of this version - routine(f"{VIRT_ENV_COMMAND} {command}", "testing if upload works.") - - command = "twine upload " + " ".join(paths2archives) - routine(f"{VIRT_ENV_COMMAND} {command}", "real upload to PyPI.") - - # NOTE: tags and releases are being created automatically through GHA - print(f"______________\nCongrats! Published version {version}.") diff --git a/pyproject.toml b/pyproject.toml index 4672107..4a7eece 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,39 @@ [tool.poetry] name = "multivar_horner" -version = "3.0.2" -description = "" +version = "3.0.3" +license = "MIT" +readme = "README.rst" +repository = "https://github.com/jannikmi/multivar_horner" +homepage = "https://multivar-horner.readthedocs.io/en/latest/" +documentation = "https://multivar-horner.readthedocs.io/en/latest/" +keywords = ["mathematics", "polynomials", "evaluation", "multivariate", "horner-scheme"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Intended Audience :: Information Technology", + "Intended Audience :: Science/Research", + "Natural Language :: English", + "Operating System :: OS Independent", + "Topic :: Scientific/Engineering", + "Topic :: Scientific/Engineering :: Mathematics", + "Topic :: Scientific/Engineering :: Physics", +] +description = "python package implementing a multivariate Horner scheme for efficiently evaluating multivariate polynomials" authors = ["jannikmi "] +include = [ + ".editorconfig", + ".pre-commit-config.yaml", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "LICENSE", + "Makefile", + "README.rst", + "runtests.py", + "tox.ini", + "tests/*.py", +] +#exclude = ["my_package/excluded.py"] + [tool.poetry.dependencies] python = ">=3.7,<3.11" @@ -19,6 +50,7 @@ pre-commit = "^2.15.0" sphinxcontrib-bibtex = "^2.4.1" sphinx-rtd-theme = "^1.0.0" rstcheck = "^3.3.1" +build = "^0.8.0" [tool.poetry.extras] numba = ["numba"] diff --git a/runtests.py b/runtests.py index 53ba5ac..c095216 100755 --- a/runtests.py +++ b/runtests.py @@ -1,7 +1,5 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - import sys import pytest diff --git a/setup.cfg b/setup.cfg deleted file mode 100755 index 77ac8bb..0000000 --- a/setup.cfg +++ /dev/null @@ -1,45 +0,0 @@ -[metadata] -version = file: VERSION -long_description = file: README.rst -long_description_content_type = text/x-rst -license_file = LICENSE - -[bdist_wheel] -; does not run on Python 2 and 3 -universal = 0 - -[isort] -;https://github.com/timothycrosley/isort/wiki/isort-Settings -known_first_party = multivar_horner -known_third_party = numpy, numba -line_length = 120 - -[flake8] -max_line_length = 120 -;trailing comma -ignore = C819 - -[tool:multilint] -paths = multivar_horner - setup.py - tests - -[tool:pytest] -testpaths = tests -;addopts = --cov=multivar_horner -; --cov-report term-missing - -[coverage:run] -;branch = True -include = */multivar_horner/* - -[coverage:paths] -source = - multivar_horner - .tox/*/site-packages - -[coverage:report] -show_missing = True - -[mypy] -plugins = pydantic.mypy diff --git a/setup.py b/setup.py deleted file mode 100755 index 64b6f33..0000000 --- a/setup.py +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env python -# -*- coding:utf-8 -*- - -from setuptools import setup - -setup( - name="multivar_horner", - packages=["multivar_horner"], - description="python package implementing a multivariate Horner scheme for efficiently " - "evaluating multivariate polynomials", - long_description="python package implementing a multivariate Horner scheme " - "for efficiently evaluating multivariate polynomials \n\n" - "for more refer to the documentation: https://multivar_horner.readthedocs.io/en/latest/", - # version: in VERSION file https://packaging.python.org/guides/single-sourcing-package-version/ - # With this approach you must make sure that the VERSION file is included in all your source - # and binary distributions (e.g. add include VERSION to your MANIFEST.in). - author="Jannik Michelfeit", - author_email="python@michelfe.it", - license="MIT licence", - url="https://github.com/jannikmi/multivar_horner", # use the URL to the github repo - project_urls={ - "Source Code": "https://github.com/jannikmi/multivar_horner", - "Documentation": "https://multivar_horner.readthedocs.io/en/latest/", - "Changelog": "https://github.com/jannikmi/multivar_horner/blob/master/CHANGELOG.rst", - }, - keywords="math mathematics polynomial polynomials polynomial-evaluation multivariate multivariate-polynomials" - " horner horner-scheme factorisation factorization", - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "Intended Audience :: Information Technology", - "Intended Audience :: Science/Research", - "License :: OSI Approved :: MIT License", - "Natural Language :: English", - "Operating System :: OS Independent", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Topic :: Scientific/Engineering", - "Topic :: Scientific/Engineering :: Mathematics", - "Topic :: Scientific/Engineering :: Physics", - ], - install_requires=[ - "numpy>=1.21", - ], - extras_require={"numba": ["numba>=0.55"]}, - python_requires=">=3.7", -) diff --git a/tox.ini b/tox.ini index 36180a2..2feccee 100644 --- a/tox.ini +++ b/tox.ini @@ -19,3 +19,40 @@ commands = numba: poetry install -v --extras "numba" !numba: poetry install -v poetry run ./runtests.py {posargs} + + +[isort] +;https://github.com/timothycrosley/isort/wiki/isort-Settings +known_first_party = multivar_horner +known_third_party = numpy, numba +line_length = 120 + +[flake8] +max_line_length = 120 +;trailing comma +ignore = C819 + +[tool:multilint] +paths = multivar_horner + setup.py + tests + +[tool:pytest] +testpaths = tests +;addopts = --cov=multivar_horner +; --cov-report term-missing + +[coverage:run] +;branch = True +include = */multivar_horner/* + +[coverage:paths] +source = + multivar_horner + .tox/*/site-packages + +[coverage:report] +show_missing = True + +[mypy] +plugins = pydantic.mypy