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 = [ def pys = [
[name: 'Python 3.10', docker: 'python:3.10-buster', tox:'py310,flake8', main: true], [name: 'Python 3.10', docker: 'python:3.10-bullseye', tox:'py310,flake8', main: true],
[name: 'Python 3.9', docker: 'python:3.9-buster', tox:'py39', main: false], [name: 'Python 3.9', docker: 'python:3.9-bullseye', tox:'py39', main: false],
[name: 'Python 3.8', docker: 'python:3.8-buster', tox:'py38', main: false], [name: 'Python 3.8', docker: 'python:3.8-bullseye', tox:'py38', main: false],
[name: 'Python 3.7', docker: 'python:3.7-buster', tox:'py37', main: false], [name: 'Python 3.7', docker: 'python:3.7-bullseye', tox:'py37', main: false],
] ]
properties([ properties([
@ -15,33 +15,32 @@ Map tasks = [failFast: true]
pys.each { py -> pys.each { py ->
tasks[py.name] = { tasks[py.name] = {
node { node {
def image stage("Checkout $py.name") {
checkout scm
stage("Prepare docker $py.name") { sh '''
dir('dockerbuild') { git clean -fdx
deleteDir() git fetch --tags
docker.image(py.docker).pull() '''
buildDockerfile(py.docker)
image = docker.build("dosage-$py.docker")
}
} }
stage("Build $py.name") { stage("Build $py.name") {
def image = docker.image(py.docker)
image.pull()
image.inside { image.inside {
checkout scm withEnv(['HOME=' + pwd(tmp: true)]) {
sh ''' warnError('tox failed') {
git clean -fdx sh """
git fetch --tags pip install --no-warn-script-location tox
''' python -m tox -e $py.tox
"""
}
warnError('tox failed') { if (py.main) {
sh "tox -e $py.tox" sh """
} pip install --no-warn-script-location build
python -m build
if (py.main) { """
sh """ }
python setup.py sdist bdist_wheel
"""
} }
} }
@ -80,15 +79,6 @@ stage('Allure report') {
processAllure() 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() { def windowsBuild() {
warnError('windows build failed') { warnError('windows build failed') {
node { 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' importlib_metadata;python_version<'3.8'
include_package_data = true include_package_data = true
python_requires = >=3.7 python_requires = >=3.7
setup_requires =
setuptools>=38.3.0
setuptools_scm
[options.entry_points] [options.entry_points]
console_scripts = 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] [tox]
envlist = py37, py38, py39, py310, flake8 envlist = py37, py38, py39, py310, flake8
isolated_build = True
[gh-actions] [gh-actions]
python = python =