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

added findfeaturesSegment script #5091

Merged
merged 21 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from 17 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
2 changes: 2 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ pipeline {
cd $WORKSPACE/isis/pytests
pytest .

cd $WORKSPACE/isis/python_bindings/tests
pytest .
Comment on lines +120 to +121
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added the tests to jenkins

'''
}
}
Expand Down
2 changes: 2 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ channels:
- defaults

dependencies:
- kalasiris
- ale=0.9.1
- armadillo
- boost=1.72
Expand Down Expand Up @@ -48,6 +49,7 @@ dependencies:
- opencv>=4.5.2
- openssl>=1.1.1k
- pcl >= 1.10.0
- plio
- protobuf<3.20
- python>=3.7.11
- pytest
Expand Down
9 changes: 4 additions & 5 deletions isis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ option(buildMissions "Build the mission specific modules" ON )
option(buildStaticCore "Build libisis static as well as dynamic" OFF )
option(buildTests "Set up unit, application, and module tests." ON )
option(JP2KFLAG "Whether or not to build using JPEG2000 support" OFF )
option(pybindings "Turn on to build Python bindings" OFF )
option(pybindings "Turn on to build Python bindings" ON )

# if cmake install prefix is not set, and conda env is activated, use the
# conda env as the install directory.
Expand Down Expand Up @@ -309,10 +309,6 @@ if(APPLE)
find_package(OpenGL REQUIRED)
endif(APPLE)

if(pybindings)
find_package(Python REQUIRED)
endif()

# Iterate through all variables and extract the libraries and include directories
get_cmake_property(_variableNames VARIABLES) # Get All VARIABLES

Expand Down Expand Up @@ -378,6 +374,9 @@ include_directories(${CMAKE_BINARY_DIR}/inc)
set(CORE_LIB_NAME isis)
message(STATUS "CORE LIB: ${CORE_LIB_NAME}")

if(pybindings)
add_subdirectory(python_bindings)
endif()

# Specify relative library include paths which will be set up on
# the installed files.
Expand Down
1 change: 0 additions & 1 deletion isis/cmake/AddIsisModule.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ include(CodeGeneration)

# Incorporate an application folder
function(add_isis_app folder libDependencies)

# The internal build name will be different than the output name
# - This deals with problems compiling same-named targets on case-insensitive machines.
get_filename_component(appName ${folder} NAME)
Expand Down
49 changes: 49 additions & 0 deletions isis/python_bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
cmake_minimum_required(VERSION 3.14)

# Setup for SWIG
set(CMAKE_SWIG_FLAGS)
find_package(SWIG REQUIRED)
include(UseSWIG)
list(APPEND CMAKE_SWIG_FLAGS "-py3;-DPY3")

message(STATUS "SWIG flags: " ${CMAKE_SWIG_FLAGS} )

# Setup for Python linking
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)

# Setup for wrapper library
set(ASTROSET_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/astroset")
set(ASTROSET_SOURCES astroset.i
UserInterface.i
)

set(ASTROSET_APPS apps/)

set_source_files_properties(${ASTROSET_SOURCES} PROPERTIES CPLUSPLUS ON)
swig_add_library(astroset
LANGUAGE python
SOURCES ${ASTROSET_SOURCES}
OUTPUT_DIR ${ASTROSET_OUTPUT_DIR})
swig_link_libraries(astroset isis Python3::Module)
set_target_properties(astroset PROPERTIES SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE)
set_target_properties(astroset PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${ASTROSET_OUTPUT_DIR})

# Create the files to install the Python wrapper
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in
${CMAKE_CURRENT_BINARY_DIR}/setup.py)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/__init__.py
${ASTROSET_OUTPUT_DIR}/__init__.py
COPYONLY)

file(COPY ${ASTROSET_APPS}
DESTINATION
${ASTROSET_OUTPUT_DIR}/apps/)

set(ASTROSET_APP_XML_FILES "apps/findFeaturesSegment/findFeaturesSegment.xml")
file(COPY ${ASTROSET_APP_XML_FILES} DESTINATION ${CMAKE_BINARY_DIR}/bin/xml/ )
install(FILES ${ASTROSET_APP_XML_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/xml/)

# Setup to run setup tools on install
install(CODE "execute_process(COMMAND $ENV{CONDA_PREFIX}/bin/pip install ${CMAKE_CURRENT_BINARY_DIR}/ --prefix=${CMAKE_INSTALL_PREFIX}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})")

42 changes: 42 additions & 0 deletions isis/python_bindings/UserInterface.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
%module(package="astroset") UserInterface


%{
#include "Gui.h"
#include "Pvl.h"
#include "UserInterface.h"
%}

%include <QVector>
%include <QString>

// Rename the constructors to Python-friendly names
%rename(UserInterfaceFromArgsv) UserInterface(const QString &xmlfile, int &argc, char *argv[]);
%rename(UserInterfaceFromList) UserInterface(const QString &xmlfile, QVector<QString> &args);

%rename(GetFileName) IsisAml::GetFileName(QString const &) const;
%rename(GetFileNameWithExt) IsisAml::GetFileName(QString const &, QString) const;
%rename(GetFileNames) IsisAml::GetFileName(QString const &, std::vector<QString> &) const;

%rename(GetAsString) IsisAml::GetAsString(QString const &) const;
%rename(GetAsStrings) IsisAml::GetAsString(QString const &, std::vector<QString> &) const;

%rename(GetString) IsisAml::GetString(QString const &) const;
%rename(GetStrings) IsisAml::GetString(QString const &, std::vector<QString> &) const;

%rename(GetCubeNameWithExt) IsisAml::GetCubeName(QString const &,QString) const;
%rename(GetCubeName) IsisAml::GetCubeName(QString const &) const;

%rename(GetInteger) IsisAml::GetInteger(const QString &) const;
%rename(GetIntegers) IsisAml::GetInteger(const QString &, std::vector<int> &) const;

%rename(GetDouble) IsisAml::GetDouble(const QString &) const;
%rename(GetDoubles) IsisAml::GetDouble(const QString &, std::vector<int> &) const;

%rename(GetBoolean) IsisAml::GetBoolean(const QString &) const;
%rename(GetBooleans) IsisAml::GetBoolean(const QString &, std::vector<bool> &) const;

%include "Pvl.h"
%include "IsisAml.h"
%include "UserInterface.h"

22 changes: 22 additions & 0 deletions isis/python_bindings/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from .astroset import *

from pathlib import Path
import os

try:
ISISROOT = Path(os.environ["ISISROOT"])
except KeyError:
raise EnvironmentError("Please set ISISROOT before importing anything")

def init_application(args):
appname = os.path.basename(args[0])
args = args[1:]

xmlpath = Path(appname).with_suffix(".xml")
if not xmlpath.exists() or not xmlpath.is_file():
xmlpath = ISISROOT / "bin" / "xml" / xmlpath
print(xmlpath)
if not xmlpath.exists():
raise FileExistsError(f"{appname} does not have an XML file")

return UserInterfaceFromList(str(xmlpath), args)
1 change: 1 addition & 0 deletions isis/python_bindings/apps/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import findFeaturesSegment
Empty file.
Loading