Skip to content

Commit

Permalink
Merge pull request #209 from naivisoftware/disable_python
Browse files Browse the repository at this point in the history
Deprecate & Disable Python Integration
  • Loading branch information
cklosters authored Jul 22, 2022
2 parents 0925908 + f2192fb commit 026a993
Show file tree
Hide file tree
Showing 30 changed files with 175 additions and 87 deletions.
20 changes: 16 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,26 @@ elseif(UNIX)
endif()
endif()

# We don't actively support and work on macOS anymore.
# This is not because we don't like their hardware, but because of the continuous tightening of restrictions of macOS,
# Including aggressive gate-keeping, required app singing, forcing specific data structures, vague licence policies,
# proprietary APIs, etc. It's simply not in line with our policies and what we stand for.
# Feel free to continue support for macOS on your end.
if(APPLE)
message(DEPRECATION "macOS (as a target) is no longer in active development or supported")
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15)
endif()

# enable python
set(NAP_ENABLE_PYTHON 1)
add_definitions(-DNAP_ENABLE_PYTHON)
# We don't actively support and work on python bindings anymore.
if(NAP_ENABLE_PYTHON)
message(DEPRECATION "Python bindings are no longer in active development or supported")
add_definitions(-DNAP_ENABLE_PYTHON)
endif()

# Automatically link Qt executables to qtmain target on Windows.
cmake_policy(SET CMP0020 NEW)

# Ignore COMPILE_DEFINITIONS
cmake_policy(SET CMP0043 NEW)

# Restrict to debug and release build types
Expand Down Expand Up @@ -128,7 +140,6 @@ add_subdirectory(demos/curveball)
add_subdirectory(demos/curveball/module)
add_subdirectory(demos/copystamp)
add_subdirectory(demos/copystamp/module)
add_subdirectory(demos/python)
add_subdirectory(demos/websocketserver)
add_subdirectory(demos/websocketserver/module)
add_subdirectory(demos/facedetection)
Expand All @@ -142,6 +153,7 @@ add_subdirectory(demos/artnetreceive)
add_subdirectory(demos/artnetreceive/module)
add_subdirectory(demos/pipins)
add_subdirectory(demos/webportal)
add_subdirectory(demos/python)

if(APPLE)
set(GENERATE_XCODE_PROJECT_TARGET generateXcodeProject)
Expand Down
14 changes: 8 additions & 6 deletions build_tools/generate_solution/generate_solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
CODEBLOCKS_BUILD_DIR = 'codeblocks'
DEFAULT_LINUX_BUILD_TYPE = 'Release'

def generate(forced_path, additional_dirs, linux_build_type):
def generate(forced_path, enable_python, additional_dirs, linux_build_type):
nap_root = get_nap_root()
cmake = get_cmake_path()

if platform.startswith('linux'):
build_dir = forced_path if forced_path else os.path.join(nap_root, LINUX_BUILD_DIR)
build_type = linux_build_type.lower().capitalize()
call(['%s -H%s -B%s -DCMAKE_BUILD_TYPE=%s -DADDITIONAL_SUB_DIRECTORIES=%s' % (cmake, nap_root, build_dir, build_type, additional_dirs)], shell=True)
call(['%s -H%s -B%s -DCMAKE_BUILD_TYPE=%s -DNAP_ENABLE_PYTHON=%s -DADDITIONAL_SUB_DIRECTORIES=%s' % (cmake, nap_root, build_dir, build_type, enable_python, additional_dirs)], shell=True)
elif platform == 'darwin':
build_dir = forced_path if forced_path else os.path.join(nap_root, MACOS_BUILD_DIR)
call(['%s -H%s -B%s -G Xcode -DADDITIONAL_SUB_DIRECTORIES=%s' % (cmake, nap_root, build_dir, additional_dirs)], shell=True)
call(['%s -H%s -B%s -G Xcode -DNAP_ENABLE_PYTHON=%s -DADDITIONAL_SUB_DIRECTORIES=%s' % (cmake, nap_root, build_dir, enable_python, additional_dirs)], shell=True)
else:
build_dir = forced_path if forced_path else os.path.join(nap_root, MSVC_BUILD_DIR)
cmd = '%s -H%s -B%s -G "Visual Studio 16 2019" -DPYBIND11_PYTHON_VERSION=3.5 -DADDITIONAL_SUB_DIRECTORIES=%s' % (cmake, nap_root, build_dir, additional_dirs)
cmd = '%s -H%s -B%s -G "Visual Studio 16 2019" -DNAP_ENABLE_PYTHON=%s -DADDITIONAL_SUB_DIRECTORIES=%s' % (cmake, nap_root, build_dir, enable_python, additional_dirs)
call(cmd, shell=True)

def get_cmake_path():
Expand Down Expand Up @@ -67,13 +67,15 @@ def get_nap_root():
choices=['release', 'debug'],
help="Linux build type (default: %s)" % DEFAULT_LINUX_BUILD_TYPE.lower())

parser.add_argument('-p', '--enable-python', action="store_true",
help="Enable python integration using pybind (deprecated)")

parser.add_argument('-d', '--additional-dirs',
nargs='+',
type=str,
default=[],
help="List of additional sub directories to add to the build")

# Parse command line arguments
args = parser.parse_args()

# Convert additional sub directories to CMAKE list type
Expand All @@ -83,4 +85,4 @@ def get_nap_root():
linux_build_type = args.linux_build_type if platform.startswith('linux') else None

# Generate solution
generate(args.build_path, additional_dirs, linux_build_type)
generate(args.build_path, int(args.enable_python), additional_dirs, linux_build_type)
35 changes: 22 additions & 13 deletions build_tools/package/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ def package(zip_release,
archive_source_zipped,
archive_source_only,
overwrite,
additional_dirs):
additional_dirs,
enable_python):

"""Package a NAP platform release - main entry point"""
nap_root = get_nap_root()
Expand Down Expand Up @@ -122,7 +123,8 @@ def package(zip_release,
zip_release,
include_debug_symbols,
build_projects,
sub_dirs
sub_dirs,
enable_python
)
elif platform == 'darwin':
package_path = package_for_macos(package_basename,
Expand All @@ -136,7 +138,8 @@ def package(zip_release,
zip_release,
include_debug_symbols,
build_projects,
sub_dirs
sub_dirs,
enable_python
)
else:
package_path = package_for_win64(package_basename,
Expand All @@ -150,7 +153,8 @@ def package(zip_release,
zip_release,
include_debug_symbols,
build_projects,
sub_dirs
sub_dirs,
enable_python
)

# Archive source
Expand Down Expand Up @@ -213,7 +217,7 @@ def check_for_existing_package(package_path, zip_release, remove=False):
sys.exit(ERROR_PACKAGE_EXISTS)


def package_for_linux(package_basename, timestamp, git_revision, build_label, overwrite, include_apps, single_app_to_include, include_docs, zip_release, include_debug_symbols, build_projects, additional_dirs):
def package_for_linux(package_basename, timestamp, git_revision, build_label, overwrite, include_apps, single_app_to_include, include_docs, zip_release, include_debug_symbols, build_projects, additional_dirs, enable_python):
"""Package NAP platform release for Linux"""

for build_type in BUILD_TYPES:
Expand All @@ -230,7 +234,8 @@ def package_for_linux(package_basename, timestamp, git_revision, build_label, ov
'-DBUILD_LABEL=%s' % build_label,
'-DINCLUDE_DEBUG_SYMBOLS=%s' % int(include_debug_symbols),
'-DBUILD_PROJECTS=%s' % int(build_projects),
'-DADDITIONAL_SUB_DIRECTORIES=%s' % additional_dirs
'-DADDITIONAL_SUB_DIRECTORIES=%s' % additional_dirs,
'-DNAP_ENABLE_PYTHON=%s' % int(enable_python)
])

d = '%s/%s' % (WORKING_DIR, build_dir_for_type)
Expand All @@ -250,7 +255,7 @@ def package_for_linux(package_basename, timestamp, git_revision, build_label, ov
else:
return archive_to_timestamped_dir(package_basename)

def package_for_macos(package_basename, timestamp, git_revision, build_label, overwrite, include_apps, single_app_to_include, include_docs, zip_release, include_debug_symbols, build_projects, additional_dirs):
def package_for_macos(package_basename, timestamp, git_revision, build_label, overwrite, include_apps, single_app_to_include, include_docs, zip_release, include_debug_symbols, build_projects, additional_dirs, enable_python):
"""Package NAP platform release for macOS"""

# Generate project
Expand All @@ -266,7 +271,8 @@ def package_for_macos(package_basename, timestamp, git_revision, build_label, ov
'-DBUILD_LABEL=%s' % build_label,
'-DINCLUDE_DEBUG_SYMBOLS=%s' % int(include_debug_symbols),
'-DBUILD_PROJECTS=%s' % int(build_projects),
'-DADDITIONAL_SUB_DIRECTORIES=%s' % additional_dirs
'-DADDITIONAL_SUB_DIRECTORIES=%s' % additional_dirs,
'-DNAP_ENABLE_PYTHON=%s' % int(enable_python)
])

# Build & install to packaging dir
Expand All @@ -291,7 +297,7 @@ def package_for_macos(package_basename, timestamp, git_revision, build_label, ov
else:
return archive_to_timestamped_dir(package_basename)

def package_for_win64(package_basename, timestamp, git_revision, build_label, overwrite, include_apps, single_app_to_include, include_docs, zip_release, include_debug_symbols, build_projects, additional_dirs):
def package_for_win64(package_basename, timestamp, git_revision, build_label, overwrite, include_apps, single_app_to_include, include_docs, zip_release, include_debug_symbols, build_projects, additional_dirs, enable_python):
"""Package NAP platform release for Windows"""

# Create build dir if it doesn't exist
Expand All @@ -304,15 +310,15 @@ def package_for_win64(package_basename, timestamp, git_revision, build_label, ov
'-B%s' % BUILD_DIR,
'-G', 'Visual Studio 16 2019',
'-DNAP_PACKAGED_BUILD=1',
'-DPYBIND11_PYTHON_VERSION=3.5',
'-DINCLUDE_DOCS=%s' % int(include_docs),
'-DPACKAGE_NAIVI_APPS=%s' % int(include_apps),
'-DBUILD_TIMESTAMP=%s' % timestamp,
'-DBUILD_GIT_REVISION=%s' % git_revision,
'-DBUILD_LABEL=%s' % build_label,
'-DINCLUDE_DEBUG_SYMBOLS=%s' % int(include_debug_symbols),
'-DBUILD_PROJECTS=%s' % int(build_projects),
'-DADDITIONAL_SUB_DIRECTORIES=%s' % additional_dirs
'-DADDITIONAL_SUB_DIRECTORIES=%s' % additional_dirs,
'-DNAP_ENABLE_PYTHON=%s' % int(enable_python)
])

# Build & install to packaging dir
Expand Down Expand Up @@ -682,11 +688,13 @@ def get_cmake_path():
core_group.add_argument("-ds", "--include-debug-symbols", action="store_true",
help="Include debug symbols")
core_group.add_argument("-o", "--overwrite", action="store_true",
help="Overwrite any existing framework or source package")
help="Overwrite any existing framework or source package")
core_group.add_argument("-c", "--clean", action="store_true",
help="Clean build")
core_group.add_argument("--build-projects", action="store_true",
help="Build projects while packaging (not included in package)")
core_group.add_argument('-p', '--enable-python', action="store_true",
help="Enable python integration using pybind (deprecated)")

source_archive_group = parser.add_argument_group('Source Archiving')
source_archive_group.add_argument("-as", "--archive-source", action="store_true",
Expand Down Expand Up @@ -755,4 +763,5 @@ def get_cmake_path():
args.source_archive_zipped,
args.source_archive_only,
args.overwrite,
args.additional_dirs)
args.additional_dirs,
args.enable_python)
22 changes: 16 additions & 6 deletions build_tools/source_cli_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get_nap_root():
script_to_nap_root = os.path.join(os.pardir, os.pardir)
return os.path.abspath(os.path.join(os.path.dirname(script_path), script_to_nap_root))

def main(target, clean_build, build_type):
def main(target, clean_build, build_type, enable_python):
build_dir = None
if platform.startswith('linux'):
build_dir = LINUX_BUILD_DIR
Expand All @@ -60,13 +60,21 @@ def main(target, clean_build, build_type):
if clean_build and os.path.exists(build_dir):
shutil.rmtree(build_dir)

# Generate solution
# Get arguments to generate solution
solution_args = []
if platform.startswith('linux'):
rc = call(nap_root, ['./generate_solution.sh', '--build-path=%s' % build_dir, '-t', build_type.lower()])
solution_args = ['./generate_solution.sh', '--build-path=%s' % build_dir, '-t', build_type.lower()]
elif platform == 'darwin':
rc = call(nap_root, ['./generate_solution.sh', '--build-path=%s' % build_dir])
solution_args = ['./generate_solution.sh', '--build-path=%s' % build_dir]
else:
rc = call(nap_root, ['generate_solution.bat', '--build-path=%s' % build_dir])
solution_args = ['generate_solution.bat', '--build-path=%s' % build_dir]

# Enable python if requested
if enable_python:
solution_args.append('-p')

# Generate solution
rc = call(nap_root, solution_args)

# Build
build_config = build_type.capitalize()
Expand All @@ -88,10 +96,12 @@ def main(target, clean_build, build_type):
parser.add_argument('-t', '--build-type', type=str.lower, default=DEFAULT_BUILD_TYPE,
choices=['release', 'debug'], help="Build configuration (default=%s)" % DEFAULT_BUILD_TYPE.lower())
parser.add_argument('-c', '--clean', default=False, action="store_true", help="Clean before build")
parser.add_argument('-p', '--enable-python', action="store_true", help="Enable python integration using pybind (deprecated)")

args = parser.parse_args()

print("Project to build: {0}, clean: {1}, type: {2}".format(
args.PROJECT_NAME, args.clean, args.build_type))

# Run main
main(args.PROJECT_NAME, args.clean, args.build_type)
main(args.PROJECT_NAME, args.clean, args.build_type, args.enable_python)
14 changes: 7 additions & 7 deletions cmake/packaging_macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ macro(package_nap)
install(CODE "FILE(MAKE_DIRECTORY \${ENV}\${CMAKE_INSTALL_PREFIX}/user_modules)")

# Package thirdparty Python into release
if (NAP_ENABLE_PYTHON)
package_python()
endif ()
package_python()

# Package documentation
if(INCLUDE_DOCS)
Expand Down Expand Up @@ -140,11 +138,13 @@ macro(package_python)
CONFIGURATIONS Release)

# Install framework for Napkin
install(FILES ${THIRDPARTY_DIR}/python/msvc/x86_64/python36.zip
DESTINATION tools/napkin/
CONFIGURATIONS Release)
if(NAP_ENABLE_PYTHON)
install(FILES ${THIRDPARTY_DIR}/python/msvc/x86_64/python36.zip
DESTINATION tools/napkin/
CONFIGURATIONS Release)
endif()

# Install license
# Install license
install(FILES ${THIRDPARTY_DIR}/python/msvc/LICENSE.txt
DESTINATION thirdparty/python/
CONFIGURATIONS Release)
Expand Down
1 change: 1 addition & 0 deletions core/src/nap/linux/directorywatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <utility/fileutils.h>
#include <unistd.h>
#include <linux/limits.h>
#include <assert.h>

namespace nap
{
Expand Down
1 change: 1 addition & 0 deletions core/src/nap/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "logger.h"
#include <iostream>
#include <utility/fileutils.h>
#include <assert.h>

namespace nap
{
Expand Down
4 changes: 3 additions & 1 deletion core/src/nap/python.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

#pragma once

#ifdef NAP_ENABLE_PYTHON
#include <rtti/pythonmodule.h>
#include <rtti/pythonmodule.h>
#endif
34 changes: 17 additions & 17 deletions demos/helloworld/src/helloworldapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,10 @@ namespace nap
*/
void HelloWorldApp::update(double deltaTime)
{
// The default input router forwards messages to key and mouse input components
// attached to a set of entities.
// Create an input router, the default one forwards messages to mouse and keyboard input components
nap::DefaultInputRouter input_router;

// Forward all input events associated with the first window to the listening components
// Now forward all input events associated with the first window to the listening components
std::vector<nap::EntityInstance*> entities = { mPerspectiveCamEntity.get() };
mInputService->processWindowEvents(*mRenderWindow, input_router, entities);

Expand Down Expand Up @@ -104,8 +103,19 @@ namespace nap
}
ImGui::End();

// push camera location to the world shader for the halo effect
// To do that we fetch the material associated with the world mesh and query the camera location uniform
// Push text color
auto& text_comp = mTextEntity->getComponent<Renderable2DTextComponentInstance>();
text_comp.setColor(mTextColor);
}


/**
* Renders the world and text.
*/
void HelloWorldApp::render()
{
// Now we know the final camera position, we can push it to the world shader for the computation of the halo effect.
// To do that we fetch the material associated with the world mesh and query the camera location uniform.
// Once we have the uniform we can set it to the camera world space location
nap::RenderableMeshComponentInstance& render_mesh = mWorldEntity->getComponent<nap::RenderableMeshComponentInstance>();
auto ubo = render_mesh.getMaterialInstance().getOrCreateUniform("UBO");
Expand All @@ -116,22 +126,12 @@ namespace nap
glm::vec3 global_pos = math::extractPosition(cam_xform.getGlobalTransform());
cam_loc_uniform->setValue(global_pos);

// Now push sphere colors
// Push the colors.
// Note that it is also possible to set shader variables on update().
ubo->getOrCreateUniform<nap::UniformVec3Instance>("colorOne")->setValue(mColorOne);
ubo->getOrCreateUniform<nap::UniformVec3Instance>("colorTwo")->setValue(mColorTwo);
ubo->getOrCreateUniform<nap::UniformVec3Instance>("haloColor")->setValue(mHaloColor);

// Push text color
auto& text_comp = mTextEntity->getComponent<Renderable2DTextComponentInstance>();
text_comp.setColor(mTextColor);
}


/**
* Renders the world and text.
*/
void HelloWorldApp::render()
{
// Signal the beginning of a new frame, allowing it to be recorded.
// The system might wait until all commands that were previously associated with the new frame have been processed on the GPU.
// Multiple frames are in flight at the same time, but if the graphics load is heavy the system might wait here to ensure resources are available.
Expand Down
7 changes: 6 additions & 1 deletion demos/python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
cmake_minimum_required(VERSION 3.18.4)
if(NOT NAP_ENABLE_PYTHON)
return()
endif()

# Python demo
project(python)

#add all cpp files to SOURCES
# Add all cpp files to SOURCES
file(GLOB SOURCES src/*.cpp)
file(GLOB HEADERS src/*.h)
file(GLOB DATA data/*)
Expand Down
Loading

0 comments on commit 026a993

Please sign in to comment.