Skip to content

Commit

Permalink
Merge pull request #305 from david-castillo/master
Browse files Browse the repository at this point in the history
Changes in setup for pip install
  • Loading branch information
david-castillo authored Jan 31, 2020
2 parents a087f5e + 75faa91 commit 8688b42
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 45 deletions.
5 changes: 2 additions & 3 deletions _pytadbit/tools/tadbit_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,9 @@ def run(opts):
decay_corr_fig = 'None'
eigen_corr_dat = 'None'
eigen_corr_fig = 'None'
valid_pairs1 = 0
valid_pairs2 = 0
masked1 = masked2 = {}

corr = eig_corr = 0
corr = eig_corr = scc = std = reprod = 0
bads = {}

# merge inputs
Expand Down
95 changes: 53 additions & 42 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env python

from setuptools.command.install import install
from distutils.core import setup, Extension
from os import path, system
from re import sub
from subprocess import Popen, PIPE
from distutils.spawn import find_executable
from argparse import ArgumentParser
import sys
# import os
# os.environ["CC"] = "g++"
Expand All @@ -30,13 +30,58 @@
"Topic :: Software Development :: Libraries :: Python Modules",
]

parser = ArgumentParser(usage="%(prog)s -f")
from setuptools.command.install import install

parser.add_argument('-f', '--force', dest='force', action='store_true',
default=False, help='bypass requirement prompts')

opts, unknown = parser.parse_known_args()
sys.argv = [sys.argv[0]] + unknown
class InstallCommand(install):
user_options = install.user_options + [
('bypasscheck', None, 'Bypass checks for optional requirements'),
]

PYTHON_DEPENDENCIES = [
["numpy" , "Numpy is required arrays, 1 dimensional interpolation and polynomial fit.", 1],
["scipy" , "Required for clustering and interpolation.", 1],
["matplotlib", "Required fot displaying plots.", 0],
["IMP" , "Required for 3D modeling.", 0]]

def initialize_options(self):
install.initialize_options(self)
self.bypasscheck = False

def finalize_options(self):
print("value of bypasscheck is", self.bypasscheck)
install.finalize_options(self)

def run(self):

missing = False
if not self.bypasscheck:
print("Checking dependencies...")
for mname, msg, ex in self.PYTHON_DEPENDENCIES:
if not can_import(mname):
print(" *", mname, "cannot be found in your python installation.")
print(" ->", msg)
if ex:
missing=True
else:
print ("\n However, you can still install Tadbit and " +
"try to fix it afterwards.")
if ask( " -> Do you want to continue with the installation?",
["y", "n"]) == "n":
exit()
if missing:
exit("Essential dependencies missing, please review and install.\n")

# check if MCL is installed
if not self.bypasscheck and not find_executable('mcl'):
print('\nWARNING: It is HIGHLY RECOMMENDED to have MCL installed ' +
'(which do not seems to be).\nIf you are under Debian/Ubuntu' +
' just run "apt-get-install mcl".')
follow = raw_input('\n You still have the option to follow with the ' +
'installation. Do you want to follow? [y/N]')
if follow.upper() != 'Y' :
exit('\n Wise choice :)\n')
install.run(self)

def can_import(modname):
'Test if a module can be imported '
Expand All @@ -62,43 +107,8 @@ def ask(string, valid_values, default=-1, case_sensitive=False):


PATH = path.abspath(path.split(path.realpath(__file__))[0])
PYTHON_DEPENDENCIES = [
["numpy" , "Numpy is required arrays, 1 dimensional interpolation and polynomial fit.", 1],
["scipy" , "Required for clustering and interpolation.", 1],
["matplotlib", "Required fot displaying plots.", 0],
["IMP" , "Required for 3D modeling.", 0]]

missing = False
if not opts.force:
print("Checking dependencies...")
for mname, msg, ex in PYTHON_DEPENDENCIES:
if not can_import(mname):
print(" *", mname, "cannot be found in your python installation.")
print(" ->", msg)
if ex:
missing=True
else:
print ("\n However, you can still install Tadbit and " +
"try to fix it afterwards.")
if ask( " -> Do you want to continue with the installation?",
["y", "n"]) == "n":
exit()

if missing:
exit("Essential dependencies missing, please review and install.\n")


def main():
# check if MCL is installed
if not opts.force and not find_executable('mcl'):
print('\nWARNING: It is HIGHLY RECOMMENDED to have MCL installed ' +
'(which do not seems to be).\nIf you are under Debian/Ubuntu' +
' just run "apt-get-install mcl".')
follow = raw_input('\n You still have the option to follow with the ' +
'installation. Do you want to follow? [y/N]')
if follow.upper() != 'Y' :
exit('\n Wise choice :)\n')

# c module to find TADs
pytadbit_module = Extension('pytadbit.tadbit_py',
language = "c",
Expand Down Expand Up @@ -228,7 +238,8 @@ def main():
scripts = ['scripts/shrec.py', 'scripts/model_and_analyze.py',
'scripts/tadbit', 'scripts/normalize_oneD.R'],
data_files = [(path.expanduser('~'),
['extras/.bash_completion'])]
['extras/.bash_completion'])],
cmdclass = {'install': InstallCommand}
)


Expand Down

0 comments on commit 8688b42

Please sign in to comment.