Switch to modern PEP-517/PEP-518 build

- Add pyproject.toml
- Remove setup.py
- Adopt tox & CI to modern structure
This commit is contained in:
Tobias Gruetzmacher 2022-04-08 01:14:02 +02:00
parent b72fff5c23
commit 45436f1693
5 changed files with 31 additions and 48 deletions

60
Jenkinsfile vendored
View file

@ -1,8 +1,8 @@
def pys = [
[name: 'Python 3.10', docker: 'python:3.10-buster', tox:'py310,flake8', main: true],
[name: 'Python 3.9', docker: 'python:3.9-buster', tox:'py39', main: false],
[name: 'Python 3.8', docker: 'python:3.8-buster', tox:'py38', main: false],
[name: 'Python 3.7', docker: 'python:3.7-buster', tox:'py37', main: false],
[name: 'Python 3.10', docker: 'python:3.10-bullseye', tox:'py310,flake8', main: true],
[name: 'Python 3.9', docker: 'python:3.9-bullseye', tox:'py39', main: false],
[name: 'Python 3.8', docker: 'python:3.8-bullseye', tox:'py38', main: false],
[name: 'Python 3.7', docker: 'python:3.7-bullseye', tox:'py37', main: false],
]
properties([
@ -15,33 +15,32 @@ Map tasks = [failFast: true]
pys.each { py ->
tasks[py.name] = {
node {
def image
stage("Prepare docker $py.name") {
dir('dockerbuild') {
deleteDir()
docker.image(py.docker).pull()
buildDockerfile(py.docker)
image = docker.build("dosage-$py.docker")
}
stage("Checkout $py.name") {
checkout scm
sh '''
git clean -fdx
git fetch --tags
'''
}
stage("Build $py.name") {
def image = docker.image(py.docker)
image.pull()
image.inside {
checkout scm
sh '''
git clean -fdx
git fetch --tags
'''
withEnv(['HOME=' + pwd(tmp: true)]) {
warnError('tox failed') {
sh """
pip install --no-warn-script-location tox
python -m tox -e $py.tox
"""
}
warnError('tox failed') {
sh "tox -e $py.tox"
}
if (py.main) {
sh """
python setup.py sdist bdist_wheel
"""
if (py.main) {
sh """
pip install --no-warn-script-location build
python -m build
"""
}
}
}
@ -80,15 +79,6 @@ stage('Allure report') {
processAllure()
}
def buildDockerfile(image) {
def uid = sh(returnStdout: true, script: 'id -u').trim()
writeFile file: 'Dockerfile', text: """
FROM $image
RUN pip install tox
RUN useradd -mu $uid dockerjenkins
"""
}
def windowsBuild() {
warnError('windows build failed') {
node {

5
pyproject.toml Normal file
View file

@ -0,0 +1,5 @@
[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm>=6.2"]
build-backend = "setuptools.build_meta"
[tool.setuptools_scm]

View file

@ -41,9 +41,6 @@ install_requires =
importlib_metadata;python_version<'3.8'
include_package_data = true
python_requires = >=3.7
setup_requires =
setuptools>=38.3.0
setuptools_scm
[options.entry_points]
console_scripts =

View file

@ -1,10 +0,0 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: MIT
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
# Copyright (C) 2012-2014 Bastian Kleineidam
# Copyright (C) 2015-2019 Tobias Gruetzmacher
from setuptools import setup
setup(
use_scm_version=True,
)

View file

@ -1,5 +1,6 @@
[tox]
envlist = py37, py38, py39, py310, flake8
isolated_build = True
[gh-actions]
python =