diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 7165c9813..4c7470ff5 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -30,12 +30,9 @@ jobs: sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10 - name: Install dependencies run: | - cd extern/ - bash ./download.sh - cd ../ conda env create --name build-env --file environment.yml conda activate build-env - python setup.py develop + pip install . shell: bash -l {0} - name: Build documentation run: | diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 1d116c448..72c7a87b6 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -32,9 +32,6 @@ jobs: sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10 - name: Install dependencies run: | - cd extern/ - bash ./download.sh - cd ../ conda env create --name ci-env --file environment.yml shell: bash -l {0} - name: Print debugging information @@ -45,7 +42,7 @@ jobs: - name: Install catkit2 run: | conda activate ci-env - python setup.py develop + pip install -v -e . shell: bash -l {0} - name: Run tests run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index 837b3fc5d..44bbe65e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.21) project(catkit2) @@ -13,6 +13,4 @@ list(APPEND CMAKE_INSTALL_RPATH $ENV{CONDA_PREFIX}/lib) list(APPEND CMAKE_PREFIX_PATH "$ENV{CONDA_PREFIX}") list(APPEND CMAKE_PREFIX_PATH "$ENV{CONDA_PREFIX}/Library") -add_subdirectory(catkit_core) -add_subdirectory(catkit_bindings) -add_subdirectory(benchmarks) +add_subdirectory(catkit2) diff --git a/README.md b/README.md index 949b12680..ce197e20d 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ The Control and Automation for Testbeds Kit 2 (CATKit2) --------------------- -CATKit2 is a toolkit for hardware controls that has been developed at the Space Telescope Science Institute. -It provides a general infrastructure to control hardware and synchronize devices. +CATKit2 is a toolkit for hardware controls that has been developed at the Space Telescope Science Institute. +It provides a general infrastructure to control hardware and synchronize devices. -This package was developed for use on the High-contrast Imager for Complex Apertures Testbed (HiCAT) for +This package was developed for use on the High-contrast Imager for Complex Apertures Testbed (HiCAT) for developing technologies relevant to direct imaging of exoplanets in astronomy in the laboratory. This is an open-source package, but it is not actively supported. Use at your own risk. @@ -66,27 +66,19 @@ Installation This procedure requires a pre-installed C++ compiler. - On Windows, you can for example install the Visual Studio Compiler, either by installing the Build Tools, or by installing the full IDE with compiler (the community edition is free). -- On MacOS, nothing should be needed, but some machines require Xcode to be installed. It does install components on first startup, so it is recommended to start XCode on your mac if you have never used it (and accept the license agreement of XCode, which is required). -- XCode 15 (Sonoma and higher) introduced some changes in the compiler location, which require the following environment variable update: +- On MacOS, nothing should be needed, but some machines require Xcode to be installed. It does install components on first startup, so it is recommended to start XCode on your mac if you have never used it (and accept the license agreement of XCode, which is required). +- XCode 15 (Sonoma and higher) introduced some changes in the compiler location, which require the following environment variable update: ``` export SDKROOT=$(xcrun --sdk macosx --show-sdk-path) ``` -The following will download all third-party C++ dependencies and create a new Conda environment with the required Python packages. The download can be performed on a separate machine with internet connectivity and the resulting folders can be copy-pasted in the extern folder on the machine without internet connectivity. +The following will create a new Conda environment with the required C++ and Python packages. You will need to install drivers and SDKs for some devices yourself to use those devices. -You will need to install drivers and SDKs for some devices yourself to use those devices. - -``` -cd catkit2 -cd extern -./download.sh -cd .. -``` For installation on Apple Silicon with python=3.7, you need to follow these steps: ``` -conda create --name catkit2 -conda activate catkit2 -conda config --env --set subdir osx-64 +conda create --name catkit2 +conda activate catkit2 +conda config --env --set subdir osx-64 conda env update --file environment.yml ``` @@ -96,8 +88,8 @@ conda env create --file environment.yml conda activate catkit2 ``` -Finally install the package using: +Finally install the package using: ``` python setup.py develop cd .. -``` \ No newline at end of file +``` diff --git a/catkit2-core/CMakeLists.txt b/catkit2-core/CMakeLists.txt new file mode 100644 index 000000000..79ca9f5f7 --- /dev/null +++ b/catkit2-core/CMakeLists.txt @@ -0,0 +1,120 @@ +cmake_minimum_required(VERSION 3.21) + +project(catkit_core) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED on) + +if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) + message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there. You may need to remove CMakeCache.txt.") +endif() + +add_compile_options($<$:/MP1>) + +file(GLOB_RECURSE SOURCES "./src/*.cpp") +file(GLOB_RECURSE HEADERS "./src/*.h") + +add_library(catkit_core STATIC) +target_sources(catkit_core PRIVATE "${SOURCES}") +target_include_directories( + catkit_core + INTERFACE + $ + $ +) + +set_property(TARGET catkit_core PROPERTY POSITION_INDEPENDENT_CODE ON) +target_compile_definitions(catkit_core PUBLIC PROTOBUF_USE_DLLS) + +if (MSVC) + # disable warning: 'identifier': class 'type' needs to have dll-interface to be used by clients of class 'type2' + target_compile_options(catkit_core PUBLIC /wd4251) +endif() + +# Link ZeroMQ +find_package(ZeroMQ REQUIRED) +target_include_directories(catkit_core PUBLIC ${ZeroMQ_INCLUDE_DIR}) +target_link_libraries(catkit_core PUBLIC libzmq) +if (WIN32) + target_link_libraries(catkit_core PUBLIC wsock32 ws2_32 Iphlpapi) +else() + target_link_libraries(catkit_core PUBLIC pthread) + if (NOT APPLE) + target_link_libraries(catkit_core PUBLIC rt) + endif (NOT APPLE) +endif (WIN32) + +# Add includes for cppzmq +find_package(cppzmq REQUIRED) +target_include_directories(catkit_core PUBLIC ${cppzmq_INCLUDE_DIR}) + +# Link Eigen +find_package(Eigen3 REQUIRED NO_MODULE) +target_link_libraries (catkit_core PUBLIC Eigen3::Eigen) + +# Link nlohmann JSON +find_package(nlohmann_json) +target_include_directories(catkit_core PRIVATE ${nlohmann_json_INCLUDE_DIR}) + +# Link protobuf +INCLUDE(FindProtobuf) +find_package(Protobuf REQUIRED) +target_include_directories(catkit_core PUBLIC ${PROTOBUF_INCLUDE_DIR}) +target_link_libraries(catkit_core PUBLIC ${PROTOBUF_LIBRARY}) + +set(PROTO_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/gen/") +set(PROTO_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/proto/") +file(GLOB_RECURSE PROTO_SOURCES "${PROTO_SOURCE_DIR}/*.proto") +file(MAKE_DIRECTORY "${PROTO_BINARY_DIR}") +protobuf_generate( + TARGET catkit_core + IMPORT_DIRS "${PROTO_SOURCE_DIR}" + PROTOC_OUT_DIR "${PROTO_BINARY_DIR}" + PROTOS ${PROTO_SOURCES} +) +target_include_directories(catkit_core PUBLIC "$") +# Generate and install CatkitCoreConfig.cmake +include(CMakePackageConfigHelpers) + +configure_package_config_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/CatkitCoreConfig.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/CatkitCoreConfig.cmake" + INSTALL_DESTINATION lib/cmake/catkit_core +) + +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/CatkitCoreConfig.cmake" + DESTINATION "lib/cmake/catkit_core" +) + +install( + TARGETS catkit_core + EXPORT CatkitCoreTargets + LIBRARY DESTINATION lib +) + +# Generate and install CatkitCoreTargets.cmake +install( + EXPORT CatkitCoreTargets + FILE CatkitCoreTargets.cmake + DESTINATION "lib/cmake/catkit_core" +) + +install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src/" + DESTINATION include/catkit_core + FILES_MATCHING + PATTERN "*.h" + PATTERN "*.inl" +) +install(DIRECTORY "${PROTO_BINARY_DIR}" + DESTINATION include/catkit_core + FILES_MATCHING + PATTERN "*.h" +) +install(DIRECTORY "${PROTO_SOURCE_DIR}" + DESTINATION include/catkit_core/proto + FILES_MATCHING + PATTERN "*.proto" +) + +add_subdirectory(benchmarks) diff --git a/benchmarks/CMakeLists.txt b/catkit2-core/benchmarks/CMakeLists.txt similarity index 77% rename from benchmarks/CMakeLists.txt rename to catkit2-core/benchmarks/CMakeLists.txt index a76ebf1e7..2bc1e1b39 100644 --- a/benchmarks/CMakeLists.txt +++ b/catkit2-core/benchmarks/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.21) project(catkit2) @@ -11,32 +11,26 @@ endif() # DataStream latency benchmark add_executable(datastream_latency datastream_latency.cpp) -target_include_directories(datastream_latency PUBLIC ../catkit_core) target_link_libraries(datastream_latency PUBLIC catkit_core) # Datastream submit benchmark add_executable(datastream_submit datastream_submit.cpp) -target_include_directories(datastream_submit PUBLIC ../catkit_core) target_link_libraries(datastream_submit PUBLIC catkit_core) # Timestamp benchmark add_executable(timestamp timestamp.cpp) -target_include_directories(timestamp PUBLIC ../catkit_core) target_link_libraries(timestamp PUBLIC catkit_core) # Free list allocator benchmark add_executable(free_list_allocator free_list_allocator.cpp) -target_include_directories(free_list_allocator PUBLIC ../catkit_core) target_link_libraries(free_list_allocator PUBLIC catkit_core) # Pool allocator benchmark add_executable(pool_allocator pool_allocator.cpp) -target_include_directories(pool_allocator PUBLIC ../catkit_core) target_link_libraries(pool_allocator PUBLIC catkit_core) # Hash map benchmark add_executable(hash_map hash_map.cpp) -target_include_directories(hash_map PUBLIC ../catkit_core) target_link_libraries(hash_map PUBLIC catkit_core) # Add install files diff --git a/benchmarks/datastream_latency.cpp b/catkit2-core/benchmarks/datastream_latency.cpp similarity index 100% rename from benchmarks/datastream_latency.cpp rename to catkit2-core/benchmarks/datastream_latency.cpp diff --git a/benchmarks/datastream_submit.cpp b/catkit2-core/benchmarks/datastream_submit.cpp similarity index 100% rename from benchmarks/datastream_submit.cpp rename to catkit2-core/benchmarks/datastream_submit.cpp diff --git a/benchmarks/free_list_allocator.cpp b/catkit2-core/benchmarks/free_list_allocator.cpp similarity index 100% rename from benchmarks/free_list_allocator.cpp rename to catkit2-core/benchmarks/free_list_allocator.cpp diff --git a/benchmarks/hash_map.cpp b/catkit2-core/benchmarks/hash_map.cpp similarity index 100% rename from benchmarks/hash_map.cpp rename to catkit2-core/benchmarks/hash_map.cpp diff --git a/benchmarks/latency_histogram.py b/catkit2-core/benchmarks/latency_histogram.py similarity index 100% rename from benchmarks/latency_histogram.py rename to catkit2-core/benchmarks/latency_histogram.py diff --git a/benchmarks/pool_allocator.cpp b/catkit2-core/benchmarks/pool_allocator.cpp similarity index 100% rename from benchmarks/pool_allocator.cpp rename to catkit2-core/benchmarks/pool_allocator.cpp diff --git a/benchmarks/timestamp.cpp b/catkit2-core/benchmarks/timestamp.cpp similarity index 100% rename from benchmarks/timestamp.cpp rename to catkit2-core/benchmarks/timestamp.cpp diff --git a/catkit2-core/cmake/CatkitCoreConfig.cmake.in b/catkit2-core/cmake/CatkitCoreConfig.cmake.in new file mode 100644 index 000000000..3f3e1e380 --- /dev/null +++ b/catkit2-core/cmake/CatkitCoreConfig.cmake.in @@ -0,0 +1,2 @@ +@PACKAGE_INIT@ +include("${CMAKE_CURRENT_LIST_DIR}/CatkitCoreTargets.cmake") diff --git a/proto/core.proto b/catkit2-core/proto/core.proto similarity index 100% rename from proto/core.proto rename to catkit2-core/proto/core.proto diff --git a/proto/logging.proto b/catkit2-core/proto/logging.proto similarity index 100% rename from proto/logging.proto rename to catkit2-core/proto/logging.proto diff --git a/proto/service.proto b/catkit2-core/proto/service.proto similarity index 100% rename from proto/service.proto rename to catkit2-core/proto/service.proto diff --git a/proto/testbed.proto b/catkit2-core/proto/testbed.proto similarity index 100% rename from proto/testbed.proto rename to catkit2-core/proto/testbed.proto diff --git a/proto/tracing.proto b/catkit2-core/proto/tracing.proto similarity index 100% rename from proto/tracing.proto rename to catkit2-core/proto/tracing.proto diff --git a/catkit2-core/recipe/bld.bat b/catkit2-core/recipe/bld.bat new file mode 100644 index 000000000..0d26b3cec --- /dev/null +++ b/catkit2-core/recipe/bld.bat @@ -0,0 +1,6 @@ +mkdir build +cd build + +cmake .. -A x64 +cmake --build . --config Release +cmake --install . --prefix %PREFIX% diff --git a/catkit2-core/recipe/build.sh b/catkit2-core/recipe/build.sh new file mode 100644 index 000000000..efb04c17a --- /dev/null +++ b/catkit2-core/recipe/build.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +mkdir -p build +cd build + +cmake .. -DCMAKE_BUILD_TYPE=Release +cmake --build . --config Release -v +cmake --install . --prefix=$PREFIX diff --git a/catkit2-core/recipe/meta.yaml b/catkit2-core/recipe/meta.yaml new file mode 100644 index 000000000..3f3674562 --- /dev/null +++ b/catkit2-core/recipe/meta.yaml @@ -0,0 +1,21 @@ +package: + name: catkit2-core + version: "0.0.1" + +source: + path: ../ + +build: + number: 0 + +requirements: + build: + - cmake + - make + - {{ compiler('cxx') }} + - cppzmq=4.8.1 + - eigen=3.4.0 + - nlohmann_json=3.9.1 + host: + - zeromq>=4.0.0 + - libprotobuf diff --git a/catkit_core/Client.cpp b/catkit2-core/src/Client.cpp similarity index 100% rename from catkit_core/Client.cpp rename to catkit2-core/src/Client.cpp diff --git a/catkit_core/Client.h b/catkit2-core/src/Client.h similarity index 100% rename from catkit_core/Client.h rename to catkit2-core/src/Client.h diff --git a/catkit_core/Command.cpp b/catkit2-core/src/Command.cpp similarity index 100% rename from catkit_core/Command.cpp rename to catkit2-core/src/Command.cpp diff --git a/catkit_core/Command.h b/catkit2-core/src/Command.h similarity index 100% rename from catkit_core/Command.h rename to catkit2-core/src/Command.h diff --git a/catkit_core/ComplexTraits.h b/catkit2-core/src/ComplexTraits.h similarity index 100% rename from catkit_core/ComplexTraits.h rename to catkit2-core/src/ComplexTraits.h diff --git a/catkit_core/DataStream.cpp b/catkit2-core/src/DataStream.cpp similarity index 100% rename from catkit_core/DataStream.cpp rename to catkit2-core/src/DataStream.cpp diff --git a/catkit_core/DataStream.h b/catkit2-core/src/DataStream.h similarity index 100% rename from catkit_core/DataStream.h rename to catkit2-core/src/DataStream.h diff --git a/catkit_core/Finally.h b/catkit2-core/src/Finally.h similarity index 100% rename from catkit_core/Finally.h rename to catkit2-core/src/Finally.h diff --git a/catkit_core/FreeListAllocator.cpp b/catkit2-core/src/FreeListAllocator.cpp similarity index 100% rename from catkit_core/FreeListAllocator.cpp rename to catkit2-core/src/FreeListAllocator.cpp diff --git a/catkit_core/FreeListAllocator.h b/catkit2-core/src/FreeListAllocator.h similarity index 100% rename from catkit_core/FreeListAllocator.h rename to catkit2-core/src/FreeListAllocator.h diff --git a/catkit_core/HashMap.h b/catkit2-core/src/HashMap.h similarity index 100% rename from catkit_core/HashMap.h rename to catkit2-core/src/HashMap.h diff --git a/catkit_core/HostName.cpp b/catkit2-core/src/HostName.cpp similarity index 100% rename from catkit_core/HostName.cpp rename to catkit2-core/src/HostName.cpp diff --git a/catkit_core/HostName.h b/catkit2-core/src/HostName.h similarity index 100% rename from catkit_core/HostName.h rename to catkit2-core/src/HostName.h diff --git a/catkit_core/Log.cpp b/catkit2-core/src/Log.cpp similarity index 100% rename from catkit_core/Log.cpp rename to catkit2-core/src/Log.cpp diff --git a/catkit_core/Log.h b/catkit2-core/src/Log.h similarity index 100% rename from catkit_core/Log.h rename to catkit2-core/src/Log.h diff --git a/catkit_core/LogConsole.cpp b/catkit2-core/src/LogConsole.cpp similarity index 100% rename from catkit_core/LogConsole.cpp rename to catkit2-core/src/LogConsole.cpp diff --git a/catkit_core/LogConsole.h b/catkit2-core/src/LogConsole.h similarity index 100% rename from catkit_core/LogConsole.h rename to catkit2-core/src/LogConsole.h diff --git a/catkit_core/LogFile.cpp b/catkit2-core/src/LogFile.cpp similarity index 100% rename from catkit_core/LogFile.cpp rename to catkit2-core/src/LogFile.cpp diff --git a/catkit_core/LogFile.h b/catkit2-core/src/LogFile.h similarity index 100% rename from catkit_core/LogFile.h rename to catkit2-core/src/LogFile.h diff --git a/catkit_core/LogForwarder.cpp b/catkit2-core/src/LogForwarder.cpp similarity index 100% rename from catkit_core/LogForwarder.cpp rename to catkit2-core/src/LogForwarder.cpp diff --git a/catkit_core/LogForwarder.h b/catkit2-core/src/LogForwarder.h similarity index 100% rename from catkit_core/LogForwarder.h rename to catkit2-core/src/LogForwarder.h diff --git a/catkit_core/LoggingProxy.h b/catkit2-core/src/LoggingProxy.h similarity index 100% rename from catkit_core/LoggingProxy.h rename to catkit2-core/src/LoggingProxy.h diff --git a/catkit_core/PoolAllocator.cpp b/catkit2-core/src/PoolAllocator.cpp similarity index 100% rename from catkit_core/PoolAllocator.cpp rename to catkit2-core/src/PoolAllocator.cpp diff --git a/catkit_core/PoolAllocator.h b/catkit2-core/src/PoolAllocator.h similarity index 100% rename from catkit_core/PoolAllocator.h rename to catkit2-core/src/PoolAllocator.h diff --git a/catkit_core/Property.cpp b/catkit2-core/src/Property.cpp similarity index 100% rename from catkit_core/Property.cpp rename to catkit2-core/src/Property.cpp diff --git a/catkit_core/Property.h b/catkit2-core/src/Property.h similarity index 100% rename from catkit_core/Property.h rename to catkit2-core/src/Property.h diff --git a/catkit_core/Server.cpp b/catkit2-core/src/Server.cpp similarity index 100% rename from catkit_core/Server.cpp rename to catkit2-core/src/Server.cpp diff --git a/catkit_core/Server.h b/catkit2-core/src/Server.h similarity index 100% rename from catkit_core/Server.h rename to catkit2-core/src/Server.h diff --git a/catkit_core/Service.cpp b/catkit2-core/src/Service.cpp similarity index 99% rename from catkit_core/Service.cpp rename to catkit2-core/src/Service.cpp index e472d2518..1d37b7639 100644 --- a/catkit_core/Service.cpp +++ b/catkit2-core/src/Service.cpp @@ -4,7 +4,7 @@ #include "Timing.h" #include "TestbedProxy.h" #include "Tracing.h" -#include "proto/service.pb.h" +#include "service.pb.h" #include #include diff --git a/catkit_core/Service.h b/catkit2-core/src/Service.h similarity index 100% rename from catkit_core/Service.h rename to catkit2-core/src/Service.h diff --git a/catkit_core/ServiceProxy.cpp b/catkit2-core/src/ServiceProxy.cpp similarity index 99% rename from catkit_core/ServiceProxy.cpp rename to catkit2-core/src/ServiceProxy.cpp index 53629f88d..1eb3c122e 100644 --- a/catkit_core/ServiceProxy.cpp +++ b/catkit2-core/src/ServiceProxy.cpp @@ -4,7 +4,7 @@ #include "Timing.h" #include "Service.h" #include "Util.h" -#include "proto/service.pb.h" +#include "service.pb.h" #include diff --git a/catkit_core/ServiceProxy.h b/catkit2-core/src/ServiceProxy.h similarity index 100% rename from catkit_core/ServiceProxy.h rename to catkit2-core/src/ServiceProxy.h diff --git a/catkit_core/ServiceState.cpp b/catkit2-core/src/ServiceState.cpp similarity index 100% rename from catkit_core/ServiceState.cpp rename to catkit2-core/src/ServiceState.cpp diff --git a/catkit_core/ServiceState.h b/catkit2-core/src/ServiceState.h similarity index 90% rename from catkit_core/ServiceState.h rename to catkit2-core/src/ServiceState.h index 5f3cacbe6..2d7a9c76e 100644 --- a/catkit_core/ServiceState.h +++ b/catkit2-core/src/ServiceState.h @@ -1,7 +1,7 @@ #ifndef SERVICE_STATE_H #define SERVICE_STATE_H -#include "proto/testbed.pb.h" +#include "testbed.pb.h" enum ServiceState { diff --git a/catkit_core/SharedMemory.cpp b/catkit2-core/src/SharedMemory.cpp similarity index 100% rename from catkit_core/SharedMemory.cpp rename to catkit2-core/src/SharedMemory.cpp diff --git a/catkit_core/SharedMemory.h b/catkit2-core/src/SharedMemory.h similarity index 100% rename from catkit_core/SharedMemory.h rename to catkit2-core/src/SharedMemory.h diff --git a/catkit_core/Synchronization.cpp b/catkit2-core/src/Synchronization.cpp similarity index 100% rename from catkit_core/Synchronization.cpp rename to catkit2-core/src/Synchronization.cpp diff --git a/catkit_core/Synchronization.h b/catkit2-core/src/Synchronization.h similarity index 100% rename from catkit_core/Synchronization.h rename to catkit2-core/src/Synchronization.h diff --git a/catkit_core/Tensor.cpp b/catkit2-core/src/Tensor.cpp similarity index 100% rename from catkit_core/Tensor.cpp rename to catkit2-core/src/Tensor.cpp diff --git a/catkit_core/Tensor.h b/catkit2-core/src/Tensor.h similarity index 98% rename from catkit_core/Tensor.h rename to catkit2-core/src/Tensor.h index 228e42561..23c22284a 100644 --- a/catkit_core/Tensor.h +++ b/catkit2-core/src/Tensor.h @@ -2,7 +2,7 @@ #define TENSOR_H #include "ComplexTraits.h" -#include "proto/core.pb.h" +#include "core.pb.h" #include diff --git a/catkit_core/Tensor.inl b/catkit2-core/src/Tensor.inl similarity index 100% rename from catkit_core/Tensor.inl rename to catkit2-core/src/Tensor.inl diff --git a/catkit_core/TestbedProxy.cpp b/catkit2-core/src/TestbedProxy.cpp similarity index 99% rename from catkit_core/TestbedProxy.cpp rename to catkit2-core/src/TestbedProxy.cpp index de7ad8859..596435f01 100644 --- a/catkit_core/TestbedProxy.cpp +++ b/catkit2-core/src/TestbedProxy.cpp @@ -2,7 +2,7 @@ #include "Timing.h" #include "HostName.h" -#include "proto/testbed.pb.h" +#include "testbed.pb.h" #include #include diff --git a/catkit_core/TestbedProxy.h b/catkit2-core/src/TestbedProxy.h similarity index 98% rename from catkit_core/TestbedProxy.h rename to catkit2-core/src/TestbedProxy.h index 032ee659a..d54be6fb8 100644 --- a/catkit_core/TestbedProxy.h +++ b/catkit2-core/src/TestbedProxy.h @@ -5,7 +5,7 @@ #include "LoggingProxy.h" #include "DataStream.h" #include "Client.h" -#include "proto/testbed.pb.h" +#include "testbed.pb.h" #include "ServiceState.h" #include "Util.h" diff --git a/catkit_core/Timing.cpp b/catkit2-core/src/Timing.cpp similarity index 100% rename from catkit_core/Timing.cpp rename to catkit2-core/src/Timing.cpp diff --git a/catkit_core/Timing.h b/catkit2-core/src/Timing.h similarity index 100% rename from catkit_core/Timing.h rename to catkit2-core/src/Timing.h diff --git a/catkit_core/Tracing.cpp b/catkit2-core/src/Tracing.cpp similarity index 99% rename from catkit_core/Tracing.cpp rename to catkit2-core/src/Tracing.cpp index 0807b63e4..31c9903c1 100644 --- a/catkit_core/Tracing.cpp +++ b/catkit2-core/src/Tracing.cpp @@ -3,7 +3,7 @@ #include "Timing.h" #include "Util.h" #include "Log.h" -#include "proto/tracing.pb.h" +#include "tracing.pb.h" #include diff --git a/catkit_core/Tracing.h b/catkit2-core/src/Tracing.h similarity index 100% rename from catkit_core/Tracing.h rename to catkit2-core/src/Tracing.h diff --git a/catkit_core/Types.cpp b/catkit2-core/src/Types.cpp similarity index 100% rename from catkit_core/Types.cpp rename to catkit2-core/src/Types.cpp diff --git a/catkit_core/Types.h b/catkit2-core/src/Types.h similarity index 97% rename from catkit_core/Types.h rename to catkit2-core/src/Types.h index 165929ea4..1480df555 100644 --- a/catkit_core/Types.h +++ b/catkit2-core/src/Types.h @@ -2,7 +2,7 @@ #define TYPES_H #include "Tensor.h" -#include "proto/core.pb.h" +#include "core.pb.h" #include #include diff --git a/catkit_core/Util.cpp b/catkit2-core/src/Util.cpp similarity index 100% rename from catkit_core/Util.cpp rename to catkit2-core/src/Util.cpp diff --git a/catkit_core/Util.h b/catkit2-core/src/Util.h similarity index 100% rename from catkit_core/Util.h rename to catkit2-core/src/Util.h diff --git a/catkit_core/Util.inl b/catkit2-core/src/Util.inl similarity index 100% rename from catkit_core/Util.inl rename to catkit2-core/src/Util.inl diff --git a/catkit2/CMakeLists.txt b/catkit2/CMakeLists.txt new file mode 100644 index 000000000..eec0dcac7 --- /dev/null +++ b/catkit2/CMakeLists.txt @@ -0,0 +1,42 @@ +cmake_minimum_required(VERSION 3.21) + +project(catkit_bindings) + +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED on) + +set(SOURCES "bindings.cpp") + +find_package(pybind11 REQUIRED) +pybind11_add_module(catkit_bindings ${SOURCES}) + +find_package(pybind11_json REQUIRED) +target_include_directories(catkit_bindings PUBLIC pybind11_json_INCLUDE_DIRS) + +target_include_directories(catkit_bindings PUBLIC ../catkit_core) + +target_link_libraries(catkit_bindings PUBLIC catkit_core) + +# Compile protobuf files. +find_package(Protobuf REQUIRED) + +set(PROTO_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/../proto/core.proto + ${CMAKE_CURRENT_SOURCE_DIR}/../proto/logging.proto + ${CMAKE_CURRENT_SOURCE_DIR}/../proto/service.proto + ${CMAKE_CURRENT_SOURCE_DIR}/../proto/testbed.proto + ${CMAKE_CURRENT_SOURCE_DIR}/../proto/tracing.proto +) + +set(PYTHON_OUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/./proto/) + +add_custom_target( + catkit2_python_protobuf ALL + COMMAND ${Protobuf_PROTOC_EXECUTABLE} + --proto_path=${CMAKE_CURRENT_SOURCE_DIR}/../proto/ + --python_out=${PYTHON_OUT_DIR} + ${PROTO_FILES} + DEPENDS ${PROTO_FILES} +) + +install(TARGETS catkit_bindings LIBRARY DESTINATION "${SKBUILD_PLATLIB_DIR}/catkit2/") diff --git a/catkit_bindings/bindings.cpp b/catkit2/bindings.cpp similarity index 99% rename from catkit_bindings/bindings.cpp rename to catkit2/bindings.cpp index 00c0f8d38..3b7fadf73 100644 --- a/catkit_bindings/bindings.cpp +++ b/catkit2/bindings.cpp @@ -21,7 +21,7 @@ #include "HostName.h" #include "Tracing.h" -#include "proto/testbed.pb.h" +#include "testbed.pb.h" #define STRINGIFY(x) #x #define MACRO_STRINGIFY(x) STRINGIFY(x) diff --git a/catkit_bindings/CMakeLists.txt b/catkit_bindings/CMakeLists.txt deleted file mode 100644 index 02533f210..000000000 --- a/catkit_bindings/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -cmake_minimum_required(VERSION 3.5) - -project(catkit_bindings) - -set(CMAKE_CXX_STANDARD 20) -set(CMAKE_CXX_STANDARD_REQUIRED on) - -set(SOURCES "bindings.cpp") - -add_subdirectory(../extern/pybind11 pybind11) -pybind11_add_module(catkit_bindings ${SOURCES}) - -target_include_directories(catkit_bindings PUBLIC ../extern/pybind11_json-0.2.11/include) -target_include_directories(catkit_bindings PUBLIC ../catkit_core) - -target_link_libraries(catkit_bindings PUBLIC catkit_core) - -install(TARGETS catkit_bindings DESTINATION lib) diff --git a/catkit_core/CMakeLists.txt b/catkit_core/CMakeLists.txt deleted file mode 100644 index 6258d432e..000000000 --- a/catkit_core/CMakeLists.txt +++ /dev/null @@ -1,95 +0,0 @@ -cmake_minimum_required(VERSION 3.5) - -project(catkit_core) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED on) - -if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) - message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there. You may need to remove CMakeCache.txt.") -endif() - -add_compile_options($<$:/MP1>) - -add_library(catkit_core STATIC - DataStream.cpp - SharedMemory.cpp - Synchronization.cpp - Timing.cpp - Log.cpp - LogConsole.cpp - LogFile.cpp - LogForwarder.cpp - HostName.cpp - Command.cpp - Property.cpp - Service.cpp - Server.cpp - Client.cpp - TestbedProxy.cpp - ServiceProxy.cpp - ServiceState.cpp - Tensor.cpp - Tracing.cpp - Types.cpp - Util.cpp - PoolAllocator.cpp - FreeListAllocator.cpp - proto/core.pb.cc - proto/logging.pb.cc - proto/testbed.pb.cc - proto/service.pb.cc - proto/tracing.pb.cc) - -set_property(TARGET catkit_core PROPERTY POSITION_INDEPENDENT_CODE ON) -target_compile_definitions(catkit_core PUBLIC PROTOBUF_USE_DLLS) - -if (MSVC) - # disable warning: 'identifier': class 'type' needs to have dll-interface to be used by clients of class 'type2' - target_compile_options(catkit_core PUBLIC /wd4251) -endif() - -# Link ZeroMQ -find_package(ZeroMQ REQUIRED) -target_include_directories(catkit_core PUBLIC ${ZeroMQ_INCLUDE_DIR}) -target_link_libraries(catkit_core PUBLIC libzmq) -if (WIN32) - target_link_libraries(catkit_core PUBLIC wsock32 ws2_32 Iphlpapi) -else() - target_link_libraries(catkit_core PUBLIC pthread) - if (NOT APPLE) - target_link_libraries(catkit_core PUBLIC rt) - endif (NOT APPLE) -endif (WIN32) - -# Add includes for cppzmq -set(CPPZMQ_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/../extern/cppzmq-4.8.1) -target_include_directories(catkit_core PUBLIC ${CPPZMQ_INCLUDE_DIR}) - -# Link Eigen -set(EIGEN_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/../extern/eigen-3.4.0) -target_include_directories(catkit_core PUBLIC ${EIGEN_INCLUDE_DIR}) - -# Link nlohmann JSON -set (JSON_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/../extern/json-3.9.1/include) -target_include_directories(catkit_core PUBLIC ${JSON_INCLUDE_DIR}) - -# Link protobuf -INCLUDE(FindProtobuf) -find_package(Protobuf REQUIRED) -target_include_directories(catkit_core PUBLIC ${PROTOBUF_INCLUDE_DIR}) -target_link_libraries(catkit_core PUBLIC ${PROTOBUF_LIBRARY}) - -# Add install files -install(TARGETS catkit_core DESTINATION lib) -install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR} - DESTINATION include - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.inl" -) -install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../proto/gen/cpp/ - DESTINATION include/catkit_core - FILES_MATCHING - PATTERN "*.h" -) diff --git a/catkit_core/LoggingProxy.cpp b/catkit_core/LoggingProxy.cpp deleted file mode 100644 index 4f189fdac..000000000 --- a/catkit_core/LoggingProxy.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include "LoggingProxy.h" - -LoggingProxy::LoggingProxy(std::shared_ptr ) \ No newline at end of file diff --git a/docs/installation.rst b/docs/installation.rst index c9163f2d5..7ddb001ff 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -1,19 +1,9 @@ Installation ============ -Catkit2 consists of a core C++ library and a Python package that wraps this library. It also requires a number of C++ third party libraries to facilitate JSON encoding and decoding, Python bindings, linear algebra and high-speed communication over sockets. Compilation requires a C++ compiler conforming to the C++20 standard. Catkit2 provides scripts to automate downloading and installation of its dependencies and main library. +Catkit2 consists of a core C++ library and a Python package that wraps this library. It also requires a number of C++ third party libraries to facilitate JSON encoding and decoding, Python bindings, linear algebra and high-speed communication over sockets. Compilation requires a C++ compiler conforming to the C++20 standard. Catkit2 performs installation of the core library and Python package using CMake and Conda. -The following will download all third-party C++ dependencies: - -.. code-block:: bash - - cd catkit2 - cd extern - ./download.sh - -These downloads can be performed on a separate machine with internet connectivity, in case the machine on which the testbed is run does not have an (unfirewalled) internet connection. After downloading, the resulting folders can be copy-pasted in the extern folder on the machine without internet connectivity. - -The following will install all downloaded dependencies and create the Conda environment for catkit2. +The following will install all dependencies and create the Conda environment for catkit2. .. code-block:: bash @@ -25,7 +15,7 @@ At this point, all C++ and Python dependencies of catkit2 should have been downl .. code-block:: bash - python setup.py develop + pip install -e . This will use the default CMake generator to compile catkit_core and its Python bindings. If the default generator doesn't support 64bit compilation, this step will return an error and you will need to specify a default generator to use by setting the CMAKE_GENERATOR environment variable to your preferred generator. You can list all generators installed on your machine with cmake --help. You will have to restart your terminal after changing your environment variables as usual. diff --git a/environment.yml b/environment.yml index 43d207e62..3de5fd88e 100644 --- a/environment.yml +++ b/environment.yml @@ -26,10 +26,15 @@ dependencies: - psutil - protobuf - libprotobuf - - conda-forge:hcipy + - conda-forge::hcipy + - conda-forge::cppzmq==4.8.1 + - conda-forge::pybind11==2.13.6 + - conda-forge::eigen==3.4.0 + - conda-forge::nlohmann_json==3.9.1 + - conda-forge::pybind11_json - pip - - conda-forge::cmake>=3.0.0 - - conda-forge::doxygen + - cmake>=3.0.0 + - doxygen - sphinx - conda-forge::sphinx-automodapi - conda-forge::breathe==4.32.0 diff --git a/extern/download.sh b/extern/download.sh deleted file mode 100755 index 647adcf35..000000000 --- a/extern/download.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -# Download cppzmq -curl -L https://github.com/zeromq/cppzmq/archive/refs/tags/v4.8.1.tar.gz -O -tar xfz v4.8.1.tar.gz -rm -f v4.8.1.tar.gz - -# Download pybind11 -git clone -b v2.9.2 https://github.com/pybind/pybind11 - -# Download Eigen -curl -L https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz -O -tar xfz eigen-3.4.0.tar.gz -rm -f eigen-3.4.0.tar.gz - -# Download nlohmann JSON -curl -L https://github.com/nlohmann/json/archive/refs/tags/v3.9.1.tar.gz -O -tar xfz v3.9.1.tar.gz -rm -f v3.9.1.tar.gz - -# Download pybind11 to JSON converter -curl -L https://github.com/pybind/pybind11_json/archive/refs/tags/0.2.11.tar.gz -O -tar xfz 0.2.11.tar.gz -rm -f 0.2.11.tar.gz diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..8a10b90d8 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,95 @@ +[build-system] +requires = ["scikit-build-core"] +build-backend = "scikit_build_core.build" + +[tool.scikit-build] +build.verbose = true +logging.level = "INFO" + +[project] +name = "catkit2" +version = "0.0.1" +authors = [ + {name = "E.H. Por et al."}, +] +description = "A library for controlling testbed hardware" +requires-python = ">=3.7" +dependencies = [ +] +maintainers = [ + {name = "Emiel Por", email = "epor@ucsc.edu"}, + {name = "Remi Soummer", email = "soummer@stsci.edu"}, + {name = "Iva Laginja", email = "iva.laginja@obspm.fr"} +] +readme = "README.md" +license = {file = "LICENSE.rst"} +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python :: 3", +] + +[project.urls] +Homepage = "https://spacetelescope.github.com/catkit2" +Documentation = "https://spacetelescope.github.io/catkit2" +Repository = "https://spacetelescope.github.com/catkit2.git" + +[project.entry-points."catkit2.services"] +aimtti_plp_device = "catkit2.services.aimtti_plp_device.aimtti_plp_device" +aimtti_plp_device_sim = "catkit2.services.aimtti_plp_device_sim.aimtti_plp_device_sim" +allied_vision_camera = "catkit2.services.allied_vision_camera.allied_vision_camera" +bmc_deformable_mirror_hardware = "catkit2.services.bmc_deformable_mirror_hardware.bmc_deformable_mirror_hardware" +bmc_deformable_mirror_sim = "catkit2.services.bmc_deformable_mirror_sim.bmc_deformable_mirror_sim" +bmc_dm = "catkit2.services.bmc_dm.bmc_dm" +bmc_dm_sim = "catkit2.services.bmc_dm_sim.bmc_dm_sim" +camera_sim = "catkit2.services.camera_sim.camera_sim" +dummy_camera = "catkit2.services.dummy_camera.dummy_camera" +empty_service = "catkit2.services.empty_service.empty_service" +flir_camera = "catkit2.services.flir_camera.flir_camera" +hamamatsu_camera = "catkit2.services.hamamatsu_camera.hamamatsu_camera" +newport_picomotor = "catkit2.services.newport_picomotor.newport_picomotor" +newport_picomotor_sim = "catkit2.services.newport_picomotor_sim.newport_picomotor_sim" +newport_xps_q8 = "catkit2.services.newport_xps_q8.newport_xps_q8" +newport_xps_q8_sim = "catkit2.services.newport_xps_q8_sim.newport_xps_q8_sim" +ni_daq = "catkit2.services.ni_daq.ni_daq" +ni_daq_sim = "catkit2.services.ni_daq_sim.ni_daq_sim" +nkt_superk = "catkit2.services.nkt_superk.nkt_superk" +nkt_superk_sim = "catkit2.services.nkt_superk_sim.nkt_superk_sim" +oceanoptics_spectrometer = "catkit2.services.oceanoptics_spectrometer.oceanoptics_spectrometer" +oceanoptics_spectrometer_sim = "catkit2.services.oceanoptics_spectrometer_sim.oceanoptics_spectrometer_sim" +omega_ithx_w3 = "catkit2.services.omega_ithx_w3.omega_ithx_w3" +omega_ithx_w3_sim = "catkit2.services.omega_ithx_w3_sim.omega_ithx_w3_sim" +safety_manual_check = "catkit2.services.safety_manual_check.safety_manual_check" +safety_monitor = "catkit2.services.safety_monitor.safety_monitor" +simple_simulator = "catkit2.services.simple_simulator.simple_simulator" +snmp_ups = "catkit2.services.snmp_ups.snmp_ups" +snmp_ups_sim = "catkit2.services.snmp_ups_sim.snmp_ups_sim" +thorlabs_cld101x = "catkit2.services.thorlabs_cld101x.thorlabs_cld101x" +thorlabs_cld101x_sim = "catkit2.services.thorlabs_cld101x_sim.thorlabs_cld101x_sim" +thorlabs_cube_motor_kinesis = "catkit2.services.thorlabs_cube_motor_kinesis.thorlabs_cube_motor_kinesis" +thorlabs_cube_motor_kinesis_sim = "catkit2.services.thorlabs_cube_motor_kinesis_sim.thorlabs_cube_motor_kinesis_sim" +thorlabs_fw102c = "catkit2.services.thorlabs_fw102c.thorlabs_fw102c" +thorlabs_mcls1 = "catkit2.services.thorlabs_mcls1.thorlabs_mcls1" +thorlabs_mcls1_sim = "catkit2.services.thorlabs_mcls1_sim.thorlabs_mcls1_sim" +thorlabs_mff101 = "catkit2.services.thorlabs_mff101.thorlabs_mff101" +thorlabs_mff101_sim = "catkit2.services.thorlabs_mff101_sim.thorlabs_mff101_sim" +thorlabs_pm = "catkit2.services.thorlabs_pm.thorlabs_pm" +thorlabs_pm_sim = "catkit2.services.thorlabs_pm_sim.thorlabs_pm_sim" +thorlabs_tsp01 = "catkit2.services.thorlabs_tsp01.thorlabs_tsp01" +thorlabs_tsp01_sim = "catkit2.services.thorlabs_tsp01_sim.thorlabs_tsp01_sim" +web_power_switch = "catkit2.services.web_power_switch.web_power_switch" +web_power_switch_sim = "catkit2.services.web_power_switch_sim.web_power_switch_sim" +zwo_camera = "catkit2.services.zwo_camera.zwo_camera" + +[project.entry-points."catkit2.proxies"] +bmc_dm = "catkit2.testbed.proxies.bmc_dm:BmcDmProxy" +camera = "catkit2.testbed.proxies.camera:CameraProxy" +deformable_mirror = "catkit2.testbed.proxies.deformable_mirror:DeformableMirrorProxy" +flip_mount = "catkit2.testbed.proxies.flip_mount:FlipMountProxy" +newport_picomotor = "catkit2.testbed.proxies.newport_picomotor:NewportPicomotorProxy" +newport_xps_q8 = "catkit2.testbed.proxies.newport_xps:NewportXpsQ8Proxy" +ni_daq = "catkit2.testbed.proxies.ni_daq:NiDaqProxy" +nkt_superk = "catkit2.testbed.proxies.nkt_superk:NktSuperkProxy" +oceanoptics_spectrometer = "catkit2.testbed.proxies.oceanoptics_spectrometer:OceanopticsSpectroProxy" +thorlabs_cube_motor_kinesis = "catkit2.testbed.proxies.thorlabs_cube_motor_kinesis:ThorlabsCubeMotorKinesisProxy" +thorlabs_mcls1 = "catkit2.testbed.proxies.thorlabs_mcls1:ThorlabsMcls1" +web_power_switch = "catkit2.testbed.proxies.web_power_switch:WebPowerSwitchProxy" diff --git a/setup.py b/setup.py deleted file mode 100644 index 450a651f0..000000000 --- a/setup.py +++ /dev/null @@ -1,209 +0,0 @@ -import setuptools -import os -import re -import sys -import glob -import shutil -import platform -import subprocess - -from distutils.version import LooseVersion -from setuptools import setup, Extension -from setuptools.command.build_ext import build_ext -from distutils.spawn import find_executable - -# Find the Protocol Compiler. -if 'PROTOC' in os.environ and os.path.exists(os.environ['PROTOC']): - protoc = os.environ['PROTOC'] -else: - protoc = find_executable("protoc") - -if protoc is None: - sys.stderr.write( - "protoc is not installed nor found in ../src. Please compile it " - "or install the binary package.\n") - sys.exit(-1) - -def generate_protos(source_dir): - '''Invokes the Protobuf Compiler to generate C++ and Python source files - from all .proto files in the proto directory. Does nothing if the output - already exists and is newer than the input. - ''' - proto_path = os.path.join(source_dir, 'proto') - - files = glob.glob(os.path.join(proto_path, '**.proto')) - files = [os.path.relpath(f, proto_path) for f in files] - - python_path = os.path.join(source_dir, 'catkit2', 'proto') - cpp_path = os.path.join(source_dir, 'catkit_core', 'proto') - - os.makedirs(python_path, exist_ok=True) - os.makedirs(cpp_path, exist_ok=True) - - for f in files: - src_time = os.path.getmtime(os.path.join(proto_path, f)) - - python_output = os.path.splitext(os.path.join(python_path, f))[0] + '_pb2.py' - cpp_h_output = os.path.splitext(os.path.join(cpp_path, f))[0] + '.pb.h' - cpp_cc_output = os.path.splitext(os.path.join(cpp_path, f))[0] + '.pb.cc' - - try: - dest_time_python = os.path.getmtime(python_output) - dest_time_cpp_h = os.path.getmtime(cpp_h_output) - dest_time_cpp_cc = os.path.getmtime(cpp_cc_output) - - should_compile = min(dest_time_python, dest_time_cpp_h, dest_time_cpp_cc) < src_time - except OSError: - # Either the Python or C++ did not exist. - should_compile = True - - if should_compile: - protoc_command = [ - protoc, - '--proto_path', proto_path, - '--python_out', python_path, - '--cpp_out', cpp_path, - f] - - if subprocess.run(protoc_command).returncode != 0: - sys.exit(-1) - -class CMakeExtension(Extension): - def __init__(self, name, sourcedir=''): - Extension.__init__(self, name, sources=[]) - self.sourcedir = os.path.abspath(sourcedir) - -class CMakeBuild(build_ext): - def run(self): - try: - out = subprocess.check_output(['cmake', '--version']) - except OSError: - raise RuntimeError( - "CMake must be installed to build the following extensions: " + - ", ".join(e.name for e in self.extensions)) - - if platform.system() == "Windows": - cmake_version = LooseVersion(re.search(r'version\s*([\d.]+)', - out.decode()).group(1)) - if cmake_version < '3.1.0': - raise RuntimeError("CMake >= 3.1.0 is required on Windows") - - for ext in self.extensions: - self.build_extension(ext) - - def build_extension(self, ext): - cmake_args = ['-DPYTHON_EXECUTABLE=' + sys.executable] - - cfg = 'Debug' if self.debug else 'Release' - build_args = ['--config', cfg] - - if platform.system() == "Windows": - if sys.maxsize > 2**32: - cmake_args += ['-A', 'x64'] - else: - cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg] - build_args += ['-j', '4'] - - env = os.environ.copy() - env['CXXFLAGS'] = '{} -DVERSION_INFO=\\"{}\\"'.format(env.get('CXXFLAGS', ''), self.distribution.get_version()) - - install_dir = os.path.join(ext.sourcedir, 'build') - - os.makedirs(self.build_temp, exist_ok=True) - os.makedirs(install_dir, exist_ok=True) - - print('Compiling protobuffers...') - generate_protos(ext.sourcedir) - - subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env) - subprocess.check_call(['cmake', '--build', '.'] + build_args, cwd=self.build_temp) - subprocess.check_call(['cmake', '--install', '.', '--prefix', install_dir], cwd=self.build_temp) - - for f in glob.glob(os.path.join(install_dir, 'lib', 'catkit_bindings*')): - shutil.copy(f, os.path.join(ext.sourcedir, 'catkit2')) - -with open("README.md", "r") as f: - long_description = f.read() - -setup( - name="catkit2", - version="0.0.1", - author="Emiel Por", - author_email="epor@stsci.edu", - description="A library for controlling testbed hardware", - long_description=long_description, - long_description_content_type="text/markdown", - packages=setuptools.find_packages(), - package_data={'catkit2': ['user_interface/assets/*']}, - classifiers=[ - "Programming Language :: Python :: 3" - ], - ext_modules=[CMakeExtension('catkit_bindings')], - python_requires='>=3.6', - cmdclass=dict(build_ext=CMakeBuild), - zip_safe=False, - install_requires=[], - entry_points={ - 'catkit2.services': [ - 'aimtti_plp_device = catkit2.services.aimtti_plp_device.aimtti_plp_device', - 'aimtti_plp_device_sim = catkit2.services.aimtti_plp_device_sim.aimtti_plp_device_sim', - 'allied_vision_camera = catkit2.services.allied_vision_camera.allied_vision_camera', - 'bmc_deformable_mirror_hardware = catkit2.services.bmc_deformable_mirror_hardware.bmc_deformable_mirror_hardware', - 'bmc_deformable_mirror_sim = catkit2.services.bmc_deformable_mirror_sim.bmc_deformable_mirror_sim', - 'bmc_dm = catkit2.services.bmc_dm.bmc_dm', - 'bmc_dm_sim = catkit2.services.bmc_dm_sim.bmc_dm_sim', - 'camera_sim = catkit2.services.camera_sim.camera_sim', - 'dummy_camera = catkit2.services.dummy_camera.dummy_camera', - 'empty_service = catkit2.services.empty_service.empty_service', - 'flir_camera = catkit2.services.flir_camera.flir_camera', - 'hamamatsu_camera = catkit2.services.hamamatsu_camera.hamamatsu_camera', - 'newport_picomotor = catkit2.services.newport_picomotor.newport_picomotor', - 'newport_picomotor_sim = catkit2.services.newport_picomotor_sim.newport_picomotor_sim', - 'newport_xps_q8 = catkit2.services.newport_xps_q8.newport_xps_q8', - 'newport_xps_q8_sim = catkit2.services.newport_xps_q8_sim.newport_xps_q8_sim', - 'ni_daq = catkit2.services.ni_daq.ni_daq', - 'ni_daq_sim = catkit2.services.ni_daq_sim.ni_daq_sim', - 'nkt_superk = catkit2.services.nkt_superk.nkt_superk', - 'nkt_superk_sim = catkit2.services.nkt_superk_sim.nkt_superk_sim', - 'oceanoptics_spectrometer = catkit2.services.oceanoptics_spectrometer.oceanoptics_spectrometer', - 'oceanoptics_spectrometer_sim = catkit2.services.oceanoptics_spectrometer_sim.oceanoptics_spectrometer_sim', - 'omega_ithx_w3 = catkit2.services.omega_ithx_w3.omega_ithx_w3', - 'omega_ithx_w3_sim = catkit2.services.omega_ithx_w3_sim.omega_ithx_w3_sim', - 'safety_manual_check = catkit2.services.safety_manual_check.safety_manual_check', - 'safety_monitor = catkit2.services.safety_monitor.safety_monitor', - 'simple_simulator = catkit2.services.simple_simulator.simple_simulator', - 'snmp_ups = catkit2.services.snmp_ups.snmp_ups', - 'snmp_ups_sim = catkit2.services.snmp_ups_sim.snmp_ups_sim', - 'thorlabs_cld101x = catkit2.services.thorlabs_cld101x.thorlabs_cld101x', - 'thorlabs_cld101x_sim = catkit2.services.thorlabs_cld101x_sim.thorlabs_cld101x_sim', - 'thorlabs_cube_motor_kinesis = catkit2.services.thorlabs_cube_motor_kinesis.thorlabs_cube_motor_kinesis', - 'thorlabs_cube_motor_kinesis_sim = catkit2.services.thorlabs_cube_motor_kinesis_sim.thorlabs_cube_motor_kinesis_sim', - 'thorlabs_fw102c = catkit2.services.thorlabs_fw102c.thorlabs_fw102c', - 'thorlabs_mcls1 = catkit2.services.thorlabs_mcls1.thorlabs_mcls1', - 'thorlabs_mcls1_sim = catkit2.services.thorlabs_mcls1_sim.thorlabs_mcls1_sim', - 'thorlabs_mff101 = catkit2.services.thorlabs_mff101.thorlabs_mff101', - 'thorlabs_mff101_sim = catkit2.services.thorlabs_mff101_sim.thorlabs_mff101_sim', - 'thorlabs_pm = catkit2.services.thorlabs_pm.thorlabs_pm', - 'thorlabs_pm_sim = catkit2.services.thorlabs_pm_sim.thorlabs_pm_sim', - 'thorlabs_tsp01 = catkit2.services.thorlabs_tsp01.thorlabs_tsp01', - 'thorlabs_tsp01_sim = catkit2.services.thorlabs_tsp01_sim.thorlabs_tsp01_sim', - 'web_power_switch = catkit2.services.web_power_switch.web_power_switch', - 'web_power_switch_sim = catkit2.services.web_power_switch_sim.web_power_switch_sim', - 'zwo_camera = catkit2.services.zwo_camera.zwo_camera', - ], - 'catkit2.proxies': [ - 'bmc_dm = catkit2.testbed.proxies.bmc_dm:BmcDmProxy', - 'camera = catkit2.testbed.proxies.camera:CameraProxy', - 'deformable_mirror = catkit2.testbed.proxies.deformable_mirror:DeformableMirrorProxy', - 'flip_mount = catkit2.testbed.proxies.flip_mount:FlipMountProxy', - 'newport_picomotor = catkit2.testbed.proxies.newport_picomotor:NewportPicomotorProxy', - 'newport_xps_q8 = catkit2.testbed.proxies.newport_xps:NewportXpsQ8Proxy', - 'ni_daq = catkit2.testbed.proxies.ni_daq:NiDaqProxy', - 'nkt_superk = catkit2.testbed.proxies.nkt_superk:NktSuperkProxy', - 'oceanoptics_spectrometer = catkit2.testbed.proxies.oceanoptics_spectrometer:OceanopticsSpectroProxy', - 'thorlabs_cube_motor_kinesis = catkit2.testbed.proxies.thorlabs_cube_motor_kinesis:ThorlabsCubeMotorKinesisProxy', - 'thorlabs_mcls1 = catkit2.testbed.proxies.thorlabs_mcls1:ThorlabsMcls1', - 'web_power_switch = catkit2.testbed.proxies.web_power_switch:WebPowerSwitchProxy' - ] - } -)