Skip to content

Commit

Permalink
Removed use of distutils and drop support for Python 3.7 (#860)
Browse files Browse the repository at this point in the history
# Description
The `distutils` package is deprecates since Python 3.12 and has to be
removed. The only function we used from `distutils` was
`distutils.dir_util.copy_tree()`. This function can be replaced with
`shutil.copytree()`.

However, `shutil.copytree()` got the needed `dirs_exist_ok` argument in
Python 3.8, which means that we have to drop support for Python 3.7.
This is acceptable, since Python 3.7 reached end-of-life in June 2023.

## Type of change
- [x] Bug fix & code cleanup
- [ ] New feature
- [ ] Documentation update
- [ ] Test update

## Checklist for the reviewer
This checklist should be used as a help for the reviewer.

- [ ] Is the change limited to one issue?
- [ ] Does this PR close the issue?
- [ ] Is the code easy to read and understand?
- [ ] Do all new feature have an accompanying new test?
- [ ] Has the documentation been updated as necessary?
  • Loading branch information
francescalb authored Jun 24, 2024
2 parents c88db3e + 43e4cbd commit ce04221
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .github/docker/Dockerfile-manylinux.template
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# Reference: https://github.com/pypa/manylinux#manylinux2014-centos-7-based
FROM quay.io/pypa/manylinux{{ TYPE }}_{{ ARCH }}:latest

ARG PY_MINORS="7 8 9 10 11 12"
ARG PY_MINORS="8 9 10 11 12"

{{ EXTRA_PRE }}

Expand Down
2 changes: 1 addition & 1 deletion .github/docker/Dockerfile-manylinux_x_y.template
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# Reference: https://github.com/pypa/manylinux
FROM quay.io/pypa/manylinux{{ TYPE }}_{{ ARCH }}

ARG PY_MINORS="7 8 9 10 11 12"
ARG PY_MINORS="8 9 10 11 12"

{{ EXTRA_PRE }}

Expand Down
2 changes: 1 addition & 1 deletion .github/docker/Dockerfile-musllinux.template
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#
FROM quay.io/pypa/musllinux{{ TYPE }}_{{ ARCH }}:latest

ARG PY_MINORS="7 8 9 10 11 12"
ARG PY_MINORS="8 9 10 11 12"

# Do not use distutils distributed with setuptools
# This is due to base changes in the distutils API, removing msvccompiler,
Expand Down
18 changes: 7 additions & 11 deletions .github/workflows/cd_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,41 +80,37 @@ jobs:
- os: ubuntu-20.04
system_type: ["manylinux", "2010"]
arch: i686
py_minors: 7,8,9
py_minors: 8,9
- os: ubuntu-20.04
system_type: ["manylinux", "2014"]
arch: i686
py_minors: 7,8,9,10,11,12
py_minors: 8,9,10,11,12
- os: ubuntu-20.04
system_type: ["musllinux", "_1_1"]
arch: i686
py_minors: 7,8,9,10,11
py_minors: 8,9,10,11

# 64-bit linux
- os: ubuntu-20.04
system_type: ["manylinux", "2010"]
arch: x86_64
py_minors: 7,8,9
py_minors: 8,9
- os: ubuntu-20.04
system_type: ["manylinux", "2014"]
arch: x86_64
py_minors: 7,8,9,10,11,12
py_minors: 8,9,10,11,12
- os: ubuntu-20.04
system_type: ["manylinux", "_2_28"]
arch: x86_64
py_minors: 7,8,9,10,11,12
py_minors: 8,9,10,11,12
- os: ubuntu-20.04
system_type: ["musllinux", "_1_1"]
arch: x86_64
py_minors: 7,8,9,10,11
py_minors: 8,9,10,11

# 32-bit Windows

# 64-bit Windows
- os: windows-2019
system_type: ["win", ""]
arch: amd64
py_minors: '7'
- os: windows-2019
system_type: ["win", ""]
arch: amd64
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/ci_build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ jobs:
- os: ubuntu-20.04
system_type: ["manylinux", "2010"]
arch: i686
py_minors: 7,9
py_minors: 8,9
- os: ubuntu-20.04
system_type: ["manylinux", "2014"]
arch: i686
py_minors: 7,12
py_minors: 8,12
- os: ubuntu-20.04
system_type: ["musllinux", "_1_1"]
arch: i686
py_minors: 7,11 # Python 3.12 fails
py_minors: 8,11 # Python 3.12 fails
# Fails with cannot import distutils
#- os: ubuntu-20.04
# system_type: ["musllinux", "_1_2"]
Expand All @@ -40,35 +40,35 @@ jobs:
- os: ubuntu-20.04
system_type: ["manylinux", "2010"]
arch: x86_64
py_minors: 7,9
py_minors: 8,9
- os: ubuntu-20.04
system_type: ["manylinux", "2014"]
arch: x86_64
py_minors: 7,12
py_minors: 8,12
- os: ubuntu-20.04
system_type: ["manylinux", "_2_28"]
arch: x86_64
py_minors: 7,12
py_minors: 8,12
# See issue #225: https://github.com/SINTEF/dlite/issues/225
# - os: ubuntu-20.04
# system_type: ["musllinux", "_1_1"]
# arch: x86_64
# py_minors: 7,10
# py_minors: 8,10
- os: ubuntu-20.04
system_type: ["musllinux", "_1_1"]
arch: x86_64
py_minors: 7,11 # Fails for Python-3.12
py_minors: 8,11 # Fails for Python-3.12
# Fails with cannot import distutils
#- os: ubuntu-20.04
# system_type: ["musllinux", "_1_2"]
# arch: x86_64
# py_minors: 7,12
# py_minors: 8,12

# May work after weekly container build...
#- os: ubuntu-20.04
# system_type: ["musllinux", "_1_2"]
# arch: x86_64
# py_minors: 7
# py_minors: 8
#- os: ubuntu-20.04
# system_type: ["musllinux", "_1_2"]
# arch: x86_64
Expand All @@ -93,7 +93,7 @@ jobs:
- os: windows-2019
system_type: ["win", ""]
arch: amd64
py_minors: '7'
py_minors: '8'
- os: windows-2019
system_type: ["win", ""]
arch: amd64
Expand Down
22 changes: 10 additions & 12 deletions .github/workflows/container_builds_weekly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,27 @@ jobs:
template: "manylinux"
type: "2010"
arch: "x86_64"
py_minors: "7 8 9"
py_minors: "8 9"
- system: "manylinux"
template: "manylinux"
type: "2014"
arch: "x86_64"
py_minors: "7 8 9 10 11"
py_minors: "8 9 10 11"
- system: "manylinux"
template: "manylinux_x_y"
type: "_2_28"
arch: "x86_64"
py_minors: "7 8 9 10 11 12"
py_minors: "8 9 10 11 12"
- system: "musllinux"
template: "musllinux"
type: "_1_1"
arch: "x86_64"
py_minors: "7 8 9 10 11"
py_minors: "8 9 10 11"
- system: "musllinux"
template: "musllinux"
type: "_1_2"
arch: "x86_64"
py_minors: "7 8 9"
py_minors: "8 9"
- system: "musllinux"
template: "musllinux"
type: "_1_2"
Expand All @@ -59,29 +59,27 @@ jobs:
template: "manylinux"
type: "2010"
arch: "i686"
py_minors: "7 8 9"
py_minors: "8 9"
- system: "manylinux"
template: "manylinux"
type: "2014"
arch: "i686"
py_minors: "7 8 9"
py_minors: "8 9"
- system: "musllinux"
template: "musllinux"
type: "_1_1"
arch: "i686"
py_minors: "7 8 9"
py_minors: "8 9"
- system: "musllinux"
template: "musllinux"
type: "_1_2"
arch: "i686"
py_minors: "7 8 9"
py_minors: "8 9"
- system: "musllinux"
template: "musllinux"
type: "_1_2"
arch: "i686"
# Python 3.12 fails while building numpy: missing distutils
#py_minors: "10 11 12"
py_minors: "10 11"
py_minors: "10 11 12"

steps:
- name: Checkout repository
Expand Down
32 changes: 16 additions & 16 deletions doc/getting_started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,25 @@ wheels are shown in the following two tables.

#### 32-bit

| Python version | 3.7 | 3.8 | 3.9 | 3.10 | 3.11 | 3.12 |
| ---------------- | --- | --- | --- | ---- | ---- | ---- |
| [musllinux_1_1] | x | x | x | x | x | |
| [musllinux_1_2] | | | | | | |
| [manylinux2010] | x | x | x | | | |
| [manylinux2014] | x | x | x | x | x | x |
| [manylinux_2_28] | | | | | | |
| windows | | | | | | |
| Python version | 3.8 | 3.9 | 3.10 | 3.11 | 3.12 |
| ---------------- | --- | --- | ---- | ---- | ---- |
| [musllinux_1_1] | x | x | x | x | |
| [musllinux_1_2] | | | | | |
| [manylinux2010] | x | x | | | |
| [manylinux2014] | x | x | x | x | x |
| [manylinux_2_28] | | | | | |
| windows | | | | | |

#### 64-bit

| Python version | 3.7 | 3.8 | 3.9 | 3.10 | 3.11 | 3.12 |
| ---------------- | --- | --- | --- | ---- | ---- | ---- |
| [musllinux_1_1] | x | x | x | x | x | |
| [musllinux_1_2] | | | | | | |
| [manylinux2010] | x | x | x | | | |
| [manylinux2014] | x | x | x | x | x | x |
| [manylinux_2_28] | x | x | x | x | x | x |
| windows | x | x | x | x | x | x |
| Python version | 3.8 | 3.9 | 3.10 | 3.11 | 3.12 |
| ---------------- | --- | --- | ---- | ---- | ---- |
| [musllinux_1_1] | x | x | x | x | |
| [musllinux_1_2] | | | | | |
| [manylinux2010] | x | x | | | |
| [manylinux2014] | x | x | x | x | x |
| [manylinux_2_28] | x | x | x | x | x |
| windows | x | x | x | x | x |


Development installation
Expand Down
10 changes: 6 additions & 4 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import re
import site
import subprocess
from shutil import copytree
from typing import TYPE_CHECKING
from distutils import dir_util
from pathlib import Path

from setuptools import Extension, setup
Expand Down Expand Up @@ -153,8 +153,10 @@ def build_extension(self, ext: CMakeExtension) -> None:
raise

cmake_bdist_dir = Path(self.build_temp) / Path(ext.python_package_dir)
dir_util.copy_tree(
str(cmake_bdist_dir / ext.name), str(Path(output_dir) / ext.name)
copytree(
str(cmake_bdist_dir / ext.name),
str(Path(output_dir) / ext.name),
dirs_exist_ok=True,
)

version = re.search(
Expand All @@ -175,7 +177,7 @@ def build_extension(self, ext: CMakeExtension) -> None:
long_description_content_type="text/markdown",
url="https://github.com/SINTEF/dlite",
license="MIT",
python_requires=">=3.7",
python_requires=">=3.8",
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
Expand Down

0 comments on commit ce04221

Please sign in to comment.