|
| 1 | +From 2d6530941682595b26067a8b679ec2eb3aceae54 Mon Sep 17 00:00:00 2001 |
| 2 | +From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= <mcepl@cepl.eu> |
| 3 | +Date: Tue, 17 May 2022 16:00:47 +0200 |
| 4 | +Subject: [PATCH 1/3] Make the code future-proof against removal of distutils |
| 5 | + module. |
| 6 | + |
| 7 | +--- |
| 8 | + src/setup_common.py | 14 +++++++++++--- |
| 9 | + 1 file changed, 11 insertions(+), 3 deletions(-) |
| 10 | + |
| 11 | +diff --git a/src/setup_common.py b/src/setup_common.py |
| 12 | +index aec1f9b..3fb9086 100644 |
| 13 | +--- a/src/setup_common.py |
| 14 | ++++ b/src/setup_common.py |
| 15 | +@@ -30,7 +30,12 @@ |
| 16 | + if sys.version_info[0] < 3: |
| 17 | + import commands as subprocess |
| 18 | + from os import path as os_path |
| 19 | +-from distutils.sysconfig import get_python_lib |
| 20 | ++try: |
| 21 | ++ from distutils.sysconfig import get_python_lib, get_config_var |
| 22 | ++ __python_lib = get_python_lib(1) |
| 23 | ++except ImportError: |
| 24 | ++ from sysconfig import get_config_var, get_path |
| 25 | ++ __python_lib = get_path('platlib') |
| 26 | + |
| 27 | + # libxml2 - C flags |
| 28 | + def libxml2_include(incdir): |
| 29 | +@@ -50,7 +55,7 @@ def libxml2_include(incdir): |
| 30 | + |
| 31 | + # libxml2 - library flags |
| 32 | + def libxml2_lib(libdir, libs): |
| 33 | +- libdir.append(get_python_lib(1)) |
| 34 | ++ libdir.append(__python_lib) |
| 35 | + if os_path.exists("/etc/debian_version"): #. XXX: Debian Workaround... |
| 36 | + libdir.append("/usr/lib/pymodules/python%d.%d"%sys.version_info[0:2]) |
| 37 | + |
| 38 | +From 7c0788b5c5ed7d1c79f70a74047abab161dca13a Mon Sep 17 00:00:00 2001 |
| 39 | +From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= <mcepl@cepl.eu> |
| 40 | +Date: Mon, 17 Oct 2022 19:59:52 +0200 |
| 41 | +Subject: [PATCH 2/3] Don't be too complicated. |
| 42 | + |
| 43 | +There is actually no reason to use distutils.sysconfig at all, |
| 44 | +plain sysconfig works even on 2.7. |
| 45 | +--- |
| 46 | + Makefile | 3 ++- |
| 47 | + src/setup_common.py | 9 ++------- |
| 48 | + 2 files changed, 4 insertions(+), 8 deletions(-) |
| 49 | + |
| 50 | +diff --git a/src/setup_common.py b/src/setup_common.py |
| 51 | +index 3fb9086..97ece95 100644 |
| 52 | +--- a/src/setup_common.py |
| 53 | ++++ b/src/setup_common.py |
| 54 | +@@ -30,12 +30,7 @@ |
| 55 | + if sys.version_info[0] < 3: |
| 56 | + import commands as subprocess |
| 57 | + from os import path as os_path |
| 58 | +-try: |
| 59 | +- from distutils.sysconfig import get_python_lib, get_config_var |
| 60 | +- __python_lib = get_python_lib(1) |
| 61 | +-except ImportError: |
| 62 | +- from sysconfig import get_config_var, get_path |
| 63 | +- __python_lib = get_path('platlib') |
| 64 | ++from sysconfig import get_config_var, get_path |
| 65 | + |
| 66 | + # libxml2 - C flags |
| 67 | + def libxml2_include(incdir): |
| 68 | +@@ -55,7 +50,7 @@ def libxml2_include(incdir): |
| 69 | + |
| 70 | + # libxml2 - library flags |
| 71 | + def libxml2_lib(libdir, libs): |
| 72 | +- libdir.append(__python_lib) |
| 73 | ++ libdir.append(get_path('platlib')) |
| 74 | + if os_path.exists("/etc/debian_version"): #. XXX: Debian Workaround... |
| 75 | + libdir.append("/usr/lib/pymodules/python%d.%d"%sys.version_info[0:2]) |
| 76 | + |
| 77 | + |
| 78 | +From 860c730309366d6062c410ee975a2fc159452dc6 Mon Sep 17 00:00:00 2001 |
| 79 | +From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= <mcepl@cepl.eu> |
| 80 | +Date: Wed, 26 Oct 2022 17:39:47 +0200 |
| 81 | +Subject: [PATCH 3/3] Make the discovery of the build .so file more robust. |
| 82 | + |
| 83 | +Different versions of Python apparently generate different |
| 84 | +directory names, there doesn't seem to be any more reliable |
| 85 | +method of the .so file discovery than brutal force of the shell |
| 86 | +find command. |
| 87 | +--- |
| 88 | + Makefile | 12 +++++------- |
| 89 | + 1 file changed, 5 insertions(+), 7 deletions(-) |
| 90 | + |
| 91 | +--- a/Makefile.backup 2022-11-17 06:51:28.000000000 +0100 |
| 92 | ++++ b/Makefile 2023-05-20 12:56:07.590575539 +0200 |
| 93 | +@@ -44,12 +44,11 @@ |
| 94 | + PY_VER := $(shell $(PY_BIN) -c 'import sys; print("%d.%d"%sys.version_info[0:2])') |
| 95 | + PY_MV := $(shell echo $(PY_VER) | cut -b 1) |
| 96 | + PY := python$(PY_VER) |
| 97 | +-SO_PATH := build/lib.linux-$(shell uname -m)-$(PY_VER) |
| 98 | + ifeq ($(PY_MV),2) |
| 99 | +- SO := $(SO_PATH)/dmidecodemod.so |
| 100 | ++ SOLIB := dmidecodemod.so |
| 101 | + else |
| 102 | + SOABI := $(shell $(PY_BIN) -c 'import sysconfig; print(sysconfig.get_config_var("SOABI"))') |
| 103 | +- SO := $(SO_PATH)/dmidecodemod.$(SOABI).so |
| 104 | ++ SOLIB := dmidecodemod.$(SOABI).so |
| 105 | + endif |
| 106 | + SHELL := /bin/bash |
| 107 | + |
| 108 | +@@ -59,13 +58,13 @@ |
| 109 | + all : build dmidump |
| 110 | + |
| 111 | + build: $(PY)-dmidecodemod.so |
| 112 | +-$(PY)-dmidecodemod.so: $(SO) |
| 113 | +- cp $< $@ |
| 114 | +-$(SO): |
| 115 | ++ |
| 116 | ++$(PY)-dmidecodemod.so: |
| 117 | + $(PY) src/setup.py build |
| 118 | ++ cp $$(find build -name $(SOLIB)) $@ |
| 119 | + |
| 120 | + dmidump : src/util.o src/efi.o src/dmilog.o |
| 121 | +- $(CC) -o $@ src/dmidump.c $^ -g -Wall -D_DMIDUMP_MAIN_ |
| 122 | ++ $(CC) -o $@ src/dmidump.c $^ ${CFLAGS} -D_DMIDUMP_MAIN_ |
| 123 | + |
| 124 | + install: |
| 125 | + $(PY) src/setup.py install |
0 commit comments