Repository: SINTEF/dlite (language: python)

Issue:
Replace running setup.py 
Running `setup.py install` is deprecated. Instead of running ``setup.py`` directly from CMake, we should use pypa/build, pypa/installer or other standards-based tools.

See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html and https://github.com/pypa/setuptools/issues/917 for details.



Discussion / hints:

Fix patch:
diff --git a/.github/workflows/ci_build_wheels.yml b/.github/workflows/ci_build_wheels.yml
index bf75839f8..0c59a9252 100644
--- a/.github/workflows/ci_build_wheels.yml
+++ b/.github/workflows/ci_build_wheels.yml
@@ -69,7 +69,8 @@ jobs:
           #   py_minors: 7,10
 
     steps:
-      - uses: actions/checkout@v3
+      - name: Checkout repository
+        uses: actions/checkout@v3
 
       - uses: actions/setup-python@v3
         with:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7b2fd30c6..48f9807e1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -67,7 +67,6 @@ option(FORCE_EXAMPLES   "Whether to force building/running examples"        NO)
 option(ALLOW_WARNINGS   "Whether to not fail on compilation warnings"      YES)
 option(WITH_STATIC_PYTHON "Whether to compile with static python libraries" NO)
 
-
 # Append our cmake-modules to CMAKE_MODULE_PATH
 list(APPEND CMAKE_MODULE_PATH ${dlite_SOURCE_DIR}/cmake)
 
diff --git a/bindings/python/scripts/CMakeLists.txt b/bindings/python/scripts/CMakeLists.txt
index e09509f54..714bd163e 100644
--- a/bindings/python/scripts/CMakeLists.txt
+++ b/bindings/python/scripts/CMakeLists.txt
@@ -22,7 +22,7 @@ endfunction()
 install(
   CODE "
    execute_process(
-     COMMAND ${Python3_EXECUTABLE} setup.py install
+     COMMAND ${Python3_EXECUTABLE} -m pip install
        --prefix=${CMAKE_INSTALL_PREFIX} --force
      WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    )"
diff --git a/bindings/python/scripts/setup.py b/bindings/python/scripts/setup.py
index 3250b8fb2..3fb150d56 100644
--- a/bindings/python/scripts/setup.py
+++ b/bindings/python/scripts/setup.py
@@ -2,7 +2,6 @@
 import re
 import sys
 from setuptools import setup
-from glob import glob
 
 
 with open('../../../CMakeLists.txt', 'rt') as f:


Test patch:
diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml
index 173c3fd22..892630a52 100644
--- a/.github/workflows/ci_tests.yml
+++ b/.github/workflows/ci_tests.yml
@@ -7,14 +7,12 @@ jobs:
     runs-on: ubuntu-20.04
 
     steps:
-    - uses: actions/checkout@v3
-
-    - name: apt-get update
-      run: |
-        sudo apt-get update --fix-missing
+    - name: Checkout repository
+      uses: actions/checkout@v3
 
     - name: Install dependencies
       run: |
+        sudo apt-get update --fix-missing && \
         sudo apt-get install \
           libhdf5-dev \
           swig4.0 \
@@ -28,12 +26,11 @@ jobs:
 
     - name: Install Python dependencies
       run: |
-        python3 -m pip install --upgrade pip -r requirements.txt
-        python3 -m pip install -r requirements_full.txt
-        python3 -m pip install -r requirements_dev.txt
-        python3 -m pip install -r requirements_doc.txt
+        python3 -m pip install --upgrade pip
+        python3 -m pip install -U setuptools wheel
+        python3 -m pip install -r requirements.txt -r requirements_full.txt -r requirements_dev.txt -r requirements_doc.txt
 
-    - name: check numpy
+    - name: Check numpy
       run: |
         which python3
         python3 --version
@@ -50,41 +47,26 @@ jobs:
 
     - name: configure
       run: |
-        mkdir build
-        cd build
         Python3_ROOT=$(python3 -c 'import sys; print(sys.exec_prefix)') \
-          CFLAGS='-Wno-missing-field-initializers' \
-          cmake .. -DFORCE_EXAMPLES=ON -DWITH_FORTRAN=YES
-        cd -
+        CFLAGS='-Wno-missing-field-initializers' \
+        cmake -B build . -DFORCE_EXAMPLES=ON -DWITH_FORTRAN=YES
 
     - name: make
-      run: |
-        cd build
-        cmake --build .
-        cd -
+      run: cmake --build .
+      working-directory: build
 
     - name: install
-      run: |
-        cd build
-        cmake --install .
-        cd -
+      run: cmake --install .
+      working-directory: build
 
     - name: make test
-      run: |
-        cd build
-        ctest || ctest --rerun-failed --output-on-failure -V
-        cd -
+      run: ctest || ctest --rerun-failed --output-on-failure -V
+      working-directory: build
 
     - name: build Linux wheel
-      run: |
-        cd python
-        python3 -m pip install numpy wheel
-        python3 setup.py bdist_wheel
-        cd -
+      run: python3 -m pip wheel -w dist ./python
 
-    - name: Install python package via setup.py and test the installation
+    - name: Install python package and test the installation
       run: |
-        cd python
-        python3 setup.py install --user
-        cd ../bindings/python/tests
-        python3 __main__.py
+        python3 -m pip install --user dist/*.whl
+        python3 bindings/python/tests/__main__.py