From 45436f16934c4c4a557fe3839df8d9d610014382 Mon Sep 17 00:00:00 2001 From: Tobias Gruetzmacher Date: Fri, 8 Apr 2022 01:14:02 +0200 Subject: [PATCH] Switch to modern PEP-517/PEP-518 build - Add pyproject.toml - Remove setup.py - Adopt tox & CI to modern structure --- Jenkinsfile | 60 +++++++++++++++++++++----------------------------- pyproject.toml | 5 +++++ setup.cfg | 3 --- setup.py | 10 --------- tox.ini | 1 + 5 files changed, 31 insertions(+), 48 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/Jenkinsfile b/Jenkinsfile index 2c46c5e02..d7a8dc161 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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 { diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..94d86dc54 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,5 @@ +[build-system] +requires = ["setuptools>=45", "wheel", "setuptools_scm>=6.2"] +build-backend = "setuptools.build_meta" + +[tool.setuptools_scm] diff --git a/setup.cfg b/setup.cfg index ebaa4aaf9..7d6570c3a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 = diff --git a/setup.py b/setup.py deleted file mode 100644 index 4cd82b87e..000000000 --- a/setup.py +++ /dev/null @@ -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, -) diff --git a/tox.ini b/tox.ini index 49105fbfc..cbfd785f2 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,6 @@ [tox] envlist = py37, py38, py39, py310, flake8 +isolated_build = True [gh-actions] python =