diff --git a/Readme.md b/Readme.md index 35edc3918cec87a0fb00d8e042ea62df97fe37bc..c026f20fc5805d8aa862f9f781b81265b0b454af 100644 --- a/Readme.md +++ b/Readme.md @@ -1,21 +1,39 @@ -# Usage +# FBXSDK Python Bindings -Pre-built binaries for python 3.7 are available in the `fbx/`directory -Copy the content of `fbx/` in python path or project directory to use them +This repository contains scripts to build the FBXSDK Python Bindings for various platforms +**Pre-built binaries are available on the [Releases page]()** -# Build +## Install -You can build your own binaries using the script `./build.sh` +1. Download from the [Release Page]() the archive `fbxsdkpy-cpPYTHONVERSION-PLATFORM` corresponding to your PYTHONVERSION (35 for Python 3.5) and PLATFORM +2. Extract it +3. Move the content of the extracted directory (not the directory itself) in either the sites-package directory or directly in your project directory. The path of the sites-package directory is generally present in the Python path, which can be obtained using the command `python -c "import sys; print(sys.path)"` -Configured for Python3_x64 -Will use an old version of sip without installing it +## Build -dependencies +The scripts can build the Python Bindings for Python versions >=3.5 and will only produce x64 binaries +Don't hesitate to ask me if you need 32 bits support + +### Linux + +1. Install dependencies : +``` +make gcc python3-dev zlib1g-dev libxml2-dev +``` +For example using apt : +``` +sudo apt install make gcc python3-dev zlib1g-dev libxml2-dev ``` -zlib1g-dev -libxml2-dev -make -gcc -python3-pip +2. Run the build script ``` +./build.sh +``` +3. Binaries are outputed to the `fbxsdkpy-cpPYTHONVERSION-gnu_linux_x64` directory. You can follow the Install instructions from step 3 with the files in this directory + +### Windows + +1. Execute the `build.bat` file, or run it as Administrator Right-Click > Run as Administrator to bypass the authorizations requests + +There is no dependencies, installing Visual Studio is not necessary, the script will download and install the needed building tools and remove them once it's done +2. Binaries are outputed to the `fbxsdkpy-cpPYTHONVERSION-win_x64` directory. You can follow the Install instructions from step 3 with the files in this directory diff --git a/build.sh b/build.sh index ff157500f93196cc11fa2154d0d160afabdf092e..df85870c08babc01559c2975d1960b266b22abab 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -x @@ -13,7 +13,7 @@ sipinstalldir="$builddir"/sipinstall wget -nc -i "$scdir"/reqs.txt ls -1 *.tar.gz|while read a;do tar -xvzf "$a" -C "$builddir";done -rm *.tar.gz +rm fbx*.tar.gz [ -d "$fbxsdkdir" ] || mkdir "$fbxsdkdir" printf "yes\nn\n" |"$builddir"/fbx*fbxsdk_linux "$fbxsdkdir" @@ -23,7 +23,7 @@ printf "yes\nn\n" |"$builddir"/fbx*fbxpythonbindings_linux "$fbxpydir" [ -d "$sipinstalldir" ] || mkdir "$sipinstalldir" cd "$sipdir" -python3 "${sipdir}"/configure.py -b "$sipinstalldir" -d "$sipinstalldir" -e "$sipinstalldir" --pyidir="$sipinstalldir" +python3 "${sipdir}"/configure.py -b "$sipinstalldir" -d "$sipinstalldir" -e "$sipinstalldir" --pyidir="$sipinstalldir" --sip-module="fbxsip" make --debug -C"${sipdir}" make install --debug -C"${sipdir}" cd "$origdir" @@ -33,7 +33,10 @@ patch -p0 < patch cp "$scdir/PythonBindings.py" "$fbxpydir" FBXSDK_ROOT="$fbxsdkdir" SIP_ROOT="$sipdir" python3 "$fbxpydir"/PythonBindings.py Python3_x64 -fbxdir="$scdir"/fbx +pyvers=$(python3 --version | cut -d' ' -f2) +pyvers=${pyvers%.*} +pyvers=${pyvers//./} +fbxdir="$scdir"/fbxsdkpy-cp${pyvers}-gnu_linux_x64 [ -d "$fbxdir" ] || mkdir "$fbxdir" cp "$fbxpydir"/build/Distrib/site-packages/fbx/* "$fbxdir" -cp "$sipinstalldir"/sip.so "$fbxdir" +cp "$sipinstalldir"/fbxsip.so "$fbxdir" diff --git a/fbx/FbxCommon.py b/fbx/FbxCommon.py deleted file mode 100644 index a52ef5ba2a1c156ed45f16836f0ba53f9d1abcc5..0000000000000000000000000000000000000000 --- a/fbx/FbxCommon.py +++ /dev/null @@ -1,69 +0,0 @@ -from fbx import * -import sys - -def InitializeSdkObjects(): - # The first thing to do is to create the FBX SDK manager which is the - # object allocator for almost all the classes in the SDK. - lSdkManager = FbxManager.Create() - if not lSdkManager: - sys.exit(0) - - # Create an IOSettings object - ios = FbxIOSettings.Create(lSdkManager, IOSROOT) - lSdkManager.SetIOSettings(ios) - - # Create the entity that will hold the scene. - lScene = FbxScene.Create(lSdkManager, "") - - return (lSdkManager, lScene) - -def SaveScene(pSdkManager, pScene, pFilename, pFileFormat = -1, pEmbedMedia = False): - lExporter = FbxExporter.Create(pSdkManager, "") - if pFileFormat < 0 or pFileFormat >= pSdkManager.GetIOPluginRegistry().GetWriterFormatCount(): - pFileFormat = pSdkManager.GetIOPluginRegistry().GetNativeWriterFormat() - if not pEmbedMedia: - lFormatCount = pSdkManager.GetIOPluginRegistry().GetWriterFormatCount() - for lFormatIndex in range(lFormatCount): - if pSdkManager.GetIOPluginRegistry().WriterIsFBX(lFormatIndex): - lDesc = pSdkManager.GetIOPluginRegistry().GetWriterFormatDescription(lFormatIndex) - if "ascii" in lDesc: - pFileFormat = lFormatIndex - break - - if not pSdkManager.GetIOSettings(): - ios = FbxIOSettings.Create(pSdkManager, IOSROOT) - pSdkManager.SetIOSettings(ios) - - pSdkManager.GetIOSettings().SetBoolProp(EXP_FBX_MATERIAL, True) - pSdkManager.GetIOSettings().SetBoolProp(EXP_FBX_TEXTURE, True) - pSdkManager.GetIOSettings().SetBoolProp(EXP_FBX_EMBEDDED, pEmbedMedia) - pSdkManager.GetIOSettings().SetBoolProp(EXP_FBX_SHAPE, True) - pSdkManager.GetIOSettings().SetBoolProp(EXP_FBX_GOBO, True) - pSdkManager.GetIOSettings().SetBoolProp(EXP_FBX_ANIMATION, True) - pSdkManager.GetIOSettings().SetBoolProp(EXP_FBX_GLOBAL_SETTINGS, True) - - result = lExporter.Initialize(pFilename, pFileFormat, pSdkManager.GetIOSettings()) - if result == True: - result = lExporter.Export(pScene) - - lExporter.Destroy() - return result - -def LoadScene(pSdkManager, pScene, pFileName): - lImporter = FbxImporter.Create(pSdkManager, "") - result = lImporter.Initialize(pFileName, -1, pSdkManager.GetIOSettings()) - if not result: - return False - - if lImporter.IsFBX(): - pSdkManager.GetIOSettings().SetBoolProp(EXP_FBX_MATERIAL, True) - pSdkManager.GetIOSettings().SetBoolProp(EXP_FBX_TEXTURE, True) - pSdkManager.GetIOSettings().SetBoolProp(EXP_FBX_EMBEDDED, True) - pSdkManager.GetIOSettings().SetBoolProp(EXP_FBX_SHAPE, True) - pSdkManager.GetIOSettings().SetBoolProp(EXP_FBX_GOBO, True) - pSdkManager.GetIOSettings().SetBoolProp(EXP_FBX_ANIMATION, True) - pSdkManager.GetIOSettings().SetBoolProp(EXP_FBX_GLOBAL_SETTINGS, True) - - result = lImporter.Import(pScene) - lImporter.Destroy() - return result diff --git a/fbx/fbx.so b/fbx/fbx.so deleted file mode 100644 index b65d1b217dcc164e5a43ae5e3faf4cb12bc3f779..0000000000000000000000000000000000000000 Binary files a/fbx/fbx.so and /dev/null differ diff --git a/fbx/sip.so b/fbx/sip.so deleted file mode 100644 index 84e939f679bcd42ab92130ba9acb179287d8c66b..0000000000000000000000000000000000000000 Binary files a/fbx/sip.so and /dev/null differ