From e0e6389a9bfd12dd9af360904eae3bc24a652a1c Mon Sep 17 00:00:00 2001 From: FusRoman <46221629+FusRoman@users.noreply.github.com> Date: Fri, 17 Jun 2022 13:17:44 +0200 Subject: [PATCH] Issue/89/orbfit localization (#94) * move the alerts month data from the package data to the data_files in the setup.py * add licence and bash command in the orbfit and python_dependencies script * modify the orbfit_install.sh for users, add an orbfit_install.sh script in the test directory for testing * add possibility to add OrbFit to the environment path * update the orbfit location according to the new installer behavior * update orbfit installer test to add the ORBFIT_HOME path * Bump to 0.7.1 * fix test --- .github/workflows/run_test.yml | 2 +- fink_fat/__init__.py | 2 +- fink_fat/orbit_fitting/orbfit_local.py | 2 +- fink_fat/orbit_fitting/orbfit_merger.py | 2 +- fink_fat/test/orbFit_installer.sh | 50 ++++++++++++++++++++ install_python_deps.sh | 17 ++++++- orbFit_installer.sh | 62 ++++++++++++++++++++++--- run_test.sh | 3 +- setup.py | 4 +- 9 files changed, 130 insertions(+), 14 deletions(-) create mode 100755 fink_fat/test/orbFit_installer.sh diff --git a/.github/workflows/run_test.yml b/.github/workflows/run_test.yml index 83d81a76..4015b33a 100644 --- a/.github/workflows/run_test.yml +++ b/.github/workflows/run_test.yml @@ -30,7 +30,7 @@ jobs: sudo apt-get install python3-testresources - name: install OrbFit SoftWare run: | - ./orbFit_installer.sh + ./fink_fat/test/orbFit_installer.sh - name: Run test suites run: | ./run_test.sh diff --git a/fink_fat/__init__.py b/fink_fat/__init__.py index 3fb942a2..ef3df8e7 100644 --- a/fink_fat/__init__.py +++ b/fink_fat/__init__.py @@ -12,4 +12,4 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.7.0" +__version__ = "0.7.1" diff --git a/fink_fat/orbit_fitting/orbfit_local.py b/fink_fat/orbit_fitting/orbfit_local.py index 1aa63a47..98b32c8a 100644 --- a/fink_fat/orbit_fitting/orbfit_local.py +++ b/fink_fat/orbit_fitting/orbfit_local.py @@ -672,7 +672,7 @@ def call_orbitfit(ram_dir, provisional_designation): >>> os.remove("fink_fat/test/call_orbfit/K21E00A.pro") >>> os.remove("fink_fat/test/call_orbfit/mpcobs/K21E00A.rwo") """ - orbitfit_path = os.path.join("~", "OrbitFit", "bin", "") + orbitfit_path = os.path.join(os.environ["ORBFIT_HOME"], "bin", "") command = ( orbitfit_path + "orbfit.x < " diff --git a/fink_fat/orbit_fitting/orbfit_merger.py b/fink_fat/orbit_fitting/orbfit_merger.py index 5b13f90d..1358f564 100644 --- a/fink_fat/orbit_fitting/orbfit_merger.py +++ b/fink_fat/orbit_fitting/orbfit_merger.py @@ -236,7 +236,7 @@ def call_orbitfit(ram_dir, first_designation, second_designation): >>> os.remove("fink_fat/test/call_orbfit/K21E00A.pro") >>> os.remove("fink_fat/test/call_orbfit/mpcobs/K21E00A.rwo") """ - orbitfit_path = os.path.join("~", "OrbitFit", "bin", "") + orbitfit_path = os.path.join(os.environ["ORBFIT_HOME"], "bin", "") command = ( orbitfit_path + "orbfit.x < " diff --git a/fink_fat/test/orbFit_installer.sh b/fink_fat/test/orbFit_installer.sh new file mode 100755 index 00000000..f58324ff --- /dev/null +++ b/fink_fat/test/orbFit_installer.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# Copyright 2021 Le Montagner Roman +# Author: Le Montagner Roman +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +## Script to install the OrbFit software + +set -e + +ORBLOCATE=~/OrbitFit + +aria2c -x8 http://adams.dm.unipi.it/orbfit/OrbFit5.0.7.tar.gz + +if [[ ! -d $ORBLOCATE ]] +then + echo "OrbitFit/ directory does not exists on your filesystem." + mkdir $ORBLOCATE +fi + +tar -xf OrbFit5.0.7.tar.gz -C $ORBLOCATE + +rm OrbFit5.0.7.tar.gz + +cd $ORBLOCATE + +./config -O gfortran + +make + +cd lib/ + +aria2c -x8 https://ssd.jpl.nasa.gov/ftp/eph/planets/Linux/de440/linux_p1550p2650.440 + +mv linux_p1550p2650.440 jpleph + +echo "export ORBFIT_HOME=${ORBLOCATE}" >> ~/.bash_profile + +source ~/.bash_profile + +echo "OrbFit installation done, location is ${ORBLOCATE}" \ No newline at end of file diff --git a/install_python_deps.sh b/install_python_deps.sh index 9ff7b89f..60e54785 100644 --- a/install_python_deps.sh +++ b/install_python_deps.sh @@ -1,4 +1,19 @@ -#!bin/bash +#!/bin/bash +# Copyright 2021 Le Montagner Roman +# Author: Le Montagner Roman +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +## Script to install python dependencies set -e diff --git a/orbFit_installer.sh b/orbFit_installer.sh index 4880af0c..06ea7ec6 100755 --- a/orbFit_installer.sh +++ b/orbFit_installer.sh @@ -1,12 +1,58 @@ -ORBLOCATE=~/OrbitFit +#!/bin/bash +# Copyright 2021 Le Montagner Roman +# Author: Le Montagner Roman +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +## Script to install the OrbFit software + +set -e + +while true; do + read -p "Do you wish to install this program in your HOME? [yes/no]" yn + case $yn in + [Yy]* ) + echo "program will be installed in ${HOME}/OrbitFit"; + ORBLOCATE=${HOME}/OrbitFit; + if [[ ! -d $ORBLOCATE ]]; then + mkdir $ORBLOCATE + fi + break;; + [Nn]* ) + while true; do + read -p "Enter the OrbFit installation path =" ORBLOCATE; + if [[ -d ${ORBLOCATE} ]]; then + echo "${ORBLOCATE} is a directory"; + break; + else + while true; do + read -p "The path ${ORBLOCATE} does not exist, do you wish to create it? [yes/no]" yn2 + case $yn2 in + [Yy]* ) mkdir -p ${ORBLOCATE}; break;; + [Nn]* ) echo "abort installation"; exit;; + * ) echo "Please answer yes or no.";; + esac + done + break + fi + done + break;; + * ) echo "Please answer yes or no.";; + esac +done + aria2c -x8 http://adams.dm.unipi.it/orbfit/OrbFit5.0.7.tar.gz -if [[ ! -d $ORBLOCATE ]] -then - echo "OrbitFit/ directory does not exists on your filesystem." - mkdir $ORBLOCATE -fi tar -xf OrbFit5.0.7.tar.gz -C $ORBLOCATE @@ -23,3 +69,7 @@ cd lib/ aria2c -x8 https://ssd.jpl.nasa.gov/ftp/eph/planets/Linux/de440/linux_p1550p2650.440 mv linux_p1550p2650.440 jpleph + +echo "export ORBFIT_HOME=${ORBLOCATE}" >> ~/.bash_profile + +echo "OrbFit installation done, location is ${ORBLOCATE}" \ No newline at end of file diff --git a/run_test.sh b/run_test.sh index 97009bc3..416f9935 100755 --- a/run_test.sh +++ b/run_test.sh @@ -17,11 +17,10 @@ set -e +source ~/.bash_profile export ROOTPATH=`pwd` export COVERAGE_PROCESS_START="${ROOTPATH}/.coveragerc" -set -e - python -m pip install . # Run the test suite diff --git a/setup.py b/setup.py index 82585014..f46f3a64 100644 --- a/setup.py +++ b/setup.py @@ -19,12 +19,14 @@ packages=find_packages(), package_data={ "fink_fat": [ - "data/month=*", "data/fink_fat.conf", "orbit_fitting/AST17.*", "orbit_fitting/template.oop", ] }, + data_files=[ + ("fink_fat/data", ["fink_fat/data/month=03"]) + ], install_requires=[ "docopt>=0.6.2", "terminaltables>=3.1.10",