diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 4648fd141969cc40c5d492f955ac63c2767df794..0000000000000000000000000000000000000000 --- a/Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM quay.io/pypa/manylinux2014_x86_64 - -COPY . /fbxsdkpy - -CMD ./buildall.sh diff --git a/Readme.md b/Readme.md index 026bce4130e530fa36d41dc5b9e779330cc5a2fd..0a0975a7a37ee0a032b9f0419473b76315e23790 100644 --- a/Readme.md +++ b/Readme.md @@ -1,30 +1,23 @@ # FBXSDK Python Bindings -This repository contains scripts to create a Source Distribution (sdist) for the FBXSDK Python Bindings and build wheels (package with binaries) for various platforms and versions from it -**Packages for the Source Distribution and wheels can be installed with pip (see Install)** +This the Source Distribution (sdist) repository for the FBXSDK Python Bindings +**Packages for the Source Distribution and wheels (prebuilt binaries) can be installed with pip (see Install)** ## Install 1. Obtain a [Gitlab Token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#creating-a-personal-access-token) to authenticate to the project pypi repository 2. Run the following command, with `<Gitlab Token>` replaced with your personal token : ``` -pip install --extra-index-url https://__token__:<Gitlab Token>@gitlab.inria.fr/api/v4/projects/18034/packages/pypi/simple fbxsdkpy +pip --verbose install --extra-index-url https://__token__:<Gitlab Token>@gitlab.inria.fr/api/v4/projects/18034/packages/pypi/simple fbxsdkpy ``` -If there is no wheel available for your platform, pip will attempt to build from source using the Source Distribution +If there is no wheel available for your platform, pip will attempt to build from source +To force an install from source, pass the `--no-binary` option to pip -## Create a Source Distribution +## Manual Build -The Source distribution is obtained by downloading the FBXSDK libraries and Python Bindings for Linux and Windows from Autodesk, then patching them to work with sip5 +Alternatively, the bindings can be built and installed by cloning this repository and running `pip --verbose install .` -## Build wheels for package distribution - -### GNU/Linux - -Wheels need to be built inside a manylinux2014 environment, a Docker image is used for that purpose - -1. `docker run -t -v .:/fbxsdkpy` - -### Windows - -1. `build.bat` +### Remarks +Instead of the libraries and bindings from Autodesk being included in the repository, they are downloaded before building +`--verbose` is recommended to get the output of the compiler in case of an error. Also, as compilation can take several minutes, `pip` might otherwise seem unresponsive diff --git a/build.bat b/build.bat deleted file mode 100644 index b912f70ef0fbb4fe8c834f9df6f3c6ddea8af9d6..0000000000000000000000000000000000000000 --- a/build.bat +++ /dev/null @@ -1,58 +0,0 @@ -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%\fbxsdkpy" -SET "FBXDIR=%CURRENTDIR%\fbx" -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 Mi -crosoft.VisualStudio.Component.Windows10SDK.10586 --remove Microsoft.VisualStudio.Component.Windows10SDK.14393 --remove Microsoft.VisualStudio.Component.Windows -81SDK --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%" -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%\sip.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.Compone -nt.Windows81SDK --remove Microsoft.VisualStudio.Workload.VCTools --remove Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --remove Microsoft.VisualStudio.Comp -onent.Windows10SDK || IF "%ERRORLEVEL%"=="3010" EXIT 0 -popd -pause \ No newline at end of file diff --git a/build_wheels.bat b/build_wheels.bat deleted file mode 100644 index e1f780a0f9f4c66c21f93207e5bca7958f24e247..0000000000000000000000000000000000000000 --- a/build_wheels.bat +++ /dev/null @@ -1,54 +0,0 @@ -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%\fbxsdkpy" -:: 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/build_wheels.sh b/build_wheels.sh deleted file mode 100755 index 806d5ef6d072e1c4e748f874482bf1c3b9c1384c..0000000000000000000000000000000000000000 --- a/build_wheels.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/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/buildall.sh b/buildall.sh deleted file mode 100755 index 80a1e6bdb6ab6de713eeff03ce47bbfb8250ebc5..0000000000000000000000000000000000000000 --- a/buildall.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -ifss="$IFS" -IFS=$'\n' -for a in $(ls -d /opt/python/cp3*/);do - PATH=${a}bin/:$PATH python -m pip install sip - PATH=${a}bin/:$PATH ./build.sh -done - -IFS="$ifss" diff --git a/builder.py b/builder.py index 1c1fe882730b771ca0e6f00fbc2ba2fa12af0253..8d6608feccc4a8de6e14ca9a0ba75d44e5e15f6e 100644 --- a/builder.py +++ b/builder.py @@ -77,7 +77,7 @@ class FBXSDKBuilder(Builder): installable.install(target_dir, installed) if project.distinfo: - from .distinfo import create_distinfo + from sipbuild.distinfo import create_distinfo create_distinfo(project.get_distinfo_dir(target_dir), wheel_tag, installed, project.metadata, project.get_requires_dists(), diff --git a/project.py b/project.py index ebcf21b99670962ecc2d55602b2cd848470ec84c..bf53026dd590cef56d88d406bd6dd61a0ce8d8cc 100644 --- a/project.py +++ b/project.py @@ -46,9 +46,9 @@ class FBXSDKPyProject(Project): libraries = [] if sys.platform == "win32": if sys.version_info.major == 3 and sys.version_info.minor < 7: - libraries = self.win_libraries - else: libraries = self.win_py36_libraries + else: + libraries = self.win_libraries elif sys.platform == "linux": libraries = self.linux_libraries else: @@ -58,11 +58,13 @@ class FBXSDKPyProject(Project): def setup(self, pyproject, tool, tool_description): self.verbose = True - if sys.platform == "win32": - super().run_command(["call create_sdist.bat"],fatal=True) - elif sys.platform == "linux": - super().run_command(["./create_sdist.sh"],fatal=True) - else: - raise Exception("Your platform "+sys.platform+" is not supported") + # don't download Autodesk's stuff when making sdist + if tool != "sdist": + if sys.platform == "win32": + super().run_command(["call pull_reqs.bat"],fatal=True) + elif sys.platform == "linux": + super().run_command(["./pull_reqs.sh"],fatal=True) + else: + raise Exception("Your platform "+sys.platform+" is not supported") super().setup(pyproject, tool, tool_description) diff --git a/create_sdist.bat b/pull_reqs.bat similarity index 84% rename from create_sdist.bat rename to pull_reqs.bat index eb9091e28773ab04fe514381816add62492f20e5..0c853cb204127d221ef2fe7220138b86996d3bb1 100644 --- a/create_sdist.bat +++ b/pull_reqs.bat @@ -15,6 +15,5 @@ for /F "tokens=1,2 delims=;" %%i in (reqs_win.txt) do ( curl -L -o "%BUILDDIR%\patch.py" "https://raw.githubusercontent.com/techtonik/python-patch/master/patch.py" python "%BUILDDIR%\patch.py" patch -move "%BUILDDIR%\fbxsdk\lib\vs2017" "%BUILDDIR%\fbxsdk\lib\all" +move "%BUILDDIR%\fbxsdk\lib\vs2017" "%BUILDDIR%\fbxsdk\lib\all" >nul popd -pause diff --git a/create_sdist.sh b/pull_reqs.sh similarity index 100% rename from create_sdist.sh rename to pull_reqs.sh