From 1fc4031807ef4a9bcb6863c2127eb4625d547afb Mon Sep 17 00:00:00 2001 From: Joachim Metz Date: Mon, 20 Nov 2023 05:50:50 +0100 Subject: [PATCH] Applied updates and changes for deployment --- .github/workflows/build.yml | 22 -- .github/workflows/build_freebsd.yml | 21 ++ .gitignore | 3 +- Makefile.am | 2 - appveyor.yml | 7 +- configure.ac | 6 +- dpkg/rules | 2 +- exetools/exetools_signal.c | 6 +- libexe.spec.in | 4 +- m4/python.m4 | 373 +--------------------------- pyexe-python2/Makefile.am | 71 ------ pyexe-python3/Makefile.am | 71 ------ runtests.sh | 80 +----- setup.cfg.in | 3 +- tests/pyexe_test_file.py | 12 +- tests/pyexe_test_support.py | 11 +- tests/runtests.py | 7 +- tests/test_runner.sh | 25 +- 18 files changed, 66 insertions(+), 660 deletions(-) create mode 100644 .github/workflows/build_freebsd.yml delete mode 100644 pyexe-python2/Makefile.am delete mode 100644 pyexe-python3/Makefile.am diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 867a714..ebfd381 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,24 +3,6 @@ name: build on: [push, pull_request] permissions: read-all jobs: - build_freebsd: - # FreeBSD support is provided via virtualization on MacOS 12 - # See https://github.com/vmactions/freebsd-vm#under-the-hood. - runs-on: macos-12 - steps: - - uses: actions/checkout@v3 - - name: Building from source - id: build_freebsd - uses: vmactions/freebsd-vm@v0 - with: - usesh: true - mem: 4096 - # Note that the test scripts require bash - prepare: | - pkg install -y autoconf automake bash gettext git libtool pkgconf - run: | - tests/build.sh - tests/runtests.sh build_ubuntu: runs-on: ubuntu-22.04 strategy: @@ -69,10 +51,6 @@ jobs: compiler: 'gcc' configure_options: '--enable-python' python_version: '' - - architecture: 'x64' - compiler: 'gcc' - configure_options: '--enable-python3' - python_version: '3' steps: - uses: actions/checkout@v3 - name: Install build dependencies diff --git a/.github/workflows/build_freebsd.yml b/.github/workflows/build_freebsd.yml new file mode 100644 index 0000000..53b87c8 --- /dev/null +++ b/.github/workflows/build_freebsd.yml @@ -0,0 +1,21 @@ +# Build from source on FreeBSD. +name: build_freebsd +on: [push] +permissions: read-all +jobs: + build_freebsd: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + - name: Building from source + id: build_freebsd + uses: vmactions/freebsd-vm@v1 + with: + usesh: true + mem: 4096 + # Note that the test scripts require bash + prepare: | + pkg install -y autoconf automake bash gettext git libtool pkgconf + run: | + tests/build.sh + tests/runtests.sh diff --git a/.gitignore b/.gitignore index caffedf..1b22041 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ # Files to ignore by git # -# Version: 20230926 +# Version: 20231119 # Generic auto-generated build files *~ @@ -127,7 +127,6 @@ stamp-h[1-9] /libexe.spec /libexe/libexe.rc /libexe/libexe_definitions.h -/pyexe-python[23]/*.[ch] /setup.cfg /exetools/*.exe /exetools/exeinfo diff --git a/Makefile.am b/Makefile.am index 83d0f25..3b4dbed 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,8 +19,6 @@ SUBDIRS = \ libexe \ exetools \ pyexe \ - pyexe-python2 \ - pyexe-python3 \ po \ manuals \ tests \ diff --git a/appveyor.yml b/appveyor.yml index 644e0f6..1386dd5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -168,11 +168,6 @@ environment: BUILD_ENVIRONMENT: cygwin64 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 CONFIGURE_OPTIONS: "--enable-python" - - TARGET: cygwin64-gcc-python3 - BUILD_ENVIRONMENT: cygwin64 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 - CONFIGURE_OPTIONS: "--enable-python3" - PYTHON_VERSION: 3 - TARGET: cygwin64-gcc-static-executables BUILD_ENVIRONMENT: cygwin64 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 @@ -197,7 +192,7 @@ install: - cmd: if [%BUILD_ENVIRONMENT%]==[msbuild] ( git clone https://github.com/libyal/vstools.git ..\vstools ) - sh: if test ${BUILD_ENVIRONMENT} = "python-tox" || test ${BUILD_ENVIRONMENT} = "xcode"; then brew update-reset && brew update -q; fi -- sh: if test ${BUILD_ENVIRONMENT} = "python-tox" || test ${BUILD_ENVIRONMENT} = "xcode"; then brew install -q gettext gnu-sed || true; fi +- sh: if test ${BUILD_ENVIRONMENT} = "python-tox" || test ${BUILD_ENVIRONMENT} = "xcode"; then brew install -q autoconf automake gettext gnu-sed libtool pkg-config || true; fi - sh: if test ${BUILD_ENVIRONMENT} = "python-tox"; then brew install -q python@${PYTHON_VERSION} tox twine-pypi || true; fi - cmd: if [%BUILD_ENVIRONMENT%]==[python] ( "%PYTHON%" -m pip install -U pip setuptools twine wheel ) diff --git a/configure.ac b/configure.ac index 0fcdeea..7139999 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ([2.71]) AC_INIT( [libexe], - [20231024], + [20231120], [joachim.metz@gmail.com]) AC_CONFIG_SRCDIR( @@ -113,7 +113,7 @@ dnl Check if libexe Python bindings (pyexe) required headers and functions are a AX_PYTHON_CHECK_ENABLE AS_IF( - [test "x${ac_cv_enable_python}" != xno || test "x${ac_cv_enable_python2}" != xno || test "x${ac_cv_enable_python3}" != xno], + [test "x${ac_cv_enable_python}" != xno], [dnl Headers included in pyexe/pyexe_error.c AC_CHECK_HEADERS([stdarg.h varargs.h]) @@ -175,8 +175,6 @@ AC_CONFIG_FILES([libfdata/Makefile]) AC_CONFIG_FILES([libfdatetime/Makefile]) AC_CONFIG_FILES([libexe/Makefile]) AC_CONFIG_FILES([pyexe/Makefile]) -AC_CONFIG_FILES([pyexe-python2/Makefile]) -AC_CONFIG_FILES([pyexe-python3/Makefile]) AC_CONFIG_FILES([exetools/Makefile]) AC_CONFIG_FILES([po/Makefile.in]) AC_CONFIG_FILES([po/Makevars]) diff --git a/dpkg/rules b/dpkg/rules index 9303000..f008c93 100644 --- a/dpkg/rules +++ b/dpkg/rules @@ -11,7 +11,7 @@ export SKIP_PYTHON_TESTS=1 .PHONY: override_dh_auto_configure override_dh_auto_configure: - dh_auto_configure -- --enable-python3 CFLAGS="-g" + dh_auto_configure -- --enable-python CFLAGS="-g" .PHONY: override_dh_install override_dh_install: diff --git a/exetools/exetools_signal.c b/exetools/exetools_signal.c index 3686aa6..efe8e49 100644 --- a/exetools/exetools_signal.c +++ b/exetools/exetools_signal.c @@ -40,7 +40,7 @@ void (*exetools_signal_signal_handler)( exetools_signal_t ) = NULL; /* Signal handler for Ctrl+C or Ctrl+Break signals */ BOOL WINAPI exetools_signal_handler( - unsigned long signal ) + exetools_signal_t signal ) { static char *function = "exetools_signal_handler"; @@ -112,7 +112,7 @@ int exetools_signal_attach( exetools_signal_signal_handler = signal_handler; if( SetConsoleCtrlHandler( - exetools_signal_handler, + (PHANDLER_ROUTINE) exetools_signal_handler, TRUE ) == 0 ) { libcerror_error_set( @@ -179,7 +179,7 @@ int exetools_signal_detach( static char *function = "exetools_signal_detach"; if( SetConsoleCtrlHandler( - exetools_signal_handler, + (PHANDLER_ROUTINE) exetools_signal_handler, FALSE ) == 0 ) { libcerror_error_set( diff --git a/libexe.spec.in b/libexe.spec.in index b68d499..1a290f1 100644 --- a/libexe.spec.in +++ b/libexe.spec.in @@ -32,7 +32,7 @@ Header files and libraries for developing applications for libexe. Summary: Python 3 bindings for libexe Group: System Environment/Libraries Requires: libexe = %{version}-%{release} python3 -BuildRequires: python3-devel +BuildRequires: python3-devel python3-setuptools %description -n libexe-python3 Python 3 bindings for libexe @@ -49,7 +49,7 @@ Several tools for reading executable (EXE) files %setup -q %build -%configure --prefix=/usr --libdir=%{_libdir} --mandir=%{_mandir} --enable-python3 +%configure --prefix=/usr --libdir=%{_libdir} --mandir=%{_mandir} --enable-python make %{?_smp_mflags} %install diff --git a/m4/python.m4 b/m4/python.m4 index e10bc9f..d1f8067 100644 --- a/m4/python.m4 +++ b/m4/python.m4 @@ -1,6 +1,6 @@ dnl Functions for Python bindings dnl -dnl Version: 20230923 +dnl Version: 20231119 dnl Function to check if the python binary is available dnl "python${PYTHON_VERSION} python python# python#.#" @@ -28,60 +28,6 @@ AC_DEFUN([AX_PROG_PYTHON], [$PYTHON]) ]) -dnl Function to check if the python2 binary is available -dnl "python2 python2.#" -AC_DEFUN([AX_PROG_PYTHON2], - [ax_python2_progs="python2 python2.7 python2.6 python2.5" - AC_CHECK_PROGS( - [PYTHON2], - [$ax_python2_progs]) - AS_IF( - [test "x${PYTHON2}" != x], - [ax_prog_python2_version=`${PYTHON2} -c "import sys; sys.stdout.write('%d.%d' % (sys.version_info[[0]], sys.version_info[[1]]))" 2>/dev/null`; - AC_SUBST( - [PYTHON2_VERSION], - [$ax_prog_python2_version]) - - ax_prog_python2_platform=`${PYTHON2} -c "import sys; sys.stdout.write(sys.platform)" 2>/dev/null`; - AC_SUBST( - [PYTHON2_PLATFORM], - [$ax_prog_python2_platform]) - ], - [AC_MSG_ERROR( - [Unable to find python2]) - ]) - AC_SUBST( - [PYTHON2], - [$PYTHON2]) - ]) - -dnl Function to check if the python3 binary is available -dnl "python3 python3.#" -AC_DEFUN([AX_PROG_PYTHON3], - [ax_python3_progs="python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7 python3.6 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0" - AC_CHECK_PROGS( - [PYTHON3], - [$ax_python3_progs]) - AS_IF( - [test "x${PYTHON3}" != x], - [ax_prog_python3_version=`${PYTHON3} -c "import sys; sys.stdout.write('%d.%d' % (sys.version_info[[0]], sys.version_info[[1]]))" 2>/dev/null`; - AC_SUBST( - [PYTHON3_VERSION], - [$ax_prog_python3_version]) - - ax_prog_python3_platform=`${PYTHON3} -c "import sys; sys.stdout.write(sys.platform)" 2>/dev/null`; - AC_SUBST( - [PYTHON3_PLATFORM], - [$ax_prog_python3_platform]) - ], - [AC_MSG_ERROR( - [Unable to find python3]) - ]) - AC_SUBST( - [PYTHON3], - [$PYTHON3]) - ]) - dnl Function to check if the python-config binary is available dnl "python${PYTHON_VERSION}-config python-config" AC_DEFUN([AX_PROG_PYTHON_CONFIG], @@ -107,42 +53,6 @@ AC_DEFUN([AX_PROG_PYTHON_CONFIG], [$PYTHON_CONFIG]) ]) -dnl Function to check if the python2-config binary is available -AC_DEFUN([AX_PROG_PYTHON2_CONFIG], - [AS_IF( - [test "x${PYTHON2_CONFIG}" = x], - [AC_CHECK_PROGS( - [PYTHON2_CONFIG], - [python2-config python2.7-config python2.6-config python2.5-config]) - ]) - AS_IF( - [test "x${PYTHON2_CONFIG}" = x], - [AC_MSG_ERROR( - [Unable to find python2-config]) - ]) - AC_SUBST( - [PYTHON2_CONFIG], - [$PYTHON2_CONFIG]) - ]) - -dnl Function to check if the python3-config binary is available -AC_DEFUN([AX_PROG_PYTHON3_CONFIG], - [AS_IF( - [test "x${PYTHON3_CONFIG}" = x], - [AC_CHECK_PROGS( - [PYTHON3_CONFIG], - [python3-config python3.12-config python3.11-config python3.10-config python3.9-config python3.8-config python3.7-config python3.6-config python3.5-config python3.4-config python3.3-config python3.2-config python3.1-config python3.0-config]) - ]) - AS_IF( - [test "x${PYTHON3_CONFIG}" = x], - [AC_MSG_ERROR( - [Unable to find python3-config]) - ]) - AC_SUBST( - [PYTHON3_CONFIG], - [$PYTHON3_CONFIG]) - ]) - dnl Function to detect if a Python build environment is available AC_DEFUN([AX_PYTHON_CHECK], [AX_PROG_PYTHON @@ -254,228 +164,6 @@ AC_DEFUN([AX_PYTHON_CHECK], ]) ]) -dnl Function to detect if a Python 2 build environment is available -AC_DEFUN([AX_PYTHON2_CHECK], - [AX_PROG_PYTHON2 - AX_PROG_PYTHON2_CONFIG - - AS_IF( - [test "x${PYTHON2_CONFIG}" != x], - [dnl Check for Python 2 includes - PYTHON2_INCLUDES=`${PYTHON2_CONFIG} --includes 2>/dev/null`; - - AC_MSG_CHECKING( - [for Python verison 2 includes]) - AC_MSG_RESULT( - [$PYTHON2_INCLUDES]) - - dnl Check for Python 2 libraries - PYTHON2_LDFLAGS=`${PYTHON2_CONFIG} --ldflags 2>/dev/null`; - - AC_MSG_CHECKING( - [for Python 2 libraries]) - AC_MSG_RESULT( - [$PYTHON2_LDFLAGS]) - - dnl For CygWin add the -no-undefined linker flag - AS_CASE( - [$host_os], - [cygwin*],[PYTHON2_LDFLAGS="${PYTHON2_LDFLAGS} -no-undefined"], - [*],[]) - - dnl Check for the existence of Python.h - BACKUP_CPPFLAGS="${CPPFLAGS}" - CPPFLAGS="${CPPFLAGS} ${PYTHON2_INCLUDES}" - - AC_CHECK_HEADERS( - [Python.h], - [ac_cv_header_python2_h=yes], - [ac_cv_header_python2_h=no]) - - CPPFLAGS="${BACKUP_CPPFLAGS}" - ]) - - AS_IF( - [test "x${ac_cv_header_python2_h}" != xyes], - [ac_cv_enable_python2=no], - [ac_cv_enable_python2=$PYTHON2_VERSION - AC_SUBST( - [PYTHON2_CPPFLAGS], - [$PYTHON2_INCLUDES]) - - AC_SUBST( - [PYTHON2_LDFLAGS], - [$PYTHON2_LDFLAGS]) - - dnl Check for Python prefix - AS_IF( - [test "x${ac_cv_with_pyprefix}" = x || test "x${ac_cv_with_pyprefix}" = xno], - [ax_python2_prefix="\${prefix}"], - [ax_python2_prefix=`${PYTHON2_CONFIG} --prefix 2>/dev/null`]) - - AC_SUBST( - [PYTHON2_PREFIX], - [$ax_python2_prefix]) - - dnl Check for Python exec-prefix - AS_IF( - [test "x${ac_cv_with_pyprefix}" = x || test "x${ac_cv_with_pyprefix}" = xno], - [ax_python2_exec_prefix="\${exec_prefix}"], - [ax_python2_exec_prefix=`${PYTHON2_CONFIG} --exec-prefix 2>/dev/null`]) - - AC_SUBST( - [PYTHON2_EXEC_PREFIX], - [$ax_python2_exec_prefix]) - - dnl Check for Python 2 library directory - ax_python2_pythondir_suffix=`${PYTHON2} -c "import sys; import distutils.sysconfig; sys.stdout.write(distutils.sysconfig.get_python_lib(0, 0, prefix=''))" 2>/dev/null`; - - AS_IF( - [test "x${ac_cv_with_pythondir2}" = x || test "x${ac_cv_with_pythondir2}" = xno], - [AS_IF( - [test "x${ac_cv_with_pyprefix}" = x || test "x${ac_cv_with_pyprefix}" = xno], - [ax_python2_pythondir="${ax_python_prefix}/${ax_python2_pythondir_suffix}"], - [ax_python2_pythondir=`${PYTHON2} -c "import sys; import distutils.sysconfig; sys.stdout.write(distutils.sysconfig.get_python_lib()) " 2>/dev/null`])], - [ax_python2_pythondir=$ac_cv_with_pythondir2]) - - AC_SUBST( - [pythondir2], - [$ax_python2_pythondir]) - - dnl Check for Python 2 platform specific library directory - ax_python2_pyexecdir_suffix=`${PYTHON2} -c "import sys; import distutils.sysconfig; sys.stdout.write(distutils.sysconfig.get_python_lib(1, 0, prefix=''))" 2>/dev/null`; - ax_python2_library_dir=`${PYTHON2} -c "import sys; import distutils.sysconfig; sys.stdout.write(distutils.sysconfig.get_python_lib(True)) " 2>/dev/null`; - - AS_IF( - [test "x${ac_cv_with_pyprefix}" = x || test "x${ac_cv_with_pyprefix}" = xno], - [ax_python2_pyexecdir="${ax_python2_exec_prefix}/${ax_python2_pyexecdir_suffix}"], - [ax_python2_pyexecdir=$ax_python2_library_dir]) - - AC_SUBST( - [pyexecdir2], - [$ax_python2_pyexecdir]) - - AC_SUBST( - [PYTHON2_LIBRARY_DIR], - [$ax_python2_pyexecdir_suffix]) - - AC_SUBST( - [PYTHON2_PACKAGE_DIR], - [$ax_python2_library_dir]) - ]) - ]) - -dnl Function to detect if a Python 3 build environment is available -AC_DEFUN([AX_PYTHON3_CHECK], - [AX_PROG_PYTHON3 - AX_PROG_PYTHON3_CONFIG - - AS_IF( - [test "x${PYTHON3_CONFIG}" != x], - [dnl Check for Python 3 includes - PYTHON3_INCLUDES=`${PYTHON3_CONFIG} --includes 2>/dev/null`; - - AC_MSG_CHECKING( - [for Python verison 3 includes]) - AC_MSG_RESULT( - [$PYTHON3_INCLUDES]) - - dnl Check for Python 3 libraries - PYTHON3_LDFLAGS=`${PYTHON3_CONFIG} --ldflags 2>/dev/null`; - - AC_MSG_CHECKING( - [for Python 3 libraries]) - AC_MSG_RESULT( - [$PYTHON3_LDFLAGS]) - - dnl For CygWin add the -no-undefined linker flag - AS_CASE( - [$host_os], - [cygwin*],[PYTHON3_LDFLAGS="${PYTHON3_LDFLAGS} -no-undefined"], - [*],[]) - - dnl Check for the existence of Python.h - BACKUP_CPPFLAGS="${CPPFLAGS}" - CPPFLAGS="${CPPFLAGS} ${PYTHON3_INCLUDES}" - - AC_CHECK_HEADERS( - [Python.h], - [ac_cv_header_python3_h=yes], - [ac_cv_header_python3_h=no]) - - CPPFLAGS="${BACKUP_CPPFLAGS}" - ]) - - AS_IF( - [test "x${ac_cv_header_python3_h}" != xyes], - [ac_cv_enable_python3=no], - [ac_cv_enable_python3=$PYTHON3_VERSION - AC_SUBST( - [PYTHON3_CPPFLAGS], - [$PYTHON3_INCLUDES]) - - AC_SUBST( - [PYTHON3_LDFLAGS], - [$PYTHON3_LDFLAGS]) - - dnl Check for Python prefix - AS_IF( - [test "x${ac_cv_with_pyprefix}" = x || test "x${ac_cv_with_pyprefix}" = xno], - [ax_python3_prefix="\${prefix}"], - [ax_python3_prefix=`${PYTHON3_CONFIG} --prefix 2>/dev/null`]) - - AC_SUBST( - [PYTHON3_PREFIX], - [$ax_python3_prefix]) - - dnl Check for Python exec-prefix - AS_IF( - [test "x${ac_cv_with_pyprefix}" = x || test "x${ac_cv_with_pyprefix}" = xno], - [ax_python3_exec_prefix="\${exec_prefix}"], - [ax_python3_exec_prefix=`${PYTHON3_CONFIG} --exec-prefix 2>/dev/null`]) - - AC_SUBST( - [PYTHON3_EXEC_PREFIX], - [$ax_python3_exec_prefix]) - - dnl Check for Python 3 library directory - ax_python3_pythondir_suffix=`${PYTHON3} -c "import sys; import distutils.sysconfig; sys.stdout.write(distutils.sysconfig.get_python_lib(0, 0, prefix=''))" 2>/dev/null`; - - AS_IF( - [test "x${ac_cv_with_pythondir3}" = x || test "x${ac_cv_with_pythondir3}" = xno], - [AS_IF( - [test "x${ac_cv_with_pyprefix}" = x || test "x${ac_cv_with_pyprefix}" = xno], - [ax_python3_pythondir="${ax_python_prefix}/${ax_python3_pythondir_suffix}"], - [ax_python3_pythondir=`${PYTHON3} -c "import sys; import distutils.sysconfig; sys.stdout.write(distutils.sysconfig.get_python_lib()) " 2>/dev/null`])], - [ax_python3_pythondir=$ac_cv_with_pythondir3]) - - AC_SUBST( - [pythondir3], - [$ax_python3_pythondir]) - - dnl Check for Python 3 platform specific library directory - ax_python3_pyexecdir_suffix=`${PYTHON3} -c "import sys; import distutils.sysconfig; sys.stdout.write(distutils.sysconfig.get_python_lib(1, 0, prefix=''))" 2>/dev/null`; - ax_python3_library_dir=`${PYTHON3} -c "import sys; import distutils.sysconfig; sys.stdout.write(distutils.sysconfig.get_python_lib(True)) " 2>/dev/null`; - - AS_IF( - [test "x${ac_cv_with_pyprefix}" = x || test "x${ac_cv_with_pyprefix}" = xno], - [ax_python3_pyexecdir="${ax_python3_exec_prefix}/${ax_python3_pyexecdir_suffix}"], - [ax_python3_pyexecdir=$ax_python3_library_dir]) - - AC_SUBST( - [pyexecdir3], - [$ax_python3_pyexecdir]) - - AC_SUBST( - [PYTHON3_LIBRARY_DIR], - [$ax_python3_pyexecdir_suffix]) - - AC_SUBST( - [PYTHON3_PACKAGE_DIR], - [$ax_python3_library_dir]) - ]) - ]) - dnl Function to determine the prefix of pythondir AC_DEFUN([AX_PYTHON_CHECK_PYPREFIX], [AX_COMMON_ARG_WITH( @@ -502,74 +190,17 @@ AC_DEFUN([AX_PYTHON_CHECK_ENABLE], [no], [no]) - AX_COMMON_ARG_ENABLE( - [python2], - [python2], - [build Python 2 bindings], - [no]) - AX_COMMON_ARG_WITH( - [pythondir2], - [pythondir2], - [use to specify the Python 2 directory (pythondir2)], - [no], - [no]) - - AX_COMMON_ARG_ENABLE( - [python3], - [python3], - [build Python 3 bindings], - [no]) - AX_COMMON_ARG_WITH( - [pythondir3], - [pythondir3], - [use to specify the Python 3 directory (pythondir3)], - [no], - [no]) - AS_IF( [test "x${ac_cv_enable_python}" != xno], [AX_PYTHON_CHECK]) - AS_IF( - [test "x${ac_cv_enable_python2}" != xno], - [AX_PYTHON2_CHECK]) - - AS_IF( - [test "x${ac_cv_enable_python3}" != xno], - [AX_PYTHON3_CHECK]) - AM_CONDITIONAL( HAVE_PYTHON, [test "x${ac_cv_enable_python}" != xno]) - AM_CONDITIONAL( - HAVE_PYTHON2, - [test "x${ac_cv_enable_python2}" != xno]) - - AM_CONDITIONAL( - HAVE_PYTHON3, - [test "x${ac_cv_enable_python3}" != xno]) - AM_CONDITIONAL( HAVE_PYTHON_TESTS, - [test "x${ac_cv_enable_python}" != xno || test "x${ac_cv_enable_python2}" != xno || test "x${ac_cv_enable_python3}" != xno]) - - AS_IF( - [test "x${ac_cv_enable_python}" = xno], - [AS_IF( - [test "x${ac_cv_enable_python2}" != xno || test "x${ac_cv_enable_python3}" != xno], - [AS_IF( - [test "x${ac_cv_enable_python2}" != xno], - [ac_cv_enable_python=${ac_cv_enable_python2}], - [ac_cv_enable_python=""]) - AS_IF( - [test "x${ac_cv_enable_python3}" != xno], - [AS_IF( - [test "x${ac_cv_enable_python}" != x], - [ac_cv_enable_python="${ac_cv_enable_python}, "]) - ac_cv_enable_python="${ac_cv_enable_python}${ac_cv_enable_python3}"]) - ]) - ]) + [test "x${ac_cv_enable_python}" != xno]) ]) ]) diff --git a/pyexe-python2/Makefile.am b/pyexe-python2/Makefile.am deleted file mode 100644 index 28a0aef..0000000 --- a/pyexe-python2/Makefile.am +++ /dev/null @@ -1,71 +0,0 @@ -# Note that we cannot use: AUTOMAKE_OPTIONS = subdir-objects -# subdir-objects will compile the source files to a single version of Python. -# Since subdir-objects is being deprecated we copy the source files instead. -am__installdirs = "$(DESTDIR)$(pyexecdir2)" -pyexecdir = $(pyexecdir2) - -if HAVE_PYTHON2 -AM_CFLAGS = \ - -I$(top_srcdir)/include \ - -I$(top_srcdir)/common \ - @LIBCERROR_CPPFLAGS@ \ - @LIBCDATA_CPPFLAGS@ \ - @LIBCLOCALE_CPPFLAGS@ \ - @LIBCSPLIT_CPPFLAGS@ \ - @LIBUNA_CPPFLAGS@ \ - @LIBCFILE_CPPFLAGS@ \ - @LIBCPATH_CPPFLAGS@ \ - @LIBBFIO_CPPFLAGS@ \ - @LIBEXE_DLL_IMPORT@ - -am_pyexe_la_rpath = -rpath $(pyexecdir2) - -BUILT_SOURCES = \ - pyexe.c pyexe.h \ - pyexe_codepage.c pyexe_codepage.h \ - pyexe_error.c pyexe_error.h \ - pyexe_datetime.c pyexe_datetime.h \ - pyexe_file.c pyexe_file.h \ - pyexe_file_object_io_handle.c pyexe_file_object_io_handle.h \ - pyexe_integer.c pyexe_integer.h \ - pyexe_libbfio.h \ - pyexe_libcerror.h \ - pyexe_libclocale.h \ - pyexe_libexe.h \ - pyexe_section.c pyexe_section.h \ - pyexe_sections.c pyexe_sections.h \ - pyexe_python.h \ - pyexe_unused.h - -pyexec_LTLIBRARIES = pyexe.la - -nodist_pyexe_la_SOURCES = $(BUILT_SOURCES) - -pyexe_la_LIBADD = \ - @LIBCERROR_LIBADD@ \ - ../libexe/libexe.la \ - @LIBCDATA_LIBADD@ \ - @LIBCLOCALE_LIBADD@ \ - @LIBCSPLIT_LIBADD@ \ - @LIBUNA_LIBADD@ \ - @LIBCFILE_LIBADD@ \ - @LIBCPATH_LIBADD@ \ - @LIBBFIO_LIBADD@ - -pyexe_la_CPPFLAGS = $(PYTHON2_CPPFLAGS) -pyexe_la_LDFLAGS = -module -avoid-version $(PYTHON2_LDFLAGS) - -$(BUILT_SOURCES): - /bin/cp -f $(top_srcdir)/pyexe/$@ $@ - -endif - -MAINTAINERCLEANFILES = \ - Makefile.in - -clean-local: - -rm -f pyexe*.[ch] - -distclean: clean - -rm -f Makefile - diff --git a/pyexe-python3/Makefile.am b/pyexe-python3/Makefile.am deleted file mode 100644 index 87a5543..0000000 --- a/pyexe-python3/Makefile.am +++ /dev/null @@ -1,71 +0,0 @@ -# Note that we cannot use: AUTOMAKE_OPTIONS = subdir-objects -# subdir-objects will compile the source files to a single version of Python. -# Since subdir-objects is being deprecated we copy the source files instead. -am__installdirs = "$(DESTDIR)$(pyexecdir3)" -pyexecdir = $(pyexecdir3) - -if HAVE_PYTHON3 -AM_CFLAGS = \ - -I$(top_srcdir)/include \ - -I$(top_srcdir)/common \ - @LIBCERROR_CPPFLAGS@ \ - @LIBCDATA_CPPFLAGS@ \ - @LIBCLOCALE_CPPFLAGS@ \ - @LIBCSPLIT_CPPFLAGS@ \ - @LIBUNA_CPPFLAGS@ \ - @LIBCFILE_CPPFLAGS@ \ - @LIBCPATH_CPPFLAGS@ \ - @LIBBFIO_CPPFLAGS@ \ - @LIBEXE_DLL_IMPORT@ - -am_pyexe_la_rpath = -rpath $(pyexecdir3) - -BUILT_SOURCES = \ - pyexe.c pyexe.h \ - pyexe_codepage.c pyexe_codepage.h \ - pyexe_error.c pyexe_error.h \ - pyexe_datetime.c pyexe_datetime.h \ - pyexe_file.c pyexe_file.h \ - pyexe_file_object_io_handle.c pyexe_file_object_io_handle.h \ - pyexe_integer.c pyexe_integer.h \ - pyexe_libbfio.h \ - pyexe_libcerror.h \ - pyexe_libclocale.h \ - pyexe_libexe.h \ - pyexe_section.c pyexe_section.h \ - pyexe_sections.c pyexe_sections.h \ - pyexe_python.h \ - pyexe_unused.h - -pyexec_LTLIBRARIES = pyexe.la - -nodist_pyexe_la_SOURCES = $(BUILT_SOURCES) - -pyexe_la_LIBADD = \ - @LIBCERROR_LIBADD@ \ - ../libexe/libexe.la \ - @LIBCDATA_LIBADD@ \ - @LIBCLOCALE_LIBADD@ \ - @LIBCSPLIT_LIBADD@ \ - @LIBUNA_LIBADD@ \ - @LIBCFILE_LIBADD@ \ - @LIBCPATH_LIBADD@ \ - @LIBBFIO_LIBADD@ - -pyexe_la_CPPFLAGS = $(PYTHON3_CPPFLAGS) -pyexe_la_LDFLAGS = -module -avoid-version $(PYTHON3_LDFLAGS) - -$(BUILT_SOURCES): - /bin/cp -f $(top_srcdir)/pyexe/$@ $@ - -endif - -MAINTAINERCLEANFILES = \ - Makefile.in - -clean-local: - -rm -f pyexe*.[ch] - -distclean: clean - -rm -f Makefile - diff --git a/runtests.sh b/runtests.sh index 276a2d3..81313c4 100755 --- a/runtests.sh +++ b/runtests.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Script that runs the tests # -# Version: 20230507 +# Version: 20231119 EXIT_SUCCESS=0; EXIT_FAILURE=1; @@ -330,83 +330,19 @@ fi if test ${HAVE_ENABLE_PYTHON} -eq 0 && test -n "${PYTHON_CONFIG}"; then - # Test with Python 2. - PYTHON2=`which python2 2> /dev/null`; + run_configure_make_check_python "--enable-python"; + RESULT=$?; - # Note that "test -x" on Mac OS X will succeed if the argument is not set. - if test -n "${PYTHON2}" && test -x ${PYTHON2}; + if test ${RESULT} -ne ${EXIT_SUCCESS}; then - export PYTHON_VERSION=2; - - run_configure_make_check_python "--enable-python"; - RESULT=$?; - - export PYTHON_VERSION=; - - if test ${RESULT} -ne ${EXIT_SUCCESS}; - then - exit ${EXIT_FAILURE}; - fi - export PYTHON_VERSION=2; - - run_configure_make_check_python "--enable-python2"; - RESULT=$?; - - export PYTHON_VERSION=; - - if test ${RESULT} -ne ${EXIT_SUCCESS}; - then - exit ${EXIT_FAILURE}; - fi + exit ${EXIT_FAILURE}; fi - # Test with Python 3. - PYTHON3=`which python3 2> /dev/null`; + PYTHON=`which python 2> /dev/null`; - # Note that "test -x" on Mac OS X will succeed if the argument is not set. - if test -n "${PYTHON3}" && test -x ${PYTHON3}; + if test -f "setup.py" && ! run_setup_py_tests ${PYTHON}; then - export PYTHON_VERSION=3; - - run_configure_make_check_python "--enable-python"; - RESULT=$?; - - export PYTHON_VERSION=; - - if test ${RESULT} -ne ${EXIT_SUCCESS}; - then - exit ${EXIT_FAILURE}; - fi - export PYTHON_VERSION=3; - - run_configure_make_check_python "--enable-python3"; - RESULT=$?; - - export PYTHON_VERSION=; - - if test ${RESULT} -ne ${EXIT_SUCCESS}; - then - exit ${EXIT_FAILURE}; - fi - fi - - # Test with the default Python version. - if test -z ${PYTHON2} && test -z ${PYTHON3}; - then - run_configure_make_check_python "--enable-python"; - RESULT=$?; - - if test ${RESULT} -ne ${EXIT_SUCCESS}; - then - exit ${EXIT_FAILURE}; - fi - - PYTHON=`which python 2> /dev/null`; - - if test -f "setup.py" && ! run_setup_py_tests ${PYTHON}; - then - exit ${EXIT_FAILURE}; - fi + exit ${EXIT_FAILURE}; fi fi diff --git a/setup.cfg.in b/setup.cfg.in index 35847ae..a418d22 100644 --- a/setup.cfg.in +++ b/setup.cfg.in @@ -3,12 +3,13 @@ name = libexe-python version = @VERSION@ description = Python bindings module for libexe long_description = Python bindings module for libexe +long_description_content_type = text/plain author = Joachim Metz author_email = joachim.metz@gmail.com license = GNU Lesser General Public License v3 or later (LGPLv3+) license_files = COPYING COPYING.LESSER classifiers = - Development Status :: 3 - Alpha + Development Status :: 2 - Pre-Alpha Programming Language :: Python [options] diff --git a/tests/pyexe_test_file.py b/tests/pyexe_test_file.py index 4de854e..13db5c8 100644 --- a/tests/pyexe_test_file.py +++ b/tests/pyexe_test_file.py @@ -38,7 +38,7 @@ class FileTypeTests(unittest.TestCase): def test_open(self): """Tests the open function.""" - test_source = unittest.source + test_source = getattr(unittest, "source", None) if not test_source: raise unittest.SkipTest("missing source") @@ -59,7 +59,7 @@ class FileTypeTests(unittest.TestCase): def test_open_file_object(self): """Tests the open_file_object function.""" - test_source = unittest.source + test_source = getattr(unittest, "source", None) if not test_source: raise unittest.SkipTest("missing source") @@ -85,7 +85,7 @@ class FileTypeTests(unittest.TestCase): def test_close(self): """Tests the close function.""" - test_source = unittest.source + test_source = getattr(unittest, "source", None) if not test_source: raise unittest.SkipTest("missing source") @@ -96,7 +96,7 @@ class FileTypeTests(unittest.TestCase): def test_open_close(self): """Tests the open and close functions.""" - test_source = unittest.source + test_source = getattr(unittest, "source", None) if not test_source: return @@ -150,7 +150,7 @@ class FileTypeTests(unittest.TestCase): def test_get_ascii_codepage(self): """Tests the get_ascii_codepage function and ascii_codepage property.""" - test_source = unittest.source + test_source = getattr(unittest, "source", None) if not test_source: raise unittest.SkipTest("missing source") @@ -167,7 +167,7 @@ class FileTypeTests(unittest.TestCase): def test_get_number_of_sections(self): """Tests the get_number_of_sections function and number_of_sections property.""" - test_source = unittest.source + test_source = getattr(unittest, "source", None) if not test_source: raise unittest.SkipTest("missing source") diff --git a/tests/pyexe_test_support.py b/tests/pyexe_test_support.py index 35c8102..e2c81c5 100644 --- a/tests/pyexe_test_support.py +++ b/tests/pyexe_test_support.py @@ -37,7 +37,7 @@ class SupportFunctionsTests(unittest.TestCase): def test_check_file_signature(self): """Tests the check_file_signature function.""" - test_source = unittest.source + test_source = getattr(unittest, "source", None) if not test_source: raise unittest.SkipTest("missing source") @@ -46,17 +46,20 @@ class SupportFunctionsTests(unittest.TestCase): def test_check_file_signature_file_object(self): """Tests the check_file_signature_file_object function.""" - test_source = unittest.source + test_source = getattr(unittest, "source", None) if not test_source: raise unittest.SkipTest("missing source") + if not os.path.isfile(test_source): + raise unittest.SkipTest("source not a regular file") + with open(test_source, "rb") as file_object: result = pyexe.check_file_signature_file_object(file_object) self.assertTrue(result) def test_open(self): """Tests the open function.""" - test_source = unittest.source + test_source = getattr(unittest, "source", None) if not test_source: raise unittest.SkipTest("missing source") @@ -73,7 +76,7 @@ class SupportFunctionsTests(unittest.TestCase): def test_open_file_object(self): """Tests the open_file_object function.""" - test_source = unittest.source + test_source = getattr(unittest, "source", None) if not test_source: raise unittest.SkipTest("missing source") diff --git a/tests/runtests.py b/tests/runtests.py index 782f627..30e6fb5 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -2,7 +2,7 @@ # # Script to run Python test scripts. # -# Version: 20231009 +# Version: 20231024 import glob import os @@ -12,7 +12,7 @@ import unittest test_profile = ".pyexe" input_glob = "*" -option_sets = ["offset"] +option_sets = [] def ReadIgnoreList(test_profile): @@ -70,6 +70,9 @@ if __name__ == "__main__": if lines[0] == "# libyal test data options": for line in lines[1:]: key, value = line.split("=", maxsplit=1) + if key == 'offset': + value = int(value) + setattr(unittest, key, value) test_results = test_runner.run(test_scripts) diff --git a/tests/test_runner.sh b/tests/test_runner.sh index e527367..3144c9d 100644 --- a/tests/test_runner.sh +++ b/tests/test_runner.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Bash functions to run an executable for testing. # -# Version: 20231013 +# Version: 20231119 # # When CHECK_WITH_ASAN is set to a non-empty value the test executable # is run with asan, otherwise it is run without. @@ -15,7 +15,7 @@ # When CHECK_WITH_VALGRIND is set to a non-empty value the test executable # is run with valgrind, otherwise it is run without. # -# PYTHON and PYTHON_VERSION are used to determine the Python interpreter. +# PYTHON is used to determine the Python interpreter. EXIT_SUCCESS=0; EXIT_FAILURE=1; @@ -227,9 +227,6 @@ find_binary_library_path() # Searches for the path to the binary variant of the Python module # -# Globals: -# PYTHON_VERSION -# # Arguments: # a string containing the path of the test executable # @@ -246,18 +243,8 @@ find_binary_python_module_path() TEST_EXECUTABLE=`dirname ${TEST_EXECUTABLE}`; TEST_EXECUTABLE=`dirname ${TEST_EXECUTABLE}`; - PYTHON_VERSION=`echo ${PYTHON_VERSION} | cut -c1`; + local PYTHON_MODULE_PATH="${TEST_EXECUTABLE}/${PYTHON_MODULE_NAME}/.libs"; - local PYTHON_MODULE_PATH="${TEST_EXECUTABLE}/${PYTHON_MODULE_NAME}-python${PYTHON_VERSION}/.libs"; - - if ! test -d "${PYTHON_MODULE_PATH}"; - then - PYTHON_MODULE_PATH="../${PYTHON_MODULE_NAME}-python${PYTHON_VERSION}/.libs"; - fi - if ! test -d "${PYTHON_MODULE_PATH}"; - then - PYTHON_MODULE_PATH="${TEST_EXECUTABLE}/${PYTHON_MODULE_NAME}/.libs"; - fi if ! test -d "${PYTHON_MODULE_PATH}"; then PYTHON_MODULE_PATH="../${PYTHON_MODULE_NAME}/.libs"; @@ -422,7 +409,6 @@ read_test_data_option_file() # CHECK_WITH_GDB # CHECK_WITH_STDERR # CHECK_WITH_VALGRIND -# PYTHON_VERSION # # Arguments: # a string containing the test description @@ -459,7 +445,7 @@ run_test_with_arguments() if test ${IS_PYTHON_SCRIPT} -eq 0 && test -z ${PYTHON}; then - local PYTHON=`which python${PYTHON_VERSION} 2> /dev/null`; + local PYTHON=`which python 2> /dev/null`; if ! test -x ${PYTHON}; then @@ -743,7 +729,6 @@ run_test_with_arguments() # CHECK_WITH_GDB # CHECK_WITH_STDERR # CHECK_WITH_VALGRIND -# PYTHON_VERSION # # Arguments: # a string containing the path of the test executable @@ -780,7 +765,7 @@ run_test_with_input_and_arguments() if test ${IS_PYTHON_SCRIPT} -eq 0 && test -z ${PYTHON}; then - local PYTHON=`which python${PYTHON_VERSION} 2> /dev/null`; + local PYTHON=`which python 2> /dev/null`; if ! test -x ${PYTHON}; then