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

Conda installation of core library #276

Draft
wants to merge 19 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 2 additions & 4 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 @@ -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)
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 ..
```
```
120 changes: 120 additions & 0 deletions catkit2-core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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($<$<CXX_COMPILER_ID:MSVC>:/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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include>
)

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 "$<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 "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)
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 All @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions catkit2-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")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions catkit2-core/recipe/bld.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mkdir build
cd build

cmake .. -A x64
cmake --build . --config Release
cmake --install . --prefix %PREFIX%
8 changes: 8 additions & 0 deletions catkit2-core/recipe/build.sh
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions catkit2-core/recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion catkit_core/Service.cpp → catkit2-core/src/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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion catkit_core/Tensor.h → catkit2-core/src/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
File renamed without changes.
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
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
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion catkit_core/Tracing.cpp → catkit2-core/src/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
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion catkit_core/Types.h → catkit2-core/src/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
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading
Loading