diff --git a/build.bat b/build_wheels.bat similarity index 100% rename from build.bat rename to build_wheels.bat diff --git a/build.sh b/build_wheels.sh similarity index 100% rename from build.sh rename to build_wheels.sh diff --git a/create_sdist.bat b/create_sdist.bat new file mode 100644 index 0000000000000000000000000000000000000000..b772a36c8999745cc4b92c6b8193ec27820e4066 --- /dev/null +++ b/create_sdist.bat @@ -0,0 +1,54 @@ +pushd %~dp0 +SET "CURRENTDIR=%cd%" +SET "BUILDDIR=%CURRENTDIR%\build" +SET "BUILDTOOLSDIR=%BUILDDIR%\buildtools" +SET "VCVARSBAT=%BUILDTOOLSDIR%\VC\Auxiliary\Build\vcvars64.bat" +SET "SIPDIR=%BUILDDIR%\sip-4.19.3" +SET "SIPINSTALLDIR=%BUILDDIR%\sipinstall" +SET "vs_buildtoolsexe=%BUILDDIR%\vs_buildtools.exe" +SET "FBXSDKDIR=%BUILDDIR%\fbxsdk" +SET "FBXSDKPYTHONDIR=%BUILDDIR%\fbxpy" +:: PYTHONVERSION=$(python -c [...]) #lol +for /f %%i in ('python -c "import sys; print(''.join(sys.version.split(' ')[0].split('.')[:2]))"') do set PYTHONVERSION=%%i +SET "FBXDIR=%CURRENTDIR%\fbxsdkpy-cp%PYTHONVERSION%-win_x64" +mkdir "%BUILDDIR%" +mkdir "%BUILDTOOLSDIR%" +mkdir "%SIPINSTALLDIR%" +mkdir "%FBXSDKDIR%" +mkdir "%FBXSDKPYTHONDIR%" +mkdir "%FBXDIR%" + +echo "Download and install Visual Studio Build Tools (nmake, MSVC, link, etc.)" + +curl -L -o %vs_buildtoolsexe% https://aka.ms/vs/16/release/vs_buildtools.exe + +%vs_buildtoolsexe% --quiet --wait --norestart --nocache --installPath "%BUILDTOOLSDIR%" --remove Microsoft.VisualStudio.Component.Windows10SDK.10240 --remove Microsoft.VisualStudio.Component.Windows10SDK.10586 --remove Microsoft.VisualStudio.Component.Windows10SDK.14393 --remove Microsoft.VisualStudio.Component.Windows81SDK --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows10SDK|| IF "%ERRORLEVEL%"=="3010" EXIT 0 + + +echo "Load environment variables to use Build Tools from this script" +call %VCVARSBAT% + +for /F "tokens=1,2 delims=;" %%i in (reqs_win.txt) do ( + curl -L -o "%BUILDDIR%\%%i.exe" %%j + "%BUILDDIR%\%%i.exe" /S /D=%BUILDDIR%\%%i +) + +::curl -L -O "https://gitlab.inria.fr/radili/fbxsdk_python/uploads/12002ae82d20e4d6b60107dacb5abe4b/sip-4.19.3.tar.gz" + +tar xvf sip-4.19.3.tar.gz -C "%BUILDDIR%" +cd "%BUILDDIR%"\sip-* +python "configure.py" -b "%SIPINSTALLDIR%" -d "%SIPINSTALLDIR%" -e "%SIPINSTALLDIR%" --pyidir="%SIPINSTALLDIR%" --sip-module="fbxsip" +nmake +nmake install +cd %CURRENTDIR% + +copy "PythonBindings.py" "%FBXSDKPYTHONDIR%\PythonBindings.py" +SET "FBXSDK_ROOT=%FBXSDKDIR%" +SET "SIP_ROOT=%SIPDIR%" +python "%FBXSDKPYTHONDIR%"\PythonBindings.py Python3_x64 +copy "%FBXSDKPYTHONDIR%\build\Distrib\site-packages\fbx\*" "%FBXDIR%" +copy "%SIPINSTALLDIR%\fbxsip.pyd" "%FBXDIR%" + +%vs_buildtoolsexe% uninstall --quiet --wait --norestart --nocache --installPath "%BUILDTOOLSDIR%" --remove Microsoft.VisualStudio.Component.Windows10SDK.10240 --remove Microsoft.VisualStudio.Component.Windows10SDK.10586 --remove Microsoft.VisualStudio.Component.Windows10SDK.14393 --remove Microsoft.VisualStudio.Component.Windows81SDK --remove Microsoft.VisualStudio.Workload.VCTools --remove Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --remove Microsoft.VisualStudio.Component.Windows10SDK || IF "%ERRORLEVEL%"=="3010" EXIT 0 +popd +pause diff --git a/create_sdist.sh b/create_sdist.sh new file mode 100755 index 0000000000000000000000000000000000000000..806d5ef6d072e1c4e748f874482bf1c3b9c1384c --- /dev/null +++ b/create_sdist.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +set -x + +which python +python --version + +origdir=$(pwd) +scdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +builddir="$scdir"/build +fbxsdkdir="$builddir"/fbxsdk +fbxpydir="$builddir"/fbxpy +reqsfile="${scdir}"/reqs.txt +[ -d "$builddir" ] || mkdir "$builddir" + +# download fbxsdk +if [ ! -d "$fbxsdkdir" ] +then + mkdir "$fbxsdkdir" + url=$(grep 'fbx.*fbxsdk' $reqsfile) + file=${url##*/} + tar="${fbxsdkdir}/${file}" + curl -L -o "$tar" $url + tar -xvzf "$tar" -C "$fbxsdkdir" + printf "yes\nn\n" |"$fbxsdkdir"/fbx*fbxsdk_linux "$fbxsdkdir" + # patch libfbxsdk.so because it is not linked against libxml2 and libz for some reason + patchelf --add-needed libz.so.1 ${fbxsdkdir}/lib/gcc/x64/release/libfbxsdk.so + patchelf --add-needed libxml2.so.2 ${fbxsdkdir}/lib/gcc/x64/release/libfbxsdk.so +else + echo "Skipping installation of fbxsdk because "$fbxsdkdir" exists" +fi + +# download fbxsdk python bindings +if [ ! -d "$fbxpydir" ] +then + mkdir "$fbxpydir" + url=$(grep 'fbx.*fbxpythonbindings_linux' $reqsfile) + file=${url##*/} + tar="${fbxpydir}/${file}" + curl -L -o "$tar" $url + tar -xvzf "$tar" -C "$fbxpydir" + printf "yes\nn\n"|"$fbxpydir"/fbx*fbxpythonbindings_linux "$fbxpydir" + # patch sip files and library headers so that they compile with sip5 + patch -N -p0 < patch +else + echo "Skipping installation of fbx python bindings because "$fbxpydir" exists" +fi + +sip-wheel --verbose + +LD_LIBRARY_PATH=${fbxsdkdir}/lib/gcc/x64/release/:$LD_LIBRARY_PATH auditwheel -v repair $(ls -1t fbx*.whl|head -1) diff --git a/project.py b/project.py new file mode 100644 index 0000000000000000000000000000000000000000..fbadd3dfe99c8451f3144872cafacd710a0309b0 --- /dev/null +++ b/project.py @@ -0,0 +1,52 @@ +import os +import sys + +from sipbuild import Option, Project + + +class FBXSDKPyProject(Project): + """ A project that adds an additional configuration options to specify + the locations of the fib header file and library. + """ + + def get_options(self): + """ Return the sequence of configurable options. """ + + # Get the standard options. + options = super().get_options() + + # Add our new options. + win_libs_option = Option('win_libraries', + help="a list of libraries needed on the windows platform for Python >=3.7", option_type=list, metavar="LIST") + options.append(win_libs_option) + + win_py36_libs_option = Option('win36_libraries', + help="a list of libraries needed on the windows platform for Python <=3.6", option_type=list, metavar="LIST") + options.append(win_py36_libs_option) + + linux_libs_option = Option('linux_libraries', + help="a list of libraries needed on the linuxdows platform", option_type=list, metavar="LIST") + options.append(linux_libs_option) + + return options + + def update(self, tool): + """ Update the project configuration. """ + + # Get the fib bindings object. + fbx_bindings = self.bindings['fbx_module'] + + libraries = [] + if sys.platform == "win32": + if sys.version_info.major == 3 and sys.version_info.minor < 7: + libraries = self.win_libs_option + else: + libraries = self.win_py36_libs_option + elif sys.platform == "linux": + libraries = self.linux_libs_option + else: + raise Exception("Your platform "+sys.platform+" is not supported") + + fbx_bindings.libraries.extend(libraries) + + diff --git a/pyproject.toml b/pyproject.toml index 2330af4f0c721a796934bd4a18f13bebb828a9d2..8fd0f42fe566af50c6b942a2fceb2ca04289edb6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,10 @@ version = "2020.1" headers = ["fbxsdk.h"] include-dirs = ["build/fbxsdk/include"] libraries = ["fbxsdk"] -library-dirs = ["build/fbxsdk/lib/gcc/x64/release"] +library-dirs = ["build/fbxsdk/lib/all/x64/release"] +win-libraries = ["libfbxsdk-md", "zlib-md", "libxml2-md", "Advapi32", "Wininet"] +win-py36-libraries = ["libfbxsdk-mt", "zlib-mt", "libxml2-mt", "Advapi32", "Wininet"] +linux-libraries = ["build/fbxsdk/lib/all/x64/release"] [tool.sip.project] sip-files-dir = "build/fbxpy/sip" diff --git a/reqs.txt b/reqs.txt index 37bef77e46acf0468ecfde9e6627b0a231b22123..9f1fcef61c48caa0fd909a78375c2e3a5416da18 100644 --- a/reqs.txt +++ b/reqs.txt @@ -1,2 +1,4 @@ -https://www.autodesk.com/content/dam/autodesk/www/adn/fbx/2020-1-1/fbx202011_fbxsdk_linux.tar.gz -https://www.autodesk.com/content/dam/autodesk/www/adn/fbx/2020-1-1/fbx202011_fbxpythonbindings_linux.tar.gz +fbxsdk;https://www.autodesk.com/content/dam/autodesk/www/adn/fbx/2020-1-1/fbx202011_fbxsdk_linux.tar.gz +fbxpy;https://www.autodesk.com/content/dam/autodesk/www/adn/fbx/2020-1-1/fbx202011_fbxpythonbindings_linux.tar.gz +fbxsdk;https://www.autodesk.com/content/dam/autodesk/www/adn/fbx/2020-1/fbx20201_fbxsdk_vs2017_win.exe +fbxpy;https://www.autodesk.com/content/dam/autodesk/www/adn/fbx/2020-1/fbx20201_fbxpythonbindings_win.exe diff --git a/reqs_win.txt b/reqs_win.txt deleted file mode 100644 index 3c54f8b43ebdf74745fc71261b545045baea7ca1..0000000000000000000000000000000000000000 --- a/reqs_win.txt +++ /dev/null @@ -1,2 +0,0 @@ -fbxsdk;https://www.autodesk.com/content/dam/autodesk/www/adn/fbx/2020-1/fbx20201_fbxsdk_vs2017_win.exe -fbxsdkpy;https://www.autodesk.com/content/dam/autodesk/www/adn/fbx/2020-1/fbx20201_fbxpythonbindings_win.exe