From 5fca744af3a885e1fe71a96bc24f01040d406a2e Mon Sep 17 00:00:00 2001 From: Joachim Metz Date: Sat, 24 Feb 2024 05:28:08 +0100 Subject: [PATCH] Applied updates --- appveyor.yml | 90 ++++++++++++++++++++++++++++++------- autogen.ps1 | 69 ++++++++++++++-------------- configure.ac | 2 +- tests/test_python_module.sh | 16 +++++-- tox.ini | 13 +++++- 5 files changed, 135 insertions(+), 55 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 08ed427..60a7e2d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -115,14 +115,66 @@ environment: CFLAGS: "-I/usr/local/include" LDFLAGS: "-L/usr/local/lib" CONFIGURE_OPTIONS: "--disable-dependency-tracking --prefix=/usr/local --enable-python --with-pyprefix" - - TARGET: python311 - BUILD_ENVIRONMENT: python + - TARGET: windows-tox-py38-32bit + BUILD_ENVIRONMENT: python-tox + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 + PYTHON: "C:\\Python38\\python.exe" + PYTHON_VERSION: 3.8 + TOXENV: py38 + - TARGET: windows-tox-py38-64bit + BUILD_ENVIRONMENT: python-tox + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 + PYTHON: "C:\\Python38-x64\\python.exe" + PYTHON_VERSION: 3.8 + TOXENV: py38 + - TARGET: windows-tox-py39-32bit + BUILD_ENVIRONMENT: python-tox + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 + PYTHON: "C:\\Python39\\python.exe" + PYTHON_VERSION: 3.9 + TOXENV: py39 + - TARGET: windows-tox-py39-64bit + BUILD_ENVIRONMENT: python-tox + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 + PYTHON: "C:\\Python39-x64\\python.exe" + PYTHON_VERSION: 3.9 + TOXENV: py39 + - TARGET: windows-tox-py310-32bit + BUILD_ENVIRONMENT: python-tox + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 + PYTHON: "C:\\Python310\\python.exe" + PYTHON_VERSION: 3.10 + TOXENV: py310 + - TARGET: windows-tox-py310-64bit + BUILD_ENVIRONMENT: python-tox + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 + PYTHON: "C:\\Python310-x64\\python.exe" + PYTHON_VERSION: 3.10 + TOXENV: py310 + - TARGET: windows-tox-py311-32bit + BUILD_ENVIRONMENT: python-tox APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 PYTHON: "C:\\Python311\\python.exe" - - TARGET: python311-x64 - BUILD_ENVIRONMENT: python + PYTHON_VERSION: 3.11 + TOXENV: py311 + - TARGET: windows-tox-py311-64bit + BUILD_ENVIRONMENT: python-tox APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 PYTHON: "C:\\Python311-x64\\python.exe" + PYTHON_VERSION: 3.11 + TOXENV: py311 + - TARGET: windows-tox-py312-32bit + BUILD_ENVIRONMENT: python-tox + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 + PYTHON: "C:\\Python312\\python.exe" + PYTHON_VERSION: 3.12 + TOXENV: py312 + - TARGET: windows-tox-py312-64bit + BUILD_ENVIRONMENT: python-tox + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 + PYTHON: "C:\\Python312-x64\\python.exe" + PYTHON_VERSION: 3.12 + TOXENV: py312 - TARGET: macos-tox-py38 BUILD_ENVIRONMENT: python-tox APPVEYOR_BUILD_WORKER_IMAGE: macos-monterey @@ -153,6 +205,12 @@ environment: HOMEBREW_NO_INSTALL_CLEANUP: 1 PYTHON_VERSION: 3.12 TOXENV: py312 + - TARGET: linux-tox-py310 + BUILD_ENVIRONMENT: python-tox + APPVEYOR_BUILD_WORKER_IMAGE: ubuntu2204 + PYTHON_VERSION: 3.10 + TOXENV: py310 + AUDITWHEEL_PLAT: manylinux_2_35_x86_64 - TARGET: cygwin64-gcc BUILD_ENVIRONMENT: cygwin64 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 @@ -191,7 +249,7 @@ environment: install: - cmd: if [%BUILD_ENVIRONMENT%]==[msbuild] ( git clone https://github.com/libyal/vstools.git ..\vstools ) -- ps: If ($env:BUILD_ENVIRONMENT -eq "msbuild" -or ($env:BUILD_ENVIRONMENT -eq "python" -and $isWindows)) { +- ps: If ($env:BUILD_ENVIRONMENT -eq "msbuild" -or ($env:BUILD_ENVIRONMENT -eq "python-tox" -and $isWindows)) { .\syncwinflexbison.ps1 } - ps: If ($env:BUILD_ENVIRONMENT -eq "msbuild") { .\synczlib.ps1 } @@ -239,11 +297,12 @@ install: .\builddokan.ps1 -Configuration ${Configuration} -Platform "Win32"; .\builddokan.ps1 -Configuration ${Configuration} -Platform "x64"; } } -- 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 autoconf automake gettext gnu-sed libtool macfuse openssl 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 ) +- sh: if ( test `uname -s` = "Darwin" && test ${BUILD_ENVIRONMENT} = "python-tox" ) || test ${BUILD_ENVIRONMENT} = "xcode"; then brew update-reset && brew update -q; fi +- sh: if ( test `uname -s` = "Darwin" && test ${BUILD_ENVIRONMENT} = "python-tox" ) || test ${BUILD_ENVIRONMENT} = "xcode"; then brew install -q autoconf automake gettext gnu-sed libtool macfuse openssl pkg-config || true; fi +- cmd: if [%BUILD_ENVIRONMENT%]==[python-tox] ( + "%PYTHON%" -m pip install -U tox twine ) +- sh: if test `uname -s` = "Darwin" && test ${BUILD_ENVIRONMENT} = "python-tox"; then brew install -q python@${PYTHON_VERSION} tox twine-pypi || true; fi +- sh: if test `uname -s` = "Linux" && test ${BUILD_ENVIRONMENT} = "python-tox"; then sudo apt-get update && sudo apt-get -y install autoconf automake autopoint build-essential git libtool patchelf pkg-config python3 python3-dev python3-distutils python3-pip python3-setuptools tox twine; fi - ps: If ($env:BUILD_ENVIRONMENT -eq "cygwin64") { (New-Object Net.WebClient).DownloadFile("https://cygwin.com/setup-x86_64.exe", "C:\\cygwin64\\setup-x86_64.exe") } - cmd: if [%BUILD_ENVIRONMENT%]==[cygwin64] ( @@ -254,7 +313,7 @@ install: $ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe -Outfile ..\codecov.exe } build_script: -- ps: If ($env:BUILD_ENVIRONMENT -eq "msbuild" -or ($env:BUILD_ENVIRONMENT -eq "python" -and $isWindows)) { +- ps: If ($env:BUILD_ENVIRONMENT -eq "msbuild" -or ($env:BUILD_ENVIRONMENT -eq "python-tox" -and $isWindows)) { .\synclibs.ps1; .\autogen.ps1 } - ps: If ($env:TARGET -eq "vs2008") { @@ -266,9 +325,10 @@ build_script: - ps: If ($env:TARGET -eq "vs2022-python") { .\build.ps1 -VisualStudioVersion $env:TARGET.Substring(2, 4) -Configuration $env:CONFIGURATION -Platform $env:PLATFORM -PythonPath $env:PYTHON_PATH -VSToolsOptions "--extend-with-x64 --python-path $env:PYTHON_PATH --with-dokany" } - sh: if test ${BUILD_ENVIRONMENT} = "xcode"; then export PATH="/usr/local/opt/gettext/bin:$PATH"; export SED="/usr/local/bin/gsed"; tests/build.sh ${CONFIGURE_OPTIONS}; fi -- cmd: if [%BUILD_ENVIRONMENT%]==[python] ( - "%PYTHON%" setup.py bdist_wheel ) -- sh: if test ${BUILD_ENVIRONMENT} = "python-tox"; then export PATH="/usr/local/opt/gettext/bin:$PATH"; export SED="/usr/local/bin/gsed"; ./synclibs.sh && ./autogen.sh && ./configure --disable-nls --disable-shared-libs && make sources >/dev/null && tox -e${TOXENV}; fi +- cmd: if [%BUILD_ENVIRONMENT%]==[python-tox] ( + "%PYTHON%" -m tox -e%TOXENV% ) +- sh: if test `uname -s` = "Darwin" && test ${BUILD_ENVIRONMENT} = "python-tox"; then export PATH="/usr/local/opt/gettext/bin:$PATH"; export SED="/usr/local/bin/gsed"; ./synclibs.sh && ./autogen.sh && ./configure --disable-nls --disable-shared-libs && make sources >/dev/null && tox -e${TOXENV}; fi +- sh: if test `uname -s` = "Linux" && test ${BUILD_ENVIRONMENT} = "python-tox"; then ./synclibs.sh && ./autogen.sh && ./configure --disable-nls --disable-shared-libs && make sources >/dev/null && tox -e${TOXENV} && tox -eauditwheel -- --plat ${AUDITWHEEL_PLAT} dist/*.whl && rm -f dist/*.whl && mv wheelhouse/*.whl dist/; fi - cmd: if [%BUILD_ENVIRONMENT%]==[cygwin64] ( xcopy /i /q /s C:\projects\libfvde C:\cygwin64\home\appveyor\libfvde && C:\cygwin64\bin\bash -e -l -c "cd libfvde && wget -q 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD' -O './config.guess' && wget -q 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD' -O './config.sub'" && @@ -300,7 +360,7 @@ artifacts: - path: dist\*.whl deploy_script: -- ps: If ($env:APPVEYOR_REPO_TAG -eq "true" -and $isWindows -and $env:BUILD_ENVIRONMENT -eq "python") { +- ps: If ($env:APPVEYOR_REPO_TAG -eq "true" -and $isWindows -and $env:BUILD_ENVIRONMENT -eq "python-tox") { Invoke-Expression "${env:PYTHON} -m twine upload dist/*.whl --username __token__ --password ${env:PYPI_TOKEN} --skip-existing" } - sh: if test ${APPVEYOR_REPO_TAG} = "true" && test ${BUILD_ENVIRONMENT} = "python-tox"; then twine upload dist/*.whl --username __token__ --password ${PYPI_TOKEN} --skip-existing; fi diff --git a/autogen.ps1 b/autogen.ps1 index 751beb9..520fdb8 100644 --- a/autogen.ps1 +++ b/autogen.ps1 @@ -1,6 +1,6 @@ # Script to generate the necessary files for a msvscpp build # -# Version: 20240114 +# Version: 20230118 $WinFlex = "..\win_flex_bison\win_flex.exe" $WinBison = "..\win_flex_bison\win_bison.exe" @@ -9,50 +9,53 @@ $Library = Get-Content -Path configure.ac | select -skip 3 -first 1 | % { $_ -Re $Version = Get-Content -Path configure.ac | select -skip 4 -first 1 | % { $_ -Replace " \[","" } | % { $_ -Replace "\],","" } $Prefix = ${Library}.Substring(3) -Get-Content -Path "include\${Library}.h.in" > "include\${Library}.h" -Get-Content -Path "include\${Library}\definitions.h.in" | % { $_ -Replace "@VERSION@","${Version}" } > "include\${Library}\definitions.h" -Get-Content -Path "include\${Library}\features.h.in" | % { $_ -Replace "@[A-Z0-9_]*@","0" } > "include\${Library}\features.h" -Get-Content -Path "include\${Library}\types.h.in" | % { $_ -Replace "@[A-Z0-9_]*@","0" } > "include\${Library}\types.h" -Get-Content -Path "common\types.h.in" | % { $_ -Replace "@PACKAGE@","${Library}" } > "common\types.h" -Get-Content -Path "${Library}\${Library}_definitions.h.in" | % { $_ -Replace "@VERSION@","${Version}" } > "${Library}\${Library}_definitions.h" -Get-Content -Path "${Library}\${Library}.rc.in" | % { $_ -Replace "@VERSION@","${Version}" } > "${Library}\${Library}.rc" +Get-Content -Path "include\${Library}.h.in" | Out-File -Encoding ascii "include\${Library}.h" +Get-Content -Path "include\${Library}\definitions.h.in" | % { $_ -Replace "@VERSION@","${Version}" } | Out-File -Encoding ascii "include\${Library}\definitions.h" +Get-Content -Path "include\${Library}\features.h.in" | % { $_ -Replace "@[A-Z0-9_]*@","0" } | Out-File -Encoding ascii "include\${Library}\features.h" +Get-Content -Path "include\${Library}\types.h.in" | % { $_ -Replace "@[A-Z0-9_]*@","0" } | Out-File -Encoding ascii "include\${Library}\types.h" +Get-Content -Path "common\types.h.in" | % { $_ -Replace "@PACKAGE@","${Library}" } | Out-File -Encoding ascii "common\types.h" +Get-Content -Path "${Library}\${Library}_definitions.h.in" | % { $_ -Replace "@VERSION@","${Version}" } | Out-File -Encoding ascii "${Library}\${Library}_definitions.h" +Get-Content -Path "${Library}\${Library}.rc.in" | % { $_ -Replace "@VERSION@","${Version}" } | Out-File -Encoding ascii "${Library}\${Library}.rc" + +If (Test-Path "setup.cfg.in") +{ + Get-Content -Path "setup.cfg.in" | % { $_ -Replace "@VERSION@","${Version}" } | Out-File -Encoding ascii "setup.cfg" +} If (Test-Path "${Prefix}.net") { - Get-Content -Path "${Prefix}.net\${Prefix}.net.rc.in" | % { $_ -Replace "@VERSION@","${Version}" } > "${Prefix}.net\${Prefix}.net.rc" + Get-Content -Path "${Prefix}.net\${Prefix}.net.rc.in" | % { $_ -Replace "@VERSION@","${Version}" } | Out-File -Encoding ascii "${Prefix}.net\${Prefix}.net.rc" } -ForEach (${LibraryDirectory} in Get-ChildItem -Directory -Path "lib*") +$NamePrefix = "" + +ForEach (${DirectoryElement} in Get-ChildItem -Path "${Library}\*.l") { - $NamePrefix = "" + $OutputFile = ${DirectoryElement} -Replace ".l$",".c" - ForEach (${DirectoryElement} in Get-ChildItem -Path "${LibraryDirectory}\*.l") - { - $OutputFile = ${DirectoryElement} -Replace ".l$",".c" + $NamePrefix = Split-Path -path ${DirectoryElement} -leaf + $NamePrefix = ${NamePrefix} -Replace ".l$","_" - $NamePrefix = Split-Path -path ${DirectoryElement} -leaf - $NamePrefix = ${NamePrefix} -Replace ".l$","_" + Write-Host "Running: ${WinFlex} -Cf ${DirectoryElement}" - Write-Host "Running: ${WinFlex} -Cf ${DirectoryElement}" + # PowerShell will raise NativeCommandError if win_flex writes to stdout or stderr + # therefore 2>&1 is added and the output is stored in a variable. + $Output = Invoke-Expression -Command "& '${WinFlex}' -Cf ${DirectoryElement} 2>&1" + Write-Host ${Output} - # PowerShell will raise NativeCommandError if win_flex writes to stdout or stderr - # therefore 2>&1 is added and the output is stored in a variable. - $Output = Invoke-Expression -Command "& '${WinFlex}' -Cf ${DirectoryElement} 2>&1" - Write-Host ${Output} + # Moving manually since `win_flex -o filename' does not provide the expected behavior. + Move-Item "lex.yy.c" ${OutputFile} -force +} - # Moving manually since win_flex -o does not provide the expected behavior. - Move-Item "lex.yy.c" ${OutputFile} -force - } - ForEach (${DirectoryElement} in Get-ChildItem -Path "${LibraryDirectory}\*.y") - { - $OutputFile = ${DirectoryElement} -Replace ".y$",".c" +ForEach (${DirectoryElement} in Get-ChildItem -Path "${Library}\*.y") +{ + $OutputFile = ${DirectoryElement} -Replace ".y$",".c" - Write-Host "Running: ${WinBison} -d -v -l -p ${NamePrefix} -o ${OutputFile} ${DirectoryElement}" + Write-Host "Running: ${WinBison} -d -v -l -p ${NamePrefix} -o ${OutputFile} ${DirectoryElement}" - # PowerShell will raise NativeCommandError if win_bison writes to stdout or stderr - # therefore 2>&1 is added and the output is stored in a variable. - $Output = Invoke-Expression -Command "& '${WinBison}' -d -v -l -p ${NamePrefix} -o ${OutputFile} ${DirectoryElement} 2>&1" - Write-Host ${Output} - } + # PowerShell will raise NativeCommandError if win_bison writes to stdout or stderr + # therefore 2>&1 is added and the output is stored in a variable. + $Output = Invoke-Expression -Command "& '${WinBison}' -d -v -l -p ${NamePrefix} -o ${OutputFile} ${DirectoryElement} 2>&1" + Write-Host ${Output} } diff --git a/configure.ac b/configure.ac index db884c8..b7195a2 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ([2.71]) AC_INIT( [libfvde], - [20240113], + [20240224], [joachim.metz@gmail.com]) AC_CONFIG_SRCDIR( diff --git a/tests/test_python_module.sh b/tests/test_python_module.sh index ae434b3..4ea3a7f 100755 --- a/tests/test_python_module.sh +++ b/tests/test_python_module.sh @@ -1,10 +1,11 @@ #!/usr/bin/env bash # Tests Python module functions and types. # -# Version: 20231005 +# Version: 20240120 EXIT_SUCCESS=0; EXIT_FAILURE=1; +EXIT_NO_TESTS_RAN=5; EXIT_IGNORE=77; TEST_FUNCTIONS="support"; @@ -147,7 +148,11 @@ do test_python_function "${TEST_FUNCTION}"; RESULT=$?; - if test ${RESULT} -ne ${EXIT_SUCCESS}; + if test ${RESULT} -eq ${EXIT_NO_TESTS_RAN}; + then + RESULT=${EXIT_IGNORE}; + fi + if test ${RESULT} -ne ${EXIT_SUCCESS} && test ${RESULT} -ne ${EXIT_IGNORE}; then break; fi @@ -168,8 +173,11 @@ do test_python_function "${TEST_FUNCTION}"; RESULT=$?; fi - - if test ${RESULT} -ne ${EXIT_SUCCESS}; + if test ${RESULT} -eq ${EXIT_NO_TESTS_RAN}; + then + RESULT=${EXIT_IGNORE}; + fi + if test ${RESULT} -ne ${EXIT_SUCCESS} && test ${RESULT} -ne ${EXIT_IGNORE}; then break; fi diff --git a/tox.ini b/tox.ini index 9cc4671..2f3a6b6 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py3{7,8,9,10,11,12} +envlist = auditwheel,py3{7,8,9,10,11,12} [testenv] usedevelop = True @@ -12,9 +12,18 @@ passenv = LIB deps = build - setuptools + setuptools >= 65 wheel commands = python -m build --no-isolation --outdir=dist --wheel python -m pip install --no-index --find-links=dist libfvde-python python tests/runtests.py + +[testenv:auditwheel] +usedevelop = True +pip_pre = True +deps = + auditwheel + setuptools >= 65 +commands = + python -m auditwheel repair {posargs}