From a70a7b8728d68d8bd06e6d1243326cad0c42f5a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrik=20Sch=C3=B6nfeldt?= Date: Wed, 26 Jun 2024 09:28:10 +0200 Subject: [PATCH 01/16] Merge MANIFEST.in into pyproject.toml --- MANIFEST.in | 22 ---------------------- pyproject.toml | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 22 deletions(-) delete mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 0879c94..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,22 +0,0 @@ -graft docs -graft src -graft ci -graft tests - -include .bumpversion.cfg -include .cookiecutterrc -include .coveragerc -include .editorconfig -include tox.ini -include .appveyor.yml -include .readthedocs.yml -include AUTHORS.rst -include CHANGELOG.rst -include CONTRIBUTING.rst -include LICENSE -include README.rst - -recursive-include examples *.csv -recursive-include examples *.py - -global-exclude *.py[cod] __pycache__/* *.so *.dylib diff --git a/pyproject.toml b/pyproject.toml index dc9c5ad..8b1a7c8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,25 @@ +[tool.flit.sdist] +include = [ + ".bumpversion.cfg", + ".cookiecutterrc", + ".coveragerc", + ".editorconfig", + "tox.ini", + ".appveyor.yml", + ".readthedocs.yml", + "AUTHORS.rst", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "LICENSE", + "README.rst", + "examples/", + "docs/", + "src/", + "ci/", + "tests/", +] +exclude = ["__pycache__/"] + [tool.black] line-length = 79 target-version = ['py37', 'py38'] From 5ab1d381c729c101a95073bbb342de8d0e1af1c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrik=20Sch=C3=B6nfeldt?= Date: Wed, 26 Jun 2024 11:49:19 +0200 Subject: [PATCH 02/16] Update Python version support info --- setup.py | 8 +++----- tox.ini | 19 +++++++++---------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/setup.py b/setup.py index 7725967..3daaf7b 100644 --- a/setup.py +++ b/setup.py @@ -52,11 +52,9 @@ def read(*names, **kwargs): "Operating System :: Microsoft :: Windows", "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", + "Programming Language :: Python :: 3.11", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Utilities", @@ -69,7 +67,7 @@ def read(*names, **kwargs): keywords=[ # eg: 'keyword1', 'keyword2', 'keyword3', ], - python_requires=">=3.6", + python_requires=">=3.8", install_requires=["numpy >= 1.17.0", "pandas >= 1.0"], package_data={ "demandlib": [join("bdew_data", "*.csv")], diff --git a/tox.ini b/tox.ini index cf359c8..2229179 100644 --- a/tox.ini +++ b/tox.ini @@ -3,19 +3,18 @@ envlist = clean, check, docs, - py36 - py37 - py38 - py39 + py39, + py310, + py311, py3-cover, pypy3, report [gh-actions] python = - 3.7: py37 - 3.8: py38 3.9: py39 + 3.10: py310 + 3.11: py311 [testenv] basepython = @@ -83,8 +82,8 @@ commands = coverage erase skip_install = true deps = coverage -[testenv:py36] -basepython = {env:TOXPYTHON:python3.6} +[testenv:py310] +basepython = {env:TOXPYTHON:python3.10} setenv = {[testenv]setenv} usedevelop = true @@ -94,8 +93,8 @@ deps = {[testenv]deps} pytest-cov -[testenv:py37] -basepython = {env:TOXPYTHON:python3.7} +[testenv:py311] +basepython = {env:TOXPYTHON:python3.11} setenv = {[testenv]setenv} usedevelop = true From 2485da2d1fb6a1f1539c1c8a7146da280179a5f4 Mon Sep 17 00:00:00 2001 From: Francesco Witte Date: Thu, 27 Jun 2024 10:57:13 +0200 Subject: [PATCH 03/16] Remove a lot of old junk --- .bumpversion.cfg | 24 -------- .cookiecutterrc | 71 ------------------------ ci/bootstrap.py | 92 ------------------------------- ci/requirements.txt | 4 -- ci/templates/.appveyor.yml | 49 ----------------- ci/templates/tox.ini | 109 ------------------------------------- setup.cfg | 102 ---------------------------------- setup.py | 78 -------------------------- 8 files changed, 529 deletions(-) delete mode 100644 .bumpversion.cfg delete mode 100644 .cookiecutterrc delete mode 100755 ci/bootstrap.py delete mode 100644 ci/requirements.txt delete mode 100644 ci/templates/.appveyor.yml delete mode 100644 ci/templates/tox.ini delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.bumpversion.cfg b/.bumpversion.cfg deleted file mode 100644 index 54b9621..0000000 --- a/.bumpversion.cfg +++ /dev/null @@ -1,24 +0,0 @@ -[bumpversion] -current_version = 0.1.10 -commit = True -tag = True - -[bumpversion:file:setup.py] -search = version='{current_version}' -replace = version='{new_version}' - -[bumpversion:file (badge):README.rst] -search = /v{current_version}.svg -replace = /v{new_version}.svg - -[bumpversion:file (link):README.rst] -search = /v{current_version}...master -replace = /v{new_version}...master - -[bumpversion:file:docs/conf.py] -search = version = release = '{current_version}' -replace = version = release = '{new_version}' - -[bumpversion:file:src/demandlib/__init__.py] -search = __version__ = '{current_version}' -replace = __version__ = '{new_version}' diff --git a/.cookiecutterrc b/.cookiecutterrc deleted file mode 100644 index 1c0678b..0000000 --- a/.cookiecutterrc +++ /dev/null @@ -1,71 +0,0 @@ -# This file exists so you can easily regenerate your project. -# -# `cookiepatcher` is a convenient shim around `cookiecutter` -# for regenerating projects (it will generate a .cookiecutterrc -# automatically for any template). To use it: -# -# pip install cookiepatcher -# cookiepatcher gh:ionelmc/cookiecutter-pylibrary demandlib -# -# See: -# https://pypi.org/project/cookiepatcher -# -# Alternatively, you can run: -# -# cookiecutter --overwrite-if-exists --config-file=demandlib/.cookiecutterrc gh:ionelmc/cookiecutter-pylibrary - -default_context: - - _extensions: ['jinja2_time.TimeExtension'] - _template: 'gh:ionelmc/cookiecutter-pylibrary' - allow_tests_inside_package: 'yes' - appveyor: 'yes' - c_extension_function: 'longest' - c_extension_module: '_demandlib' - c_extension_optional: 'no' - c_extension_support: 'no' - c_extension_test_pypi: 'no' - c_extension_test_pypi_username: 'oemof' - codacy: 'no' - codacy_projectid: 'CODACY_ID' - codeclimate: 'no' - codecov: 'yes' - command_line_interface: 'no' - command_line_interface_bin_name: 'demandlib' - coveralls: 'yes' - coveralls_token: 'COVERALLS_TOKEN' - distribution_name: 'demandlib' - email: 'contact@oemof.org' - full_name: 'oemof developer group' - legacy_python: 'no' - license: 'MIT license' - linter: 'flake8' - package_name: 'demandlib' - pre_commit: 'no' - project_name: 'oemof' - project_short_description: 'Creating heat and power demand profiles from annual values.' - pypi_badge: 'yes' - pypi_disable_upload: 'no' - release_date: 'today' - repo_hosting: 'github.com' - repo_hosting_domain: 'github.com' - repo_name: 'demandlib' - repo_username: 'oemof' - requiresio: 'yes' - scrutinizer: 'no' - setup_py_uses_setuptools_scm: 'no' - setup_py_uses_test_runner: 'no' - sphinx_docs: 'yes' - sphinx_docs_hosting: 'https://demandlib.readthedocs.io/' - sphinx_doctest: 'no' - sphinx_theme: 'sphinx-rtd-theme' - test_matrix_configurator: 'yes' - test_matrix_separate_coverage: 'yes' - test_runner: 'pytest' - travis: 'no' - travis_osx: 'no' - version: '0.1.10' - version_manager: 'bump2version' - website: 'oemof.org' - year_from: '2016' - year_to: '2021' diff --git a/ci/bootstrap.py b/ci/bootstrap.py deleted file mode 100755 index 7e42276..0000000 --- a/ci/bootstrap.py +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -from __future__ import absolute_import -from __future__ import print_function -from __future__ import unicode_literals - -import os -import subprocess -import sys -from os.path import abspath -from os.path import dirname -from os.path import exists -from os.path import join - -base_path = dirname(dirname(abspath(__file__))) - - -def check_call(args): - print("+", *args) - subprocess.check_call(args) - - -def exec_in_env(): - env_path = join(base_path, ".tox", "bootstrap") - if sys.platform == "win32": - bin_path = join(env_path, "Scripts") - else: - bin_path = join(env_path, "bin") - if not exists(env_path): - import subprocess - - print("Making bootstrap env in: {0} ...".format(env_path)) - try: - check_call([sys.executable, "-m", "venv", env_path]) - except subprocess.CalledProcessError: - try: - check_call([sys.executable, "-m", "virtualenv", env_path]) - except subprocess.CalledProcessError: - check_call(["virtualenv", env_path]) - print("Installing `jinja2` into bootstrap environment...") - check_call([join(bin_path, "pip"), "install", "jinja2", "tox", "matrix"]) - python_executable = join(bin_path, "python") - if not os.path.exists(python_executable): - python_executable += '.exe' - - print("Re-executing with: {0}".format(python_executable)) - print("+ exec", python_executable, __file__, "--no-env") - os.execv(python_executable, [python_executable, __file__, "--no-env"]) - - -def main(): - import jinja2 - import matrix - - print("Project path: {0}".format(base_path)) - - jinja = jinja2.Environment( - loader=jinja2.FileSystemLoader(join(base_path, "ci", "templates")), - trim_blocks=True, - lstrip_blocks=True, - keep_trailing_newline=True - ) - - tox_environments = {} - for (alias, conf) in matrix.from_file(join(base_path, "setup.cfg")).items(): - deps = conf["dependencies"] - tox_environments[alias] = { - "deps": deps.split(), - } - if "coverage_flags" in conf: - cover = {"false": False, "true": True}[conf["coverage_flags"].lower()] - tox_environments[alias].update(cover=cover) - if "environment_variables" in conf: - env_vars = conf["environment_variables"] - tox_environments[alias].update(env_vars=env_vars.split()) - - for name in os.listdir(join("ci", "templates")): - with open(join(base_path, name), "w") as fh: - fh.write(jinja.get_template(name).render(tox_environments=tox_environments)) - print("Wrote {}".format(name)) - print("DONE.") - - -if __name__ == "__main__": - args = sys.argv[1:] - if args == ["--no-env"]: - main() - elif not args: - exec_in_env() - else: - print("Unexpected arguments {0}".format(args), file=sys.stderr) - sys.exit(1) diff --git a/ci/requirements.txt b/ci/requirements.txt deleted file mode 100644 index d7f5177..0000000 --- a/ci/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -virtualenv>=16.6.0 -pip>=19.1.1 -setuptools>=18.0.1 -six>=1.14.0 diff --git a/ci/templates/.appveyor.yml b/ci/templates/.appveyor.yml deleted file mode 100644 index 5a659be..0000000 --- a/ci/templates/.appveyor.yml +++ /dev/null @@ -1,49 +0,0 @@ -version: '{branch}-{build}' -build: off -image: Visual Studio 2019 -environment: - global: - COVERALLS_EXTRAS: '-v' - COVERALLS_REPO_TOKEN: COVERALLS_TOKEN - matrix: - - TOXENV: check - TOXPYTHON: C:\Python36\python.exe - PYTHON_HOME: C:\Python36 - PYTHON_VERSION: '3.6' - PYTHON_ARCH: '32' -{% for env, config in tox_environments|dictsort %} -{% if env.startswith(('py2', 'py3')) %} - - TOXENV: {{ env }}{% if config.cover %},codecov,coveralls{% endif %}{{ "" }} - TOXPYTHON: C:\Python{{ env[2:4] }}\python.exe - PYTHON_HOME: C:\Python{{ env[2:4] }} - PYTHON_VERSION: '{{ env[2] }}.{{ env[3] }}' - PYTHON_ARCH: '32' -{% if 'nocov' in env %} - WHEEL_PATH: .tox/dist -{% endif %} - - TOXENV: {{ env }}{% if config.cover %},codecov,coveralls{% endif %}{{ "" }} - TOXPYTHON: C:\Python{{ env[2:4] }}-x64\python.exe - PYTHON_HOME: C:\Python{{ env[2:4] }}-x64 - PYTHON_VERSION: '{{ env[2] }}.{{ env[3] }}' - PYTHON_ARCH: '64' -{% if 'nocov' in env %} - WHEEL_PATH: .tox/dist -{% endif %} -{% endif %}{% endfor %} -init: - - ps: echo $env:TOXENV - - ps: ls C:\Python* -install: - - '%PYTHON_HOME%\python -mpip install --progress-bar=off tox -rci/requirements.txt' - - '%PYTHON_HOME%\Scripts\virtualenv --version' - - '%PYTHON_HOME%\Scripts\pip --version' - - '%PYTHON_HOME%\Scripts\tox --version' -test_script: - - %PYTHON_HOME%\Scripts\tox -on_failure: - - ps: dir "env:" - - ps: get-content .tox\*\log\* - -### To enable remote debugging uncomment this (also, see: http://www.appveyor.com/docs/how-to/rdp-to-build-worker): -# on_finish: -# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) diff --git a/ci/templates/tox.ini b/ci/templates/tox.ini deleted file mode 100644 index b9536cf..0000000 --- a/ci/templates/tox.ini +++ /dev/null @@ -1,109 +0,0 @@ -[tox] -envlist = - clean, - check, - docs, -{% for env in tox_environments|sort %} - {{ env }}, -{% endfor %} - report - -[testenv] -basepython = - {bootstrap,clean,check,report,docs,codecov,coveralls}: {env:TOXPYTHON:python3} -setenv = - PYTHONPATH={toxinidir}/tests - PYTHONUNBUFFERED=yes -passenv = - * -deps = - pytest -commands = - {posargs:pytest -vv --ignore=src} - -[testenv:bootstrap] -deps = - jinja2 - matrix -skip_install = true -commands = - python ci/bootstrap.py --no-env - -[testenv:check] -deps = - docutils - check-manifest - flake8 - readme-renderer - pygments - isort -skip_install = true -commands = - python setup.py check --strict --metadata --restructuredtext - check-manifest {toxinidir} - flake8 - isort --verbose --check-only --diff --filter-files . - - -[testenv:docs] -usedevelop = true -deps = - -r{toxinidir}/docs/requirements.txt -commands = - sphinx-build {posargs:-E} -b html docs dist/docs - sphinx-build -b linkcheck docs dist/docs - -[testenv:coveralls] -deps = - coveralls -skip_install = true -commands = - coveralls [] - - - -[testenv:codecov] -deps = - codecov -skip_install = true -commands = - codecov [] - -[testenv:report] -deps = coverage -skip_install = true -commands = - coverage report - coverage html - -[testenv:clean] -commands = coverage erase -skip_install = true -deps = coverage -{% for env, config in tox_environments|dictsort %} - -[testenv:{{ env }}] -basepython = {env:TOXPYTHON:{{ env.split("-")[0] if env.startswith("pypy") else "python{0[2]}.{0[3]}".format(env) }}} -{% if config.cover or config.env_vars %} -setenv = - {[testenv]setenv} -{% endif %} -{% for var in config.env_vars %} - {{ var }} -{% endfor %} -{% if config.cover %} -usedevelop = true -commands = - {posargs:pytest --cov --cov-report=term-missing -vv} -{% endif %} -{% if config.cover or config.deps %} -deps = - {[testenv]deps} -{% endif %} -{% if config.cover %} - pytest-cov -{% endif %} -{% for dep in config.deps %} - {{ dep }} -{% endfor -%} -{% endfor -%} diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 3f6a0ec..0000000 --- a/setup.cfg +++ /dev/null @@ -1,102 +0,0 @@ -[bdist_wheel] -universal = 1 - -[flake8] -max-line-length = 140 -exclude = .tox,.eggs,ci/templates,build,dist - -[tool:pytest] -# If a pytest section is found in one of the possible config files -# (pytest.ini, tox.ini or setup.cfg), then pytest will not look for any others, -# so if you add a pytest config section elsewhere, -# you will need to delete this section from setup.cfg. -norecursedirs = - .git - .tox - .env - dist - build - migrations - -python_files = - test_*.py - *_test.py - tests.py -addopts = - -ra - --strict-markers - --ignore=docs/conf.py - --ignore=setup.py - --ignore=ci - --ignore=.eggs - --doctest-modules - --doctest-glob=\*.rst - --tb=short - --pyargs -# The order of these options matters. testpaths comes after addopts so that -# demandlib in testpaths is interpreted as -# --pyargs demandlib. -# Any tests in the src/ directory (that is, tests installed with the package) -# can be run by any user with pytest --pyargs demandlib. -# Packages that are sensitive to the host machine, most famously NumPy, -# include tests with the installed package so that any user can check -# at any time that everything is working properly. -# If you do choose to make installable tests, this will run the installed -# tests as they are actually installed (same principle as when we ensure that -# we always test the installed version of the package). -# If you have no need for this (and your src/ directory is very large), -# you can save a few milliseconds on testing by telling pytest not to search -# the src/ directory by removing -# --pyargs and demandlib from the options here. -testpaths = - demandlib - tests/ - -[tool:isort] -force_single_line = True -line_length = 120 -known_first_party = demandlib -default_section = THIRDPARTY -forced_separate = test_demandlib -skip = .tox,.eggs,ci/templates,build,dist - -[matrix] -# This is the configuration for the `./bootstrap.py` script. -# It generates `.travis.yml`, `tox.ini` and `.appveyor.yml`. -# -# Syntax: [alias:] value [!variable[glob]] [&variable[glob]] -# -# alias: -# - is used to generate the tox environment -# - it's optional -# - if not present the alias will be computed from the `value` -# value: -# - a value of "-" means empty -# !variable[glob]: -# - exclude the combination of the current `value` with -# any value matching the `glob` in `variable` -# - can use as many you want -# &variable[glob]: -# - only include the combination of the current `value` -# when there's a value matching `glob` in `variable` -# - can use as many you want - -python_versions = - py36 - py37 - py38 - py39 - pypy3 - -dependencies = -# 1.4: Django==1.4.16 !python_versions[py3*] -# 1.5: Django==1.5.11 -# 1.6: Django==1.6.8 -# 1.7: Django==1.7.1 !python_versions[py26] -# Deps commented above are provided as examples. That's what you would use in a Django project. - -coverage_flags = - cover: true - nocov: false -environment_variables = - - diff --git a/setup.py b/setup.py deleted file mode 100644 index 3daaf7b..0000000 --- a/setup.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -import io -import re -from glob import glob -from os.path import basename -from os.path import dirname -from os.path import join -from os.path import splitext - -from setuptools import find_packages -from setuptools import setup - - -def read(*names, **kwargs): - with io.open( - join(dirname(__file__), *names), - encoding=kwargs.get("encoding", "utf8"), - ) as fh: - return fh.read() - - -setup( - name="demandlib", - version="0.1.10", - license="MIT", - description="Creating heat and power demand profiles from annual values.", - long_description="%s" - % ( - re.compile("^.. start-badges.*^.. end-badges", re.M | re.S).sub( - "", read("README.rst") - ) - ), - long_description_content_type="text/x-rst", - author="oemof developer group", - author_email="contact@oemof.org", - url="https://github.com/oemof/demandlib", - packages=find_packages("src"), - package_dir={"": "src"}, - py_modules=[splitext(basename(path))[0] for path in glob("src/*.py")], - include_package_data=True, - zip_safe=False, - classifiers=[ - # complete classifier list: - # http://pypi.python.org/pypi?%3Aaction=list_classifiers - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", - "Operating System :: Unix", - "Operating System :: POSIX", - "Operating System :: Microsoft :: Windows", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy", - "Topic :: Utilities", - ], - project_urls={ - "Documentation": "https://demandlib.readthedocs.io/", - "Changelog": "https://demandlib.readthedocs.io/en/latest/changelog.html", - "Issue Tracker": "https://github.com/oemof/demandlib/issues", - }, - keywords=[ - # eg: 'keyword1', 'keyword2', 'keyword3', - ], - python_requires=">=3.8", - install_requires=["numpy >= 1.17.0", "pandas >= 1.0"], - package_data={ - "demandlib": [join("bdew_data", "*.csv")], - }, - extras_require={ - "dev": ["pytest", "sphinx", "sphinx_rtd_theme", "matplotlib"], - }, -) From ab75918a08ff98b506f1508a31d7794852897ca6 Mon Sep 17 00:00:00 2001 From: Francesco Witte Date: Thu, 27 Jun 2024 10:57:27 +0200 Subject: [PATCH 04/16] Add features into pyproject.toml --- pyproject.toml | 102 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 95 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 8b1a7c8..b52b8d1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,13 @@ +[build-system] +requires = ["flit_core >=3.2,<4"] +build-backend = "flit_core.buildapi" + [tool.flit.sdist] include = [ - ".bumpversion.cfg", - ".cookiecutterrc", ".coveragerc", ".editorconfig", - "tox.ini", - ".appveyor.yml", ".readthedocs.yml", + "tox.ini", "AUTHORS.rst", "CHANGELOG.rst", "CONTRIBUTING.rst", @@ -15,14 +16,62 @@ include = [ "examples/", "docs/", "src/", - "ci/", "tests/", ] -exclude = ["__pycache__/"] +exclude = ["docs/_build", "**/*.egg-info"] + +[project] +name = "demandlib" +dynamic = ["version"] +description = "Creating heat and power demand profiles from annual values" +readme = "README.rst" +authors = [ + {name = "oemof developer group", email = "contact@oemof.org"}, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Operating System :: Unix", + "Operating System :: POSIX", + "Operating System :: Microsoft :: Windows", + "Operating System :: MacOS", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: Implementation :: CPython", + "Topic :: Utilities", +] +requires-python = ">=3.8" +dependencies = [ + "numpy >= 1.17.0", + "pandas >= 1.0", +] +license = {text = "MIT"} + +[project.urls] +Homepage = "https://github.com/oemof/demandlib" +Documentation = "https://demandlib.readthedocs.io/" +Changelog = "https://demandlib.readthedocs.io/en/latest/changelog.html" +"Issue Tracker" = "https://github.com/oemof/demandlib/issues/" + +[project.optional-dependencies] +dev = [ + "flit", + "matplotlib", + "pytest", + "sphinx", + "sphinx_rtd_theme", + "tox", +] [tool.black] line-length = 79 -target-version = ['py37', 'py38'] +target-version = ['py39', 'py310', 'py311'] include = '\.pyi?$' exclude = ''' /( @@ -39,3 +88,42 @@ exclude = ''' | ci )/ ''' + +[tool.pytest.ini_options] +norecursedirs = [ + ".git", + ".tox", + ".env", + "dist", + "docs/_build", + "examples", +] +python_files = [ + "test_*.py", + "*_test.py", + "*_tests.py", + "tests.py", +] +addopts = """ + -ra + --strict-markers + --ignore=docs/conf.py + --ignore=.eggs + --doctest-modules + --doctest-glob=\\*.rst + --tb=short + --pyargs +""" +testpaths = [ + "src/", + "tests/", + "docs/", +] + +[tool.isort] +force_single_line = true +line_length = 79 +known_first_party = "demandlib" +default_section = "THIRDPARTY" +forced_separate = "test_demandlib" +skip = "migrations" From 28e947c1b2511500c7391b418aea8b25b4b6db16 Mon Sep 17 00:00:00 2001 From: Francesco Witte Date: Thu, 27 Jun 2024 11:24:09 +0200 Subject: [PATCH 05/16] Tidy up tox.ini and fix the dependecies --- .github/workflows/packaging.yml | 5 ++-- pyproject.toml | 19 +++++++++++++-- tox.ini | 43 ++++++++++++--------------------- 3 files changed, 36 insertions(+), 31 deletions(-) diff --git a/.github/workflows/packaging.yml b/.github/workflows/packaging.yml index efef29c..f7c22a2 100644 --- a/.github/workflows/packaging.yml +++ b/.github/workflows/packaging.yml @@ -26,9 +26,10 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - python -m pip install --upgrade pip setuptools setuptools_scm twine wheel + python -m pip install --upgrade pip + python -m pip install -e .[build] - name: Create packages - run: python setup.py sdist bdist_wheel + run: python -m build . - name: Run twine check run: twine check dist/* - uses: actions/upload-artifact@v4 diff --git a/pyproject.toml b/pyproject.toml index b52b8d1..0c7571b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,12 +60,27 @@ Changelog = "https://demandlib.readthedocs.io/en/latest/changelog.html" "Issue Tracker" = "https://github.com/oemof/demandlib/issues/" [project.optional-dependencies] -dev = [ +build = [ + "build", + "check-manifest", + "flake8", "flit", + "isort", + "pygments", + "readme-renderer", + "twine", +] +docs = [ "matplotlib", - "pytest", "sphinx", "sphinx_rtd_theme", +] +test = [ + "pytest", + "coverage", + "coveralls", +] +tox = [ "tox", ] diff --git a/tox.ini b/tox.ini index 6c30915..decfc01 100644 --- a/tox.ini +++ b/tox.ini @@ -31,41 +31,29 @@ deps = commands = {posargs:pytest -vv --ignore=src} -[testenv:bootstrap] -deps = - jinja2 - matrix -skip_install = true -commands = - python ci/bootstrap.py --no-env - [testenv:check] -deps = - docutils - check-manifest - flake8 - readme-renderer - pygments - isort -skip_install = true +usedevelop = true +extras = + build + docs + test commands = - python setup.py check --strict --metadata --restructuredtext + python -m build . + twine check dist/demandlib* check-manifest {toxinidir} - flake8 - isort --verbose --check-only --diff --filter-files . + flake8 src tests + isort --check-only --profile black --diff src tests [testenv:docs] usedevelop = true -deps = - -r{toxinidir}/docs/requirements.txt +extras = docs commands = - sphinx-build {posargs:-E} -b html docs dist/docs - sphinx-build -b linkcheck docs dist/docs + sphinx-build {posargs:-E} -b html docs docs/_build + sphinx-build -b linkcheck docs docs/_build [testenv:coveralls] -deps = - coveralls +deps = coveralls skip_install = true commands = coveralls [] @@ -78,9 +66,10 @@ commands = coverage html [testenv:clean] -commands = coverage erase -skip_install = true deps = coverage +skip_install = true +commands = + coverage erase [testenv:py39] basepython = {env:TOXPYTHON:python3.9} From e9aaa1a761401353a7930696cfca9cc1e1cbf409 Mon Sep 17 00:00:00 2001 From: Francesco Witte Date: Thu, 27 Jun 2024 11:24:33 +0200 Subject: [PATCH 06/16] Try to fix the gh-action configration to work with extra requirements --- .github/workflows/tox_checks.yml | 5 ++--- .github/workflows/tox_pytests.yml | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tox_checks.yml b/.github/workflows/tox_checks.yml index 8c5ba3e..f702a59 100644 --- a/.github/workflows/tox_checks.yml +++ b/.github/workflows/tox_checks.yml @@ -37,7 +37,7 @@ jobs: uses: actions/cache@v4 with: path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ matrix.toxenv }}-${{ hashFiles('tox.ini', 'setup.py') }} + key: ${{ runner.os }}-pip-${{ matrix.toxenv }}-${{ hashFiles('tox.ini', 'pyproject.toml') }} restore-keys: | ${{ runner.os }}-pip-${{ matrix.toxenv }}- ${{ runner.os }}-pip- @@ -45,8 +45,7 @@ jobs: - name: Install dependencies run: | python -m pip install -U pip - python -m pip install -U setuptools wheel - python -m pip install -U tox + python -m pip install -U -e .[build,docs,test] - name: Run ${{ matrix.toxenv }} run: python -m tox -e ${{ matrix.toxenv }} diff --git a/.github/workflows/tox_pytests.yml b/.github/workflows/tox_pytests.yml index cbf67fa..ab77cc2 100644 --- a/.github/workflows/tox_pytests.yml +++ b/.github/workflows/tox_pytests.yml @@ -21,7 +21,6 @@ jobs: steps: - uses: actions/checkout@v4 - name: Install xmllint - run: sudo apt install coinor-cbc - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: @@ -29,7 +28,8 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install tox tox-gh-actions coverage coveralls + pip install -e .[test] + pip install tox-gh-actions - name: Test with tox run: tox From 3c6c3ec9df1c6ecf04413f652493c557b4e8236d Mon Sep 17 00:00:00 2001 From: Francesco Witte Date: Thu, 27 Jun 2024 11:26:44 +0200 Subject: [PATCH 07/16] Remove unnecessary step in pytest --- .github/workflows/tox_pytests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/tox_pytests.yml b/.github/workflows/tox_pytests.yml index ab77cc2..c29941d 100644 --- a/.github/workflows/tox_pytests.yml +++ b/.github/workflows/tox_pytests.yml @@ -20,7 +20,6 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install xmllint - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: From 0d2f2c68a9879ddcd93bdcaa5668aba9e0672452 Mon Sep 17 00:00:00 2001 From: Francesco Witte Date: Thu, 27 Jun 2024 11:30:04 +0200 Subject: [PATCH 08/16] Add tox dependency for gh actions checks and pytest --- .github/workflows/tox_checks.yml | 2 +- .github/workflows/tox_pytests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tox_checks.yml b/.github/workflows/tox_checks.yml index f702a59..00ef369 100644 --- a/.github/workflows/tox_checks.yml +++ b/.github/workflows/tox_checks.yml @@ -45,7 +45,7 @@ jobs: - name: Install dependencies run: | python -m pip install -U pip - python -m pip install -U -e .[build,docs,test] + python -m pip install -U -e .[build,docs,test,tox] - name: Run ${{ matrix.toxenv }} run: python -m tox -e ${{ matrix.toxenv }} diff --git a/.github/workflows/tox_pytests.yml b/.github/workflows/tox_pytests.yml index c29941d..58e50b5 100644 --- a/.github/workflows/tox_pytests.yml +++ b/.github/workflows/tox_pytests.yml @@ -27,7 +27,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -e .[test] + pip install -e .[test,tox] pip install tox-gh-actions - name: Test with tox run: tox From 20fc94d9290cef750805e42916aeb56561231187 Mon Sep 17 00:00:00 2001 From: Francesco Witte Date: Thu, 27 Jun 2024 11:31:45 +0200 Subject: [PATCH 09/16] Move matplotlib to test dependencies --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0c7571b..4bdfa66 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,14 +71,14 @@ build = [ "twine", ] docs = [ - "matplotlib", "sphinx", "sphinx_rtd_theme", ] test = [ - "pytest", "coverage", "coveralls", + "matplotlib", + "pytest", ] tox = [ "tox", From 3b69550090946ef0be49cfcb9dfb44991ae3994f Mon Sep 17 00:00:00 2001 From: Francesco Witte Date: Thu, 27 Jun 2024 11:37:54 +0200 Subject: [PATCH 10/16] Try to install things more better --- .github/workflows/tox_pytests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tox_pytests.yml b/.github/workflows/tox_pytests.yml index 58e50b5..59a7418 100644 --- a/.github/workflows/tox_pytests.yml +++ b/.github/workflows/tox_pytests.yml @@ -27,8 +27,8 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -e .[test,tox] - pip install tox-gh-actions + python -m pip install -e .[test,tox] + python -m pip install tox-gh-actions - name: Test with tox run: tox From 83bc21ff0c84a48b49a58c4ba23bd074b87d3b0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrik=20Sch=C3=B6nfeldt?= Date: Thu, 27 Jun 2024 11:44:24 +0200 Subject: [PATCH 11/16] Shorten line --- src/demandlib/bdew/heat_building.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/demandlib/bdew/heat_building.py b/src/demandlib/bdew/heat_building.py index d9aa457..f565021 100644 --- a/src/demandlib/bdew/heat_building.py +++ b/src/demandlib/bdew/heat_building.py @@ -278,7 +278,8 @@ def get_sigmoid_parameters(self, filename="shlp_sigmoid_factors.csv"): wrong_number_of_parameters_message = ( "{} sigmoid parameters found for " - + f"building_class={self.building_class}, shlp_type={self.shlp_type}, " + + f"building_class={self.building_class}, " + + f"shlp_type={self.shlp_type}, " + f"wind_class={self.wind_class}. Should be 1." ) From a92ec818479bee0aa1195c40877c32f8424e1fb9 Mon Sep 17 00:00:00 2001 From: Francesco Witte Date: Thu, 27 Jun 2024 11:45:23 +0200 Subject: [PATCH 12/16] Fix dependency installation between gh actions and tox --- .github/workflows/tox_checks.yml | 4 ++-- .github/workflows/tox_pytests.yml | 3 +-- tox.ini | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tox_checks.yml b/.github/workflows/tox_checks.yml index 00ef369..2950178 100644 --- a/.github/workflows/tox_checks.yml +++ b/.github/workflows/tox_checks.yml @@ -44,8 +44,8 @@ jobs: - name: Install dependencies run: | - python -m pip install -U pip - python -m pip install -U -e .[build,docs,test,tox] + python -m pip install pip --upgrade + python -m pip install tox - name: Run ${{ matrix.toxenv }} run: python -m tox -e ${{ matrix.toxenv }} diff --git a/.github/workflows/tox_pytests.yml b/.github/workflows/tox_pytests.yml index 59a7418..82f7b84 100644 --- a/.github/workflows/tox_pytests.yml +++ b/.github/workflows/tox_pytests.yml @@ -27,8 +27,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install -e .[test,tox] - python -m pip install tox-gh-actions + python -m pip install tox, tox-gh-actions - name: Test with tox run: tox diff --git a/tox.ini b/tox.ini index decfc01..3bf479b 100644 --- a/tox.ini +++ b/tox.ini @@ -20,7 +20,7 @@ python = basepython = {bootstrap,clean,check,report,docs,codecov,coveralls}: {env:TOXPYTHON:python3} extras = - dev + test setenv = PYTHONPATH={toxinidir}/tests PYTHONUNBUFFERED=yes @@ -36,7 +36,6 @@ usedevelop = true extras = build docs - test commands = python -m build . twine check dist/demandlib* From 7d3dae0b63b23a9900f29eb190685bcb11e390e5 Mon Sep 17 00:00:00 2001 From: Francesco Witte Date: Thu, 27 Jun 2024 11:47:00 +0200 Subject: [PATCH 13/16] Fix typo and rename job --- .github/workflows/tox_pytests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tox_pytests.yml b/.github/workflows/tox_pytests.yml index 82f7b84..f519870 100644 --- a/.github/workflows/tox_pytests.yml +++ b/.github/workflows/tox_pytests.yml @@ -12,7 +12,7 @@ on: - cron: "0 5 * * 6" # 5:00 UTC every Saturday jobs: - build: + pytest: runs-on: ubuntu-latest strategy: matrix: @@ -27,7 +27,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install tox, tox-gh-actions + python -m pip install tox tox-gh-actions - name: Test with tox run: tox From e137c83b7fabb70be3e10ddc44766537a99c4139 Mon Sep 17 00:00:00 2001 From: Francesco Witte Date: Thu, 27 Jun 2024 11:55:15 +0200 Subject: [PATCH 14/16] Final clean up for today? --- .github/workflows/tox_pytests.yml | 2 +- pyproject.toml | 1 - tox.ini | 26 +------------------------- 3 files changed, 2 insertions(+), 27 deletions(-) diff --git a/.github/workflows/tox_pytests.yml b/.github/workflows/tox_pytests.yml index f519870..eefa8cf 100644 --- a/.github/workflows/tox_pytests.yml +++ b/.github/workflows/tox_pytests.yml @@ -27,7 +27,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install tox tox-gh-actions + python -m pip install tox tox-gh-actions coverage converalls - name: Test with tox run: tox diff --git a/pyproject.toml b/pyproject.toml index 4bdfa66..b4edcc1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,7 +76,6 @@ docs = [ ] test = [ "coverage", - "coveralls", "matplotlib", "pytest", ] diff --git a/tox.ini b/tox.ini index 3bf479b..445939a 100644 --- a/tox.ini +++ b/tox.ini @@ -6,7 +6,6 @@ envlist = py39, py310, py311, - py3-cover, pypy3, report @@ -18,7 +17,7 @@ python = [testenv] basepython = - {bootstrap,clean,check,report,docs,codecov,coveralls}: {env:TOXPYTHON:python3} + {clean,check,report,docs}: {env:TOXPYTHON:python3} extras = test setenv = @@ -26,8 +25,6 @@ setenv = PYTHONUNBUFFERED=yes passenv = * -deps = - pytest commands = {posargs:pytest -vv --ignore=src} @@ -43,7 +40,6 @@ commands = flake8 src tests isort --check-only --profile black --diff src tests - [testenv:docs] usedevelop = true extras = docs @@ -51,12 +47,6 @@ commands = sphinx-build {posargs:-E} -b html docs docs/_build sphinx-build -b linkcheck docs docs/_build -[testenv:coveralls] -deps = coveralls -skip_install = true -commands = - coveralls [] - [testenv:report] deps = coverage skip_install = true @@ -78,7 +68,6 @@ usedevelop = true commands = {posargs:pytest --cov --cov-report=term-missing -vv} deps = - {[testenv]deps} pytest-cov [testenv:py310] @@ -89,7 +78,6 @@ usedevelop = true commands = {posargs:pytest --cov --cov-report=term-missing -vv} deps = - {[testenv]deps} pytest-cov [testenv:py311] @@ -100,18 +88,6 @@ usedevelop = true commands = {posargs:pytest --cov --cov-report=term-missing -vv} deps = - {[testenv]deps} - pytest-cov - -[testenv:py3-cover] -basepython = {env:TOXPYTHON:python3} -setenv = - {[testenv]setenv} -usedevelop = true -commands = - {posargs:pytest --cov --cov-report=term-missing -vv} -deps = - {[testenv]deps} pytest-cov [testenv:pypy3-nocov] From d587cfd6891ee48fb78c1e219ba1de5627be10f4 Mon Sep 17 00:00:00 2001 From: Francesco Witte Date: Thu, 27 Jun 2024 11:56:05 +0200 Subject: [PATCH 15/16] No --- .github/workflows/tox_pytests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tox_pytests.yml b/.github/workflows/tox_pytests.yml index eefa8cf..1f50c37 100644 --- a/.github/workflows/tox_pytests.yml +++ b/.github/workflows/tox_pytests.yml @@ -27,7 +27,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install tox tox-gh-actions coverage converalls + python -m pip install tox tox-gh-actions coverage coveralls - name: Test with tox run: tox From 816e11acf8c7a8222e074ecdd1e06e37fdfef10f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrik=20Sch=C3=B6nfeldt?= Date: Thu, 27 Jun 2024 12:03:32 +0200 Subject: [PATCH 16/16] Delete report tox env --- tox.ini | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tox.ini b/tox.ini index 445939a..546066b 100644 --- a/tox.ini +++ b/tox.ini @@ -47,13 +47,6 @@ commands = sphinx-build {posargs:-E} -b html docs docs/_build sphinx-build -b linkcheck docs docs/_build -[testenv:report] -deps = coverage -skip_install = true -commands = - coverage report - coverage html - [testenv:clean] deps = coverage skip_install = true