diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 70f2f2e..c945098 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/.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 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 diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2a6e6ab..1a5a22c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,8 @@ Changelog ========= +* Replace `setup.py` by `pyproject.toml` (#33) + v0.11.3 (2023-02-11) ------------------------------------------------------------ diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..8fac717 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,117 @@ +[build-system] +build-backend = "setuptools.build_meta" +requires = ["setuptools>=46.1.0"] + +[project] +name = "jmct-sampleproject" +version = "0.11.3" +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.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", +] + +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" + + +# 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] +#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/setup.py b/setup.py deleted file mode 100644 index 321bdd3..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.3', - 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')) - # ], - ) diff --git a/tox.ini b/tox.ini index 6e215f8..ecb4ad2 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -minversion = 3.25.0 +minversion = 4.4.6 ignore_basepython_conflict = true # these are the environments that will run when you # execute `tox` in the command-line @@ -67,12 +67,13 @@ deps = flake8-print>=5 flake8-docstrings flake8-bugbear + Flake8-pyproject pygments 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] @@ -80,21 +81,21 @@ 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 build twine check dist/*.whl twine check dist/*.tar.gz check-manifest {toxinidir} @@ -127,62 +128,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 -