Skip to content

Commit

Permalink
Reverting to fully automated install
Browse files Browse the repository at this point in the history
  • Loading branch information
tjakobi committed Jul 17, 2018
1 parent 222b3f9 commit ceb8e0a
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 125 deletions.
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
numpy>=1.14.5
pybedtools>=0.7.10
statsmodels>=0.8.0
biopython >= 1.71
16 changes: 11 additions & 5 deletions scripts/install_add_to_bashrc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@
# this make circtools callable for the user

# are we running in an virtual environment?
if [ $VIRTUAL_ENV ]; then
echo "export PATH=\$PATH:$VIRTUAL_ENV/bin" >> ~/.bashrc
else
echo "export PATH=\$PATH:~/.local/bin" >> ~/.bashrc
fi

CIRCTOOLS=`grep circtools ~/.bashrc`

if [ ! "$CIRCTOOLS" ]; then

if [ $VIRTUAL_ENV ]; then
echo "export PATH=\$PATH:$VIRTUAL_ENV/bin" >> ~/.bashrc
else
echo "export PATH=\$PATH:~/.local/bin" >> ~/.bashrc
fi
fi
5 changes: 4 additions & 1 deletion scripts/install_create_r_environ.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

# this is a workaround in order to be able to install R packages as regular user
echo "R_LIBS=~/.R/" >> ~/.Renviron

if [ ! -f ~/.Renviron ]; then
echo "R_LIBS=~/.R/" >> ~/.Renviron
fi
64 changes: 15 additions & 49 deletions scripts/install_external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function install_bedtools {
cp -av bin/* $HOME/.local/bin/
# mkdir -p $HOME/.local/share/bedtools/
# cp genomes -av $HOME/.local/share/bedtools/
rm /tmp/bedtools2 -rf
# rm /tmp/bedtools2 -rf
}

# install statsmodels first, does not work in setup.py due to
Expand All @@ -44,60 +44,26 @@ if [ $BEDTOOLS ]; then

# we want to have >= 27 in order to work correctly
if [ "$VERSION" -lt "27" ]; then
echo "bedtools major version is < 26. Installation of bedtools >= 2.27 recommended."
read -p "Install now [Y/N]" -n 1 -r
echo # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
[[ "$0" = "$BASH_SOURCE" ]] || return 1 # handle exits from shell or function but don't exit interactive shell
else
install_bedtools
fi
else
echo "Found recent bedtools version, skipping installation"
[[ "$0" = "$BASH_SOURCE" ]] || return 1
fi
else
read -p "No installation of bedtools found in \$PATH. Install now? [Y/N]" -n 1 -r
echo # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
[[ "$0" = "$BASH_SOURCE" ]] || return 1 # handle exits from shell or function but don't exit interactive shell
else
install_bedtools
fi
else
install_bedtools
fi

# are we running in an virtual environment?
if [ $VIRTUAL_ENV ]; then

# install DCC
cd /tmp/
git clone https://github.com/dieterich-lab/DCC.git
cd DCC
python setup.py install
# install DCC
cd /tmp/
git clone https://github.com/dieterich-lab/DCC.git
cd DCC
python2 setup.py install --user

# install FUCHS
cd ..
git clone https://github.com/dieterich-lab/FUCHS.git
cd FUCHS
python setup.py install
# install FUCHS
cd ..
git clone https://github.com/dieterich-lab/FUCHS.git
cd FUCHS
python2 setup.py install --user

else
# install DCC
cd /tmp/
git clone https://github.com/dieterich-lab/DCC.git
cd DCC
python setup.py install --user

# install FUCHS
cd ..
git clone https://github.com/dieterich-lab/FUCHS.git
cd FUCHS
python setup.py install --user
fi

# remove all temporary files
rm /tmp/FUCHS/ -rf
rm /tmp/DCC/ -rf
#rm /tmp/FUCHS/ -rf
#rm /tmp/DCC/ -rf

88 changes: 19 additions & 69 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from setuptools.command.install import install
from setuptools import setup, find_packages

import sys


def query_yes_no(question, default="yes"):
"""Ask a yes/no question via raw_input() and return their answer.
Expand Down Expand Up @@ -60,82 +62,28 @@ class PostInstallCommand(install):
def run(self):

import subprocess
import os
import time

if not os.environ.get('READTHEDOCS') == 'True':

# step 1: create .Renviron file

print("==============================================")
print(" _ _ ")
print(" (_) _ | | ")
print(" ____ _ ____ ____ _| |_ ___ ___ | | ___ ")
print(" / ___) |/ ___) ___|_ _) _ \ / _ \| | /___)")
print("( (___| | | ( (___ | || |_| | |_| | ||___ |")
print(" \____)_|_| \____) \__)___/ \___/ \_|___/ ")
print(" ")
print("==============================================")
print("")
print("Following are a few questions finalize the setup of circtools on this machine.")
print("")
print("==============================================")
print("")

print("Should we update the R package location in order to install package as user?")

answer = query_yes_no("Update R_LIB in .Renviron")
if answer:
print("Running update script...")
subprocess.check_call(["bash", "scripts/install_create_r_environ.sh"])
else:
print("Okay. If the R library path is not writeable the installation will most probably fail.")

print("")

# step 2: install DCC, FUCHS and primer design R module
print("We need to install two other programs of the Dieterich Lab circRNA suit, DCC and FUCHS, as well "
"as R package dependencies for other modules of circtools")
print("We'll install everything for you from GitHub and CRAN for you.")
print("")
print("In order for the circtools primer design module to run, we need to install some R modules.")
print("Please make sure R >= 3.3.3 is installed and your R library path is writeable .")
print("")

answer = query_yes_no("Do you want to continue the automatic dependency installation?\n"
"-> \"n\" will only install the circtools base package\n"
"-> CTRL-C will abort the installation\n")
if answer:

print("Installing DCC, FUCHS, bedtools and R packages.")
print("This might take a few minutes.")
print("You might to get a coffee or tee.", flush=True)
time.sleep(5)
print("Starting now.", flush=True)

subprocess.check_call(["bash", "scripts/install_external.sh"])

# step 3: update $PATH
print("In order for circtools to be globally callable, we would add the installation"
" folder to the $PATH variable. Would you like us to do that?")

answer = query_yes_no("Update $PATH in .bashrc?")
if answer:
print("Running update script...")
subprocess.check_call(["bash", "scripts/install_add_to_bashrc.sh"])
else:
print("Okay. Please update the $PATH variable yourself, "
"otherwise you may not be able to run circtools.")
print("")

subprocess.check_call(["bash", "scripts/install_create_r_environ.sh"])
subprocess.check_call(["bash", "scripts/install_external.sh"])
subprocess.check_call(["bash", "scripts/install_add_to_bashrc.sh"])

install.run(self)
# place for post install commands


here = path.abspath(path.dirname(__file__))

if sys.version_info.major < 3:
sys.exit('\n'
'Sorry, Python 2 is not supported\n'
'Did you run pip install circtools?\n'
'Try \'pip3 install circtools\'')

elif sys.version_info.minor < 4:
sys.exit('\nSorry, Python < 3.4 is not supported\n')

# Get the long description from the relevant file
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
with open(path.join(here, 'README.rst')) as f:
long_description = f.read()

setup(
Expand All @@ -144,7 +92,7 @@ def run(self):
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version='1.1.0-beta',
version='1.1.0',

description='circtools - a circular RNA toolbox',
long_description=long_description,
Expand Down Expand Up @@ -212,6 +160,8 @@ def run(self):
'biopython >= 1.71'
],

python_requires='>=3.4',

# List additional groups of dependencies here (e.g. development
# dependencies). You can install these using the following syntax,
# for example:
Expand Down

0 comments on commit ceb8e0a

Please sign in to comment.