From 7c7fd611c15691fb1b62f082c48d5c9377b75d38 Mon Sep 17 00:00:00 2001 From: Jonas Hoersch Date: Thu, 9 Feb 2023 12:04:55 +0100 Subject: [PATCH 01/12] Replace setup.py by pyproject.toml --- .bumpversion.cfg | 6 +-- pyproject.toml | 59 +++++++++++++++++++++++++ setup.py | 111 ----------------------------------------------- 3 files changed, 62 insertions(+), 114 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 3605868..79b39cc 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -15,9 +15,9 @@ tag_message = search = __version__ = '{current_version}' replace = __version__ = '{new_version}' -[bumpversion:file:setup.py] -search = version='{current_version}', -replace = version='{new_version}', +[bumpversion:file:pyproject.toml] +search = version = "{current_version}" +replace = version = "{new_version}" [bumpversion:file:README.rst] search = v{current_version} diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..4fdcab5 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,59 @@ +[project] +name = "jmct-sampleproject" +version = "0.11.2" +description = "A skeleton template for Python projects." +readme = "README.rst" +license = {text = "MIT"} +authors = [ + {name = "Joao Miguel Correia Teixeira", email = "joaomcteixeira@gmail.com"}, +] + +# complete classifier list: +# http://pypi.org/classifiers/ +classifiers = [ + 'Development Status :: 4 - Beta', + # 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)', + 'License :: OSI Approved :: MIT License', + 'Intended Audience :: Science/Research', + 'Natural Language :: English', + 'Operating System :: POSIX', + 'Operating System :: MacOS', + 'Operating System :: Microsoft', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Topic :: Scientific/Engineering :: Bio-Informatics', + "Development Status :: 4 - Beta", + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", +] + +keywords=[ + 'ci', 'continuous-integration', 'project-template', 'project-skeleton', + 'sample-project', + # eg: 'keyword1', 'keyword2', 'keyword3', +] + +requires-python = ">=3.8, <4" +dependencies = [ + # https://stackoverflow.com/questions/14399534 + 'matplotlib>=3', +] + +[project.urls] +homepage = "https://github.com/joaomcteixeira/python-project-skeleton" +documentation = "https://python-project-skeleton.readthedocs.io/en/latest/"" +repository = "https://github.com/joaomcteixeira/python-project-skeleton.git" +changelog = "https://github.com/joaomcteixeira/python-project-skeleton/blob/main/CHANGELOG.rst" + +[project.optional_dependencies] +# e.g.: +# rst = [ "docutils>=0.11" ] + +[project.scripts] +#samplecli1 = "sampleproject.cli_int1:main" + +[build-system] +build-backend = "setuptools.build_meta" +requires = ["setuptools>=46.1.0", "wheel"] \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index 133c6f3..0000000 --- a/setup.py +++ /dev/null @@ -1,111 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- -"""Setup dot py.""" -from __future__ import absolute_import, print_function - -# import re -from glob import glob -from os.path import basename, dirname, join, splitext - -from setuptools import find_packages, setup - - -def read(*names, **kwargs): - """Read description files.""" - path = join(dirname(__file__), *names) - with open(path, encoding=kwargs.get('encoding', 'utf8')) as fh: - return fh.read() - - -# previous approach used to ignored badges in PyPI long description -# long_description = '{}\n{}'.format( -# re.compile( -# '^.. start-badges.*^.. end-badges', -# re.M | re.S, -# ).sub( -# '', -# read('README.rst'), -# ), -# re.sub(':[a-z]+:`~?(.*?)`', r'``\1``', read(join('docs', 'CHANGELOG.rst'))) -# ) - -long_description = '{}\n{}'.format( - read('README.rst'), - read('CHANGELOG.rst'), - ) - -setup( - name='jmct-sampleproject', - version='0.11.2', - description='A skeleton template for Python projects.', - long_description=long_description, - long_description_content_type='text/x-rst', - license='MIT License', - author='Joao Miguel Correia Teixeira', - author_email='joaomcteixeira@gmail.com', - url='https://github.com/joaomcteixeira/python-project-skeleton', - packages=find_packages('src'), - package_dir={'': 'src'}, - py_modules=[splitext(basename(i))[0] for i 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 :: 4 - Beta', - # 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)', - 'License :: OSI Approved :: MIT License', - 'Intended Audience :: Science/Research', - 'Natural Language :: English', - 'Operating System :: POSIX', - 'Operating System :: MacOS', - 'Operating System :: Microsoft', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Topic :: Scientific/Engineering :: Bio-Informatics', - ], - project_urls={ - 'webpage': 'https://github.com/joaomcteixeira/python-project-skeleton', - 'Documentation': 'https://python-project-skeleton.readthedocs.io/en/latest/', - 'Changelog': 'https://github.com/joaomcteixeira/python-project-skeleton/blob/master/CHANGELOG.rst', - 'Issue Tracker': 'https://github.com/joaomcteixeira/python-project-skeleton/issues', - 'Discussion Forum': 'https://github.com/joaomcteixeira/python-project-skeleton/discussions', - }, - keywords=[ - 'ci', 'continuous-integration', 'project-template', - 'project-skeleton', 'sample-project', - # eg: 'keyword1', 'keyword2', 'keyword3', - ], - python_requires='>=3.7, <4', - install_requires=[ - # https://stackoverflow.com/questions/14399534 - 'matplotlib>=3', - ], - extras_require={ - # eg: - # 'rst': ['docutils>=0.11'], - # ':python_version=="2.6"': ['argparse'], - }, - setup_requires=[ - # 'pytest-runner', - # 'setuptools_scm>=3.3.1', - ], - entry_points={ - 'console_scripts': [ - 'samplecli1= sampleproject.cli_int1:main', - ] - # - }, - # cmdclass={'build_ext': optional_build_ext}, - # ext_modules=[ - # Extension( - # splitext(relpath(path, 'src').replace(os.sep, '.'))[0], - # sources=[path], - # include_dirs=[dirname(path)] - # ) - # for root, _, _ in os.walk('src') - # for path in glob(join(root, '*.c')) - # ], - ) From 75278ec6b15e71c8cb6e8d623cc6862264eee0f8 Mon Sep 17 00:00:00 2001 From: joaomcteixeira Date: Thu, 9 Feb 2023 23:23:48 +0100 Subject: [PATCH 02/12] Correct pyproject.toml - corrected some typos - added the client --- pyproject.toml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4fdcab5..eaab28a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,7 @@ +[build-system] +build-backend = "setuptools.build_meta" +requires = ["setuptools>=46.1.0", "wheel"] + [project] name = "jmct-sampleproject" version = "0.11.2" @@ -41,19 +45,16 @@ dependencies = [ 'matplotlib>=3', ] + [project.urls] homepage = "https://github.com/joaomcteixeira/python-project-skeleton" -documentation = "https://python-project-skeleton.readthedocs.io/en/latest/"" +documentation = "https://python-project-skeleton.readthedocs.io/en/latest/" repository = "https://github.com/joaomcteixeira/python-project-skeleton.git" changelog = "https://github.com/joaomcteixeira/python-project-skeleton/blob/main/CHANGELOG.rst" -[project.optional_dependencies] +[project.optional-dependencies] # e.g.: # rst = [ "docutils>=0.11" ] [project.scripts] -#samplecli1 = "sampleproject.cli_int1:main" - -[build-system] -build-backend = "setuptools.build_meta" -requires = ["setuptools>=46.1.0", "wheel"] \ No newline at end of file +samplecli1 = "sampleproject.cli_int1:main" From e9e809acfd2d47d9ff5da29355b89b1cffb27e29 Mon Sep 17 00:00:00 2001 From: joaomcteixeira Date: Thu, 9 Feb 2023 23:24:26 +0100 Subject: [PATCH 03/12] Partially updated tox.ini - removed `setup.py` from `tox.ini` --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 6e215f8..a8aa9d1 100644 --- a/tox.ini +++ b/tox.ini @@ -71,8 +71,8 @@ deps = isort skip_install = true commands = - flake8 {posargs:src tests setup.py docs} - isort --verbose --check-only --diff {posargs:src tests setup.py docs/conf.py} + flake8 {posargs:src tests docs} + isort --verbose --check-only --diff {posargs:src tests docs/conf.py} # asserts package build integrity [testenv:build] From c3007cd4af3086a5f5fda45206b5aa0cdfa10b6c Mon Sep 17 00:00:00 2001 From: joaomcteixeira Date: Sat, 11 Feb 2023 12:56:11 +0100 Subject: [PATCH 04/12] Configured new tox.ini build env - removed usage of `setup.py` - updated packing commands **to do:** - `test` env still won't work - `docs` env still won't work - test package README builds correctly --- tox.ini | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tox.ini b/tox.ini index a8aa9d1..4ec32cf 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,7 @@ [tox] minversion = 3.25.0 +#isolated_build = true +#skipdist = true ignore_basepython_conflict = true # these are the environments that will run when you # execute `tox` in the command-line @@ -31,7 +33,7 @@ usedevelop = true # by using tox, developers don't need to manage project's dependencies # for unit testing deps = - -r{toxinidir}/requirements.txt + # -r{toxinidir}/requirements.txt coverage pytest pytest-cov @@ -80,21 +82,22 @@ skip_install = true # setenv here integrates with commit message in .bumpversion.cfg # we can tests bump2version with an actual commit setenv = - COMMIT_MSG = Test commit message + COMMIT_MSG=Test commit message # dependencies needed for code quality checks # you need to add here any additional dependencies you might need deps = - setuptools - wheel twine - docutils check-manifest - readme-renderer bump2version + build commands_pre = python {toxinidir}/devtools/clean_dist_check.py + +# note as of 2023/02/11 the build command is different for windows and unix: +# https://packaging.python.org/en/latest/tutorials/packaging-projects/#generating-distribution-archives commands = python --version - python setup.py sdist bdist_wheel + python -m pip install --upgrade build + python -m build twine check dist/*.whl twine check dist/*.tar.gz check-manifest {toxinidir} From 7082d7701343a92772e865431add2439e8e2df37 Mon Sep 17 00:00:00 2001 From: Jonas Hoersch Date: Tue, 21 Feb 2023 10:19:05 +0100 Subject: [PATCH 05/12] Remove unnecessary pack requirements --- pyproject.toml | 2 +- tox.ini | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index eaab28a..820a796 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] build-backend = "setuptools.build_meta" -requires = ["setuptools>=46.1.0", "wheel"] +requires = ["setuptools>=46.1.0"] [project] name = "jmct-sampleproject" diff --git a/tox.ini b/tox.ini index 4ec32cf..3eb0614 100644 --- a/tox.ini +++ b/tox.ini @@ -96,7 +96,6 @@ commands_pre = python {toxinidir}/devtools/clean_dist_check.py # https://packaging.python.org/en/latest/tutorials/packaging-projects/#generating-distribution-archives commands = python --version - python -m pip install --upgrade build python -m build twine check dist/*.whl twine check dist/*.tar.gz From 2c2dcf4b03cc8f49e53b9ea1748f74744f9daf98 Mon Sep 17 00:00:00 2001 From: Jonas Hoersch Date: Tue, 21 Feb 2023 10:19:43 +0100 Subject: [PATCH 06/12] Move configuration of pytest, isort and flake8 into pyproject --- pyproject.toml | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ tox.ini | 60 +----------------------------------------------- 2 files changed, 63 insertions(+), 59 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 820a796..52e86d4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,3 +58,65 @@ changelog = "https://github.com/joaomcteixeira/python-project-skeleton/blob/main [project.scripts] samplecli1 = "sampleproject.cli_int1:main" + + +# my favourite configuration for flake8 styling +# https://flake8.pycqa.org/en/latest/# +[tool.flake8] +max_line_length = 80 +hang-closing = true +ignore = [ + "W293", + "W503", + "D412", + "D105" +] +docstring-convention = "numpy" +# normally I exclude init because it is very hard to configure init +# without breaking many rules +exclude = "src/sampleproject/__init__.py" + +# configuration for the isort module +# https://github.com/timothycrosley/isort +[tool.isort] +skip = "__init__.py" +line_length = 80 +indent = 4 +multi_line_output = 8 +include_trailing_comma = true +lines_after_imports = 2 +sections="FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER" +#known_future_library=future,pies +#known_standard_library=std,std2 +known_first_party = ["sampleproject"] +# you should add here your known thirdparties, it will facilitate +# the job to isort +known_third_party = [ + "hypothesis", + "matplotlib", + "numpy", + "pytest" +] + +[tool.pytest.ini_options] +# 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 = +#migrations +addopts = "-p pytest_cov" +python_files = [ + "test_*.py", + "*_test.py", + "tests.py" +] +#addopts = +# -ra +# --strict +# --doctest-modules +# --doctest-glob=\*.rst +# --tb=short +testpaths = [ + "tests" +] diff --git a/tox.ini b/tox.ini index 3eb0614..ae5b701 100644 --- a/tox.ini +++ b/tox.ini @@ -69,6 +69,7 @@ deps = flake8-print>=5 flake8-docstrings flake8-bugbear + Flake8-pyproject pygments isort skip_install = true @@ -129,62 +130,3 @@ commands = skip_install = true deps = safety commands = safety check - -# my favourite configuration for flake8 styling -# https://flake8.pycqa.org/en/latest/# -[flake8] -max_line_length = 80 -hang-closing = true -ignore = - W293 - W503 - D412 - D105 -per-file-ignores = setup.py:E501 -docstring-convention = numpy -# normally I exclude init because it is very hard to configure init -# without breaking many rules -exclude = src/sampleproject/__init__.py - -# configuration for the isort module -# https://github.com/timothycrosley/isort -[isort] -skip = __init__.py -line_length = 80 -indent = 4 -multi_line_output = 8 -include_trailing_comma = true -lines_after_imports = 2 -sections=FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER -#known_future_library=future,pies -#known_standard_library=std,std2 -known_first_party = sampleproject -# you should add here your known thirdparties, it will facilitate -# the job to isort -known_third_party = - hypothesis - matplotlib - numpy - pytest - -[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 = -#migrations -addopts = -p pytest_cov -python_files = - test_*.py - *_test.py - tests.py -#addopts = -# -ra -# --strict -# --doctest-modules -# --doctest-glob=\*.rst -# --tb=short -testpaths = - tests - From cc89a9f32a94a679e29441172879ce2a0c92ed0e Mon Sep 17 00:00:00 2001 From: joaomcteixeira Date: Tue, 21 Feb 2023 20:29:56 +0100 Subject: [PATCH 07/12] remove unnecessary comments --- pyproject.toml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 52e86d4..1f1120c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -99,10 +99,6 @@ known_third_party = [ ] [tool.pytest.ini_options] -# 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 = #migrations addopts = "-p pytest_cov" From dca719c7f7c681b3c56ca8d9a04bbbfbb9d8a4ed Mon Sep 17 00:00:00 2001 From: joaomcteixeira Date: Tue, 21 Feb 2023 20:30:20 +0100 Subject: [PATCH 08/12] add latest tox version --- tox.ini | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tox.ini b/tox.ini index ae5b701..ecb4ad2 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,5 @@ [tox] -minversion = 3.25.0 -#isolated_build = true -#skipdist = true +minversion = 4.4.6 ignore_basepython_conflict = true # these are the environments that will run when you # execute `tox` in the command-line @@ -33,7 +31,7 @@ usedevelop = true # by using tox, developers don't need to manage project's dependencies # for unit testing deps = - # -r{toxinidir}/requirements.txt + -r{toxinidir}/requirements.txt coverage pytest pytest-cov From 314b34137791e59ed5ace42c7ed40fbd9ac5e943 Mon Sep 17 00:00:00 2001 From: joaomcteixeira Date: Tue, 21 Feb 2023 20:31:59 +0100 Subject: [PATCH 09/12] update changelog --- CHANGELOG.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 55682a0..e1ed4fd 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,8 @@ Changelog ========= +* Replace `setup.py` by `pyproject.toml` (#33) + v0.11.2 (2023-02-07) ------------------------------------------------------------ From bb34aa2c01aa65fd9aa5004695d7fc6585e8399a Mon Sep 17 00:00:00 2001 From: joaomcteixeira Date: Tue, 21 Feb 2023 20:41:27 +0100 Subject: [PATCH 10/12] try rtd --- .readthedocs.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 46d4cf6..2ae4a03 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -14,14 +14,12 @@ formats: all # Optionally set the version of Python and requirements required to build your docs python: - version: 3.7 + version: 3.8 install: - requirements: devtools/docs_requirements.txt - method: pip path: . extra_requirements: - docs - - method: setuptools - path: . system_packages: true From 01be7c8de404b69635b1d72562dcfcb1c70906dc Mon Sep 17 00:00:00 2001 From: joaomcteixeira Date: Tue, 21 Feb 2023 21:07:53 +0100 Subject: [PATCH 11/12] drop py37 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c6e21ec..70dcc1f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: # fail-fast: false matrix: platform: [ubuntu-latest, macos-latest, windows-latest] - python-version: [3.7, 3.8, 3.9, '3.10'] + python-version: [3.8, 3.9, '3.10', '3.11'] # you can separate the tox-envs in different .yml files # see version 0.10.1 # https://github.com/joaomcteixeira/python-project-skeleton/releases/tag/v0.10.1 From 535927f1cc441ffe9022128744509bb5ddfde7e7 Mon Sep 17 00:00:00 2001 From: joaomcteixeira Date: Tue, 21 Feb 2023 21:21:50 +0100 Subject: [PATCH 12/12] update version and others --- pyproject.toml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1f1120c..8fac717 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ requires = ["setuptools>=46.1.0"] [project] name = "jmct-sampleproject" -version = "0.11.2" +version = "0.11.3" description = "A skeleton template for Python projects." readme = "README.rst" license = {text = "MIT"} @@ -23,14 +23,13 @@ classifiers = [ 'Operating System :: POSIX', 'Operating System :: MacOS', 'Operating System :: Microsoft', - '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', 'Topic :: Scientific/Engineering :: Bio-Informatics', "Development Status :: 4 - Beta", "Programming Language :: Python :: 3", - "License :: OSI Approved :: MIT License", ] keywords=[