git » libfiu » commit 88b961a

python: Update setup to use setuptools

author Alberto Bertogli
2023-08-14 17:10:43 UTC
committer Alberto Bertogli
2023-08-19 17:53:14 UTC
parent 1be3d9d78253b8fcc553f33e27d4eb4d3a051441

python: Update setup to use setuptools

Python's distutils is deprecated and will be removed from the main
distribution soon; it's being replaced by setuptools as described in PEP
632.

To prepare for that change, this patch updates our Python build script
(setup.py) to use setuptools instead of distutils.

.gitlab-ci.yml +1 -1
bindings/python/setup.py +4 -5

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 3446c3f..12b91bc 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -9,7 +9,7 @@ test:
   stage: test
   before_script:
     - apt update
-    - apt -y install make coreutils python3-dev
+    - apt -y install make coreutils python3-dev python3-setuptools
   script:
     - make all
     - make test
diff --git a/bindings/python/setup.py b/bindings/python/setup.py
index 0dac6ae..24e4fbd 100644
--- a/bindings/python/setup.py
+++ b/bindings/python/setup.py
@@ -2,8 +2,8 @@
 import os
 import sys
 import tempfile
-from distutils.core import setup, Extension
-from distutils.command.build_py import build_py
+from setuptools import setup, Extension
+from setuptools.command.build_py import build_py
 
 # We need to generate the fiu_ctrl.py file from fiu_ctrl.in.py, replacing some
 # environment variables in its contents.
@@ -20,8 +20,7 @@ class generate_and_build_py (build_py):
         contents = open('fiu_ctrl.in.py', 'rt').read()
         contents = contents.replace('@@PLIBPATH@@', plibpath)
 
-        # Create/update the file atomically, as this could be invoked in
-        # parallel for python 2 and 3, and we don't want to accidentally use
+        # Create/update the file atomically, we don't want to accidentally use
         # partially written files.
         out = tempfile.NamedTemporaryFile(
                 mode = 'wt', delete = False,
@@ -35,7 +34,7 @@ fiu_ll = Extension("fiu_ll",
 		sources = ['fiu_ll.c'],
 		libraries = ['fiu'],
 
-		# these two allow us to build without having libfiu installed,
+		# These two allow us to build without having libfiu installed,
 		# assuming we're in the libfiu source tree
 		include_dirs = ['../../libfiu/'],
 		library_dirs=['../../libfiu/'])