Progress forming the build environment for Python distutils packaging

parent 7889dc7f
......@@ -18,8 +18,9 @@ endif( )
add_definitions( -DPy_NO_ENABLE_SHARED )
# Only add library here to check if it compiles. Use python distutils to actually compile the extension.
add_library( VAPython STATIC "src/vasingleton.cpp" "src/vasingletondoc.hpp" "src/vasingletonmethods.hpp" )
add_library( VAPython STATIC "src/vasingleton.cpp" "src/vasingletondoc.hpp" "src/vasingletonmethods.hpp" "MANIFEST.in" "setup.py" )
target_link_libraries( VAPython ${VISTA_USE_PACKAGE_LIBRARIES} )
......@@ -31,3 +32,17 @@ vista_create_cmake_configs( VAPython )
vista_create_default_info_file( VAPython )
set_property( TARGET VAPython PROPERTY FOLDER "VA/Bindings" )
# install
if( WIN32 )
install( FILES "${VABASE_LIBRARY_DIRS}/VABase.dll" DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/bin" )
install( FILES "${VANET_LIBRARY_DIRS}/VANet.dll" DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/bin" )
foreach( VISTACORELIBS_LIBRARY_DIR ${VISTACORELIBS_LIBRARY_DIRS} )
if( EXISTS "${VISTACORELIBS_LIBRARY_DIR}/VistaBase.dll" )
#message( "${VISTACORELIBS_LIBRARY_DIR}")
install( FILES "${VISTACORELIBS_LIBRARY_DIR}/VistaBase.dll" DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/bin" )
endif( )
# @todo more
endforeach( )
endif( )
include README.md LICENSE.md
include bin *
recursive-include tests *
\ No newline at end of file
......@@ -22,10 +22,24 @@ limitations under the License.
### Quick build guide
#### Visual Studio
Although the CMakeLists creates a Visual Studio project, this project is of no use for Python. It is just for convenience to compile and link the VAPython source code. But it will handle some file copying for distutils, see below. It therefore is necessary to run the `INSTALL` project in order to prepare this.
#### Distutils
Use Pythons *distutils* to build the module that is called `va`. Depending on the version, you will have to install the matching compiler build tools. See the [Python documentation](https://docs.python.org/3.6/library/distutils.html) for more information.
Build VA using CMake with the `ITA_VA_WITH_BINDING_PYTHON` option beforehand. This will prepare some paths in the setup configuration.
It is very important to build and install VA using CMake with the `ITA_VA_WITH_BINDING_PYTHON` option beforehand. This will prepare some paths in the setup configuration and this will also add the required shared libraries into the `bin` folder, where the package distribution command will expect them to be.
`python setup.py build`
`python setup.py install --prefix=dist`
`python setup.py sdist'
Drop the `prefix` argument if you want to integrate the module into your site-packages folder, which might require that you use a command window with administration privileges.
#### Trouble shooting
If you get some errors like `module not found`, this usually refers to missing or incompatible shared libraries that the `va` module is trying to load upon import within the Python interpreter. Make sure the following files are available (i.e. copy them next to the va*.pyc file in the dist/lib/ site-packages folder or into the distribution zip file)
Windows:
`VABase.dll VANet.dll VistaBase.dll VistaAspects.dll VistaInterProcComm.dll`
Other OS: replace `dll` with `so`
python.exe setup.py build --plat-name=win-amd64 --compiler=msvc
python.exe setup.py install --prefix dist
\ No newline at end of file
python.exe setup.py build
python.exe setup.py install --prefix dist
python.exe setup.py sdist --formats=zip
\ No newline at end of file
......@@ -5,7 +5,7 @@ module1 = Extension('va',
include_dirs = ['../VABase/include','../VANet/include'],
libraries = ['VABase', 'VANet', 'VistaBase', 'VistaAspects', 'VistaInterProcComm'],
library_dirs = ['../build_win32-x64.vc14/lib','../../ViSTA/build_win32-x64.vc14/lib'],
sources = ['src/vasingleton.cpp'])
sources = ['src/vasingleton.cpp','src/vasingletonmethods.hpp','src/vasingletondoc.hpp'])
setup (name = 'va',
version = '2017.c',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment