Skip to content

Swig init #37

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

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
fb5fd91
Update enums to 'enum class' inheriting from 'unsigned int'
Jvinniec Aug 18, 2019
528c533
Add first set of SWIG files
Jvinniec Aug 19, 2019
85a27c8
Update version number for development
Jvinniec Aug 19, 2019
72c2d27
Exclude .so files from being installed in the lib directory
Jvinniec Aug 21, 2019
83b0389
Add doxygen class description for CEExecOptions
Jvinniec Aug 21, 2019
88032ae
Add license information to all CMakeLists.txt files
Jvinniec Oct 10, 2019
9228611
Generate more informative doc strings
Jvinniec Oct 17, 2019
bc84aa1
Update swig files and update build
Jvinniec Oct 17, 2019
cee6c4f
Add CEBase class that all classes inherit from
Jvinniec Oct 17, 2019
604d8e4
Add 'ClassName' and 'describe' methods for each class
Jvinniec Oct 17, 2019
efaf78c
Update planetephem executable to use CEPlanet::describe
Jvinniec Oct 17, 2019
c558b67
Add 'CEDate::ReturnType' method.
Jvinniec Oct 17, 2019
627de17
Add ability to control whether corrections are used
Jvinniec Oct 17, 2019
9aaacfe
Rename 'AngularSeparation' methods
Jvinniec Oct 17, 2019
9cccc77
Add 'CETime::HmsStr' method
Jvinniec Oct 17, 2019
ab5f24a
Replace angular separation method in 'angsep'
Jvinniec Oct 17, 2019
66953d1
Add correction control methods to CENamespace.i
Jvinniec Oct 17, 2019
886029a
Update ChangeLog
Jvinniec Oct 18, 2019
e9e1093
Update swig build.
Jvinniec Aug 4, 2020
6771ac8
Update documentation in CEAngle & cppephem.i SWIG files
Jvinniec Oct 28, 2020
88a2e0b
Update linux dist to latest
Jvinniec Oct 28, 2020
d34d238
Update OSX images to be tested to latest versions
Jvinniec Oct 28, 2020
dd3b454
Fix typo stating 45 deg was equal to pi/2
Jvinniec Nov 16, 2020
d47266b
Fix deprecated 'matrix' parameter with 'jobs' parameter
Jvinniec Nov 16, 2020
bc9ff63
Fix build so python wrappers are installed at the appropriate stage
Jvinniec Nov 16, 2020
3bc4c21
Fix build to require SWIG >4
Jvinniec Nov 16, 2020
8b37cc2
Add preliminary Python Tests
Jvinniec Nov 16, 2020
05cab6e
Force use of Python 3.5 or later
Jvinniec Nov 16, 2020
5a4ef79
Update README.md to reflect added Python-binding functionality
Jvinniec Nov 16, 2020
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
33 changes: 25 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,54 @@ branches:
- gh-pages

# Establish which builds we wish to test
matrix:
jobs:
include:
# Test Linux with GCC
- os: linux
dist: focal
compiler: gcc
before_install:
- sudo apt-get install -y swig

# Test Linux with Clang
- os: linux
dist: focal
compiler: clang
before_install:
- sudo apt-get install -y swig

# Test OSX with GCC
- os: osx
compiler: gcc
addons:
homebrew:
packages:
- swig
update: true

# Test OSX with previous Clang
- os: osx
compiler: clang
osx_image: xcode9.4
osx_image: xcode11.6
addons:
homebrew:
packages:
- swig
update: true

# Test OSX with Clang (latest version)
- os: osx
compiler: clang
osx_image: xcode10.2


# Allow compiling with c++11
dist: xenial
osx_image: xcode12.2
addons:
homebrew:
packages:
- swig
update: true

# Build steps
script:
- cmake -Dcoverage=1 ./
- cmake -Dcoverage=1 -Dpython-bindings=1 ./
- cmake --build .
- cmake --build . --target test

Expand Down
39 changes: 32 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,40 @@
#**************************************************************************
# CMakeLists.txt: CppEphem *
# ----------------------------------------------------------------------- *
# Copyright © 2016-2019 JCardenzana *
# ----------------------------------------------------------------------- *
# *
# This program is free software: you can redistribute it and/or modify *
# it under the terms of the GNU General Public License as published by *
# the Free Software Foundation, either version 3 of the License, or *
# (at your option) any later version. *
# *
# This program is distributed in the hope that it will be useful, *
# but WITHOUT ANY WARRANTY; without even the implied warranty of *
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# GNU General Public License for more details. *
# *
# You should have received a copy of the GNU General Public License *
# along with this program. If not, see <http://www.gnu.org/licenses/>. *
# *
#**************************************************************************

cmake_minimum_required (VERSION 3.0)
project (CppEphem)
set(CMAKE_BUILD_TYPE Release)
#set(CMAKE_VERBOSE_MAKEFILE ON)
#set(CMAKE_VERBOSE_MAKEFILE ON) # This enables verbose printing during build

# Add Version number
set (CppEphem_VERSION_MAJOR 1)
set (CppEphem_VERSION_MINOR 3)
set (CppEphem_VERSION_PATCH 0)
set (CppEphem_VERSION_PATCH 99)
set (cppephem_version "${CppEphem_VERSION_MAJOR}.${CppEphem_VERSION_MINOR}.${CppEphem_VERSION_PATCH}")
message ("\nCOMPILING CPPEPHEM VERSION ${cppephem_version}\n")

# Set SWIG policies
cmake_policy(SET CMP0086 NEW)
cmake_policy(SET CMP0078 NEW)

# Set some flags necessary for the MAC OS builds
if (CMAKE_SYSTEM_NAME MATCHES Darwin)
set(CMAKE_MACOSX_RPATH 1)
Expand Down Expand Up @@ -39,9 +64,6 @@ set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build/bin)
set (CPPEPHEM_SHARE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build/share/cppephem)
set (HEADER_OUTPUT_PATH ${CMAKE_BINARY_DIR}/build/include)

# Define some of the default compiler flags
#set (CMAKE_CXX_FLAGS "-std=c++11 ${CMake_CXX_FLAGS}")

# Define the sofa directory
set (SOFA_DIRECTORY ${CMAKE_SOURCE_DIR}/sofa/src)
if (sofa)
Expand Down Expand Up @@ -98,7 +120,6 @@ enable_testing ()
add_subdirectory (cppephem)
add_subdirectory (test)


#-------------------------------------------

# Define installation directories
Expand All @@ -120,9 +141,13 @@ install(DIRECTORY ${CPPEPHEM_SHARE_OUTPUT_DIRECTORY}
install(DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
USE_SOURCE_PERMISSIONS
DESTINATION ${CMAKE_INSTALL_PREFIX}
PATTERN "libtest*" EXCLUDE)
PATTERN "libtest*" EXCLUDE
PATTERN "_*.so" EXCLUDE)

install(DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
USE_SOURCE_PERMISSIONS
DESTINATION ${CMAKE_INSTALL_PREFIX}
PATTERN "test*" EXCLUDE)

# Install Python stuff
install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/cppephem/swig/pyext/setup.py install --prefix=${CMAKE_INSTALL_PREFIX} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/cppephem/swig/pyext/)")
7 changes: 7 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to the CppEphem package will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## v1.3.99 : DEVELOPMENT
- Add SWIG wrappers for Python bindings
- Fix ambiguity in CESkyCoord::AngularSeparation methods
- Updated Travis-CI build configuration
- Updated SOFA to latest release (2019-07)


## v1.3.0 : 2019-08-19
- Add executable 'convcoord' for converting between any coordinate systems
- Add support for Ecliptic coordinates [#18]
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Once the code is downloaded, the advised method for compiling the code is via `c
2. Now run `cmake` with your desired configuration options to build the code:
```bash
# configure
cmake [-DCMAKE_INSTALL_PREFIX=/your/install/directory/] /path/to/cloned/CppEphem
cmake [-Dpython-bindings=1] [-DCMAKE_INSTALL_PREFIX=/your/install/directory/] /path/to/cloned/CppEphem
# build (N = number of threads for compilation)
cmake --build . [-- -jN]
```
Expand All @@ -115,9 +115,12 @@ installation directories (or alternatively the directory specified in
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/install/dir/lib
```

## Support for Python (*experimental*)
Python bindings can also be generated that allow running the code within Python. This can be done by adding `-Dpython-bindings=1` in the cmake configuration (step 2 above). Note that this requires SWIG (v4 or greater) and Python (v3.5 or greater) to be installed on your system.


## Autotools Build
**NOTE:** *The code has grown to a point where it is no longer feasible to maintain two build systems. Because of this, it has been decided to deprecate the autotools build system and remove it completely in a future version.*
**NOTE:** *The code has grown to a point where it is no longer feasible to maintain two build systems. Because of this, it has been decided to deprecate the autotools build system and remove it completely in a future version. It is not guaranteed to work.*

To install via autotools, you should be able to build the software
very easily using the standard "./configure -> make -> make install"
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dnl DONT FORGET TO CHANGE THE VERSION!

m4_define([CppEphem_VERSION_MAJOR], [1])
m4_define([CppEphem_VERSION_MINOR], [3])
m4_define([CppEphem_VERSION_PATCH], [0])
m4_define([CppEphem_VERSION_PATCH], [99])
m4_define([cppephem_version],
[CppEphem_VERSION_MAJOR.CppEphem_VERSION_MINOR.CppEphem_VERSION_PATCH])

Expand Down
23 changes: 23 additions & 0 deletions cppephem/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
#**************************************************************************
# cppephem/CMakeLists.txt: CppEphem *
# ----------------------------------------------------------------------- *
# Copyright © 2019 JCardenzana *
# ----------------------------------------------------------------------- *
# *
# This program is free software: you can redistribute it and/or modify *
# it under the terms of the GNU General Public License as published by *
# the Free Software Foundation, either version 3 of the License, or *
# (at your option) any later version. *
# *
# This program is distributed in the hope that it will be useful, *
# but WITHOUT ANY WARRANTY; without even the implied warranty of *
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# GNU General Public License for more details. *
# *
# You should have received a copy of the GNU General Public License *
# along with this program. If not, see <http://www.gnu.org/licenses/>. *
# *
#**************************************************************************

#------------------------------------------
# Define include directories
Expand All @@ -13,6 +33,7 @@ include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include
#------------------------------------------
set (cppephem_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/CENamespace.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/CEBase.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/CEAngle.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/CEBody.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/CECoordinates.cpp
Expand All @@ -30,6 +51,7 @@ set (cppephem_SOURCES
set (cppephem_HEADERS
include/CppEphem.h
include/CENamespace.h
include/CEBase.h
include/CEAngle.h
include/CEBody.h
include/CECoordinates.h
Expand Down Expand Up @@ -72,3 +94,4 @@ set (testcppephem_SOURCES ${cppephem_SOURCES} PARENT_SCOPE)
add_subdirectory (test)
add_subdirectory (src)
add_subdirectory (exec)
add_subdirectory (swig)
20 changes: 20 additions & 0 deletions cppephem/exec/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
#**************************************************************************
# cppephem/exec/CMakeLists.txt: CppEphem *
# ----------------------------------------------------------------------- *
# Copyright © 2019 JCardenzana *
# ----------------------------------------------------------------------- *
# *
# This program is free software: you can redistribute it and/or modify *
# it under the terms of the GNU General Public License as published by *
# the Free Software Foundation, either version 3 of the License, or *
# (at your option) any later version. *
# *
# This program is distributed in the hope that it will be useful, *
# but WITHOUT ANY WARRANTY; without even the implied warranty of *
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# GNU General Public License for more details. *
# *
# You should have received a copy of the GNU General Public License *
# along with this program. If not, see <http://www.gnu.org/licenses/>. *
# *
#**************************************************************************

#------------------------------------------
# Define include directories
Expand Down
5 changes: 1 addition & 4 deletions cppephem/exec/planetephem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,7 @@ void PrintEphemeris(CEObservation& obs,

// Print some basic information regarding the planet itself
std::printf("= PLANET =====================\n");
std::printf(" Name : %s\n", planet->Name().c_str());
std::printf(" Mass : %e kg\n", planet->Mass_kg());
std::printf(" Radius: %f km\n", planet->Radius_m()/1000.0);
std::printf(" Albedo: %f\n\n", planet->Albedo());
std::printf("%s\n\n", planet->describe().c_str());

std::vector<double> ra;
std::vector<double> dec;
Expand Down
33 changes: 25 additions & 8 deletions cppephem/include/CEAngle.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,20 @@
#include <string>
#include <vector>

#include "CEBase.h"
#include "CENamespace.h"

enum class CEAngleType
{
DEGREES=0,
RADIANS=1,
HMS=2,
DMS=3
/**********************************************************************//**
* Angle type enum
*************************************************************************/
enum class CEAngleType : unsigned int {
DEGREES=0, ///< Degrees
RADIANS=1, ///< Radians
HMS=2, ///< Hours, minutes, seconds
DMS=3 ///< Degrees, arcmin, arcsec
};

class CEAngle {
class CEAngle : public CEBase {
public:
// Constructors
CEAngle();
Expand Down Expand Up @@ -79,6 +82,10 @@ class CEAngle {
void SetAngle(const std::vector<double>& angle_vec,
const CEAngleType& angle_type);

// Necessary methods
const std::string ClassName(void) const;
const std::string describe(void) const;

private:

// Methods
Expand All @@ -94,4 +101,14 @@ class CEAngle {

};

#endif /* CEAngle_h */

/**********************************************************************//**
* Return name of this class
*************************************************************************/
inline
const std::string CEAngle::ClassName() const
{
return std::string("CEAngle");
}

#endif /* CEAngle_h */
39 changes: 39 additions & 0 deletions cppephem/include/CEBase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/***************************************************************************
* CEBase.h: CppEphem *
* ----------------------------------------------------------------------- *
* Copyright © 2019 JCardenzana *
* ----------------------------------------------------------------------- *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
***************************************************************************/

#ifndef CEBase_h
#define CEBase_h

#include <string>
#include <vector>

class CEBase {
public:
// Constructors
CEBase();
virtual ~CEBase();

virtual const std::string ClassName(void) const = 0;
virtual const std::string describe(void) const;

};

#endif /* CEBase_h */
14 changes: 14 additions & 0 deletions cppephem/include/CEBody.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ class CEBody : public CESkyCoord {
std::string Name(void) const;
void SetName(const std::string& new_name);

// Necessary methods
const std::string ClassName(void) const;
virtual const std::string describe(void) const;

private:

/************************************
Expand All @@ -86,6 +90,16 @@ class CEBody : public CESkyCoord {
};


/**********************************************************************//**
* Return name of this class
*************************************************************************/
inline
const std::string CEBody::ClassName() const
{
return std::string("CEBody");
}


/**********************************************************************//**
* Get the name of this object
*
Expand Down
Loading