Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to pyproject.toml installation. #275

Draft
wants to merge 12 commits into
base: develop
Choose a base branch
from
5 changes: 1 addition & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: |
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.21)

project(catkit2)

Expand All @@ -14,5 +14,5 @@ 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(catkit2)
add_subdirectory(benchmarks)
30 changes: 11 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
```

Expand All @@ -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 ..
```
```
2 changes: 1 addition & 1 deletion benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.21)

project(catkit2)

Expand Down
42 changes: 42 additions & 0 deletions catkit2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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/")
2 changes: 1 addition & 1 deletion catkit_bindings/bindings.cpp → catkit2/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 0 additions & 18 deletions catkit_bindings/CMakeLists.txt

This file was deleted.

92 changes: 53 additions & 39 deletions catkit_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,10 @@ endif()

add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/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)
file(GLOB_RECURSE SOURCES "*.cpp")
file(GLOB_RECURSE HEADERS "*.h")

add_library(catkit_core STATIC "${SOURCES}")

set_property(TARGET catkit_core PROPERTY POSITION_INDEPENDENT_CODE ON)
target_compile_definitions(catkit_core PUBLIC PROTOBUF_USE_DLLS)
Expand All @@ -63,33 +38,72 @@ else()
endif (WIN32)

# Add includes for cppzmq
set(CPPZMQ_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/../extern/cppzmq-4.8.1)
find_package(cppzmq REQUIRED)
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})
find_package(Eigen3 REQUIRED NO_MODULE)
target_link_libraries (catkit_core PUBLIC Eigen3::Eigen)

# 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})
find_package(nlohmann_json)
target_include_directories(catkit_core PRIVATE ${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)
set(PROTO_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/gen/")
file(MAKE_DIRECTORY "${PROTO_BINARY_DIR}")
protobuf_generate(
TARGET catkit_core
IMPORT_DIRS ../proto
PROTOC_OUT_DIR "${PROTO_BINARY_DIR}"
PROTOS
../proto/core.proto
../proto/logging.proto
../proto/service.proto
../proto/testbed.proto
../proto/tracing.proto
)
target_include_directories(catkit_core PUBLIC "$<BUILD_INTERFACE:${PROTO_BINARY_DIR}>")
# 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 "${SKBUILD_PLATLIB_DIR}/cmake/catkit_core"
)

install(
TARGETS catkit_core
EXPORT CatkitCoreTargets
LIBRARY DESTINATION lib
)

# Generate and install CatkitCoreTargets.cmake
install(
EXPORT CatkitCoreTargets
FILE CatkitCoreTargets.cmake
DESTINATION "${SKBUILD_PLATLIB_DIR}/cmake/catkit_core"
)

install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
DESTINATION include
DESTINATION "${SKBUILD_HEADERS_DIR}"
FILES_MATCHING
PATTERN "*.h"
PATTERN "*.inl"
)
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../proto/gen/cpp/
DESTINATION include/catkit_core
install(DIRECTORY "${PROTO_BINARY_DIR}"
DESTINATION "${SKBUILD_HEADERS_DIR}/catkit_core"
FILES_MATCHING
PATTERN "*.h"
)
3 changes: 0 additions & 3 deletions catkit_core/LoggingProxy.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion catkit_core/Service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "Timing.h"
#include "TestbedProxy.h"
#include "Tracing.h"
#include "proto/service.pb.h"
#include "service.pb.h"

#include <chrono>
#include <csignal>
Expand Down
2 changes: 1 addition & 1 deletion catkit_core/ServiceProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "Timing.h"
#include "Service.h"
#include "Util.h"
#include "proto/service.pb.h"
#include "service.pb.h"

#include <iostream>

Expand Down
2 changes: 1 addition & 1 deletion catkit_core/ServiceState.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef SERVICE_STATE_H
#define SERVICE_STATE_H

#include "proto/testbed.pb.h"
#include "testbed.pb.h"

enum ServiceState
{
Expand Down
2 changes: 1 addition & 1 deletion catkit_core/Tensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define TENSOR_H

#include "ComplexTraits.h"
#include "proto/core.pb.h"
#include "core.pb.h"

#include <Eigen/Dense>

Expand Down
2 changes: 1 addition & 1 deletion catkit_core/TestbedProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "Timing.h"
#include "HostName.h"
#include "proto/testbed.pb.h"
#include "testbed.pb.h"

#include <memory>
#include <regex>
Expand Down
2 changes: 1 addition & 1 deletion catkit_core/TestbedProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion catkit_core/Tracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "Timing.h"
#include "Util.h"
#include "Log.h"
#include "proto/tracing.pb.h"
#include "tracing.pb.h"

#include <zmq.hpp>

Expand Down
2 changes: 1 addition & 1 deletion catkit_core/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define TYPES_H

#include "Tensor.h"
#include "proto/core.pb.h"
#include "core.pb.h"

#include <list>
#include <map>
Expand Down
2 changes: 2 additions & 0 deletions catkit_core/cmake/CatkitCoreConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/CatkitCoreTargets.cmake")
Loading
Loading