Skip to content

Replace setup.py by pyproject.toml #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
6 changes: 3 additions & 3 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Changelog
=========

* Replace `setup.py` by `pyproject.toml` (#33)

v0.11.3 (2023-02-11)
------------------------------------------------------------

Expand Down
117 changes: 117 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]"},
]

# 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"
]
111 changes: 0 additions & 111 deletions setup.py

This file was deleted.

78 changes: 10 additions & 68 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -67,34 +67,35 @@ 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]
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}
Expand Down Expand Up @@ -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