Browse Source

python: *very* little from Trade.

pull/1/head
Vladimír Vondruš 7 years ago
parent
commit
293c5eca64
  1. 3
      doc/python/conf.py
  2. 4
      package/ci/travis-desktop-gles.sh
  3. 4
      package/ci/travis-desktop.sh
  4. 3
      src/python/CMakeLists.txt
  5. 15
      src/python/magnum/CMakeLists.txt
  6. 34
      src/python/magnum/test/test_trade.py
  7. 53
      src/python/magnum/trade.cpp
  8. 1
      src/python/setup.py.cmake

3
doc/python/conf.py

@ -16,10 +16,11 @@ import magnum.platform.glfw
import magnum.platform.sdl2
import magnum.shaders
import magnum.scenegraph
import magnum.trade
# So the doc see everything
# TODO: use just +=, m.css should reorder this on its own
magnum.__all__ = ['math', 'gl', 'platform', 'shaders', 'scenegraph'] + magnum.__all__
magnum.__all__ = ['math', 'gl', 'platform', 'shaders', 'scenegraph', 'trade'] + magnum.__all__
# TODO ugh... can this be expressed directly in pybind?
magnum.gl.__annotations__ = {}

4
package/ci/travis-desktop-gles.sh

@ -11,7 +11,7 @@ cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_DEPRECATED=$BUILD_DEPRECATED \
-DWITH_INTERCONNECT=OFF \
-DWITH_PLUGINMANAGER=OFF \
-DWITH_PLUGINMANAGER=ON \
-DWITH_TESTSUITE=OFF \
-G Ninja
ninja install
@ -40,7 +40,7 @@ cmake .. \
-DWITH_SHADERS=ON \
-DWITH_TEXT=OFF \
-DWITH_TEXTURETOOLS=OFF \
-DWITH_TRADE=OFF \
-DWITH_TRADE=ON \
-DWITH_VK=OFF \
-DWITH_WINDOWLESSEGLAPPLICATION=ON \
-DBUILD_DEPRECATED=OFF \

4
package/ci/travis-desktop.sh

@ -11,7 +11,7 @@ cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_DEPRECATED=$BUILD_DEPRECATED \
-DWITH_INTERCONNECT=OFF \
-DWITH_PLUGINMANAGER=OFF \
-DWITH_PLUGINMANAGER=ON \
-DWITH_TESTSUITE=OFF \
-G Ninja
ninja install
@ -34,7 +34,7 @@ cmake .. \
-DWITH_SHADERS=ON \
-DWITH_TEXT=OFF \
-DWITH_TEXTURETOOLS=OFF \
-DWITH_TRADE=OFF \
-DWITH_TRADE=ON \
-DWITH_VK=OFF \
-DBUILD_DEPRECATED=OFF \
-G Ninja

3
src/python/CMakeLists.txt

@ -46,7 +46,8 @@ foreach(target
magnum_platform_egl
magnum_platform_glx
magnum_platform_glfw
magnum_platform_sdl2)
magnum_platform_sdl2
magnum_trade)
if(TARGET ${target})
set(${target}_file $<TARGET_FILE:${target}>)
endif()

15
src/python/magnum/CMakeLists.txt

@ -24,7 +24,7 @@
#
# *Not* REQUIRED
find_package(Magnum COMPONENTS GL Shaders SceneGraph)
find_package(Magnum COMPONENTS GL Shaders SceneGraph Trade)
set(magnum_SRCS
magnum.cpp
@ -81,6 +81,19 @@ if(Magnum_Shaders_FOUND)
LIBRARY_OUTPUT_DIRECTORY ${output_dir}/magnum)
endif()
if(Magnum_Trade_FOUND)
set(magnum_trade_SRCS
trade.cpp)
pybind11_add_module(magnum_trade ${magnum_trade_SRCS})
target_include_directories(magnum_trade PRIVATE ${PROJECT_SOURCE_DIR}/src/python)
target_link_libraries(magnum_trade PRIVATE Magnum::Trade)
set_target_properties(magnum_trade PROPERTIES
FOLDER "python"
OUTPUT_NAME "trade"
LIBRARY_OUTPUT_DIRECTORY ${output_dir}/magnum)
endif()
file(GENERATE OUTPUT ${output_dir}/magnum/__init__.py
INPUT ${CMAKE_CURRENT_SOURCE_DIR}/__init__.py)

34
src/python/magnum/test/test_trade.py

@ -0,0 +1,34 @@
#
# This file is part of Magnum.
#
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
# Vladimír Vondruš <mosra@centrum.cz>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
import unittest
from magnum import *
from magnum import trade
class MeshData(unittest.TestCase):
def test_init(self):
# Well this doesn't do much but well
a = trade.MeshData2D

53
src/python/magnum/trade.cpp

@ -0,0 +1,53 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <pybind11/pybind11.h>
#include <Magnum/Trade/MeshData2D.h>
#include <Magnum/Trade/MeshData3D.h>
#include "magnum/bootstrap.h"
namespace magnum { namespace {
template<class T> void meshData(py::class_<T>& c) {
c
.def_property_readonly("primitive", &T::primitive, "Primitive")
.def("is_indexed", &T::isIndexed, "Whether the mesh is indexed");
}
void trade(py::module& m) {
py::class_<Trade::MeshData2D> meshData2D{m, "MeshData2D", "Two-dimensional mesh data"};
py::class_<Trade::MeshData3D> meshData3D{m, "MeshData3D", "Three-dimensional mesh data"};
meshData(meshData2D);
meshData(meshData3D);
}
}}
PYBIND11_MODULE(trade, m) {
m.doc() = "Data format exchange";
magnum::trade(m);
}

1
src/python/setup.py.cmake

@ -40,6 +40,7 @@ extension_paths = {
'magnum.platform.glx': '${magnum_platform_glx_file}',
'magnum.platform.glfw': '${magnum_platform_glfw_file}',
'magnum.platform.sdl2': '${magnum_platform_sdl2_file}',
'magnum.trade': '${magnum_trade_file}',
}
class TheExtensionIsAlreadyBuiltWhyThisHasToBeSoDamnComplicated(build_ext):

Loading…
Cancel
Save