Permalink
Browse files

now installs Martel and doesn't complain about it

will install Bio.Cluster only if Numeric is present
  • Loading branch information...
1 parent cf890ef commit a8ae40f7829a461c62f28758e8aac8d9f409a568 jchang committed Sep 13, 2003
Showing with 90 additions and 65 deletions.
  1. +4 −1 MANIFEST.in
  2. +3 −2 README
  3. +83 −62 setup.py
View
@@ -20,11 +20,14 @@ include Bio/KDTree/Makefile # Include files for building KDTree.
include Bio/KDTree/_KDTree.i
include Bio/KDTree/README
include Bio/SCOP/tests/*.txt # Include files for testing SCOP.
-include Bio/EUtils/DTDs/*.dtd # Include DTD files for EUtils
exclude Tests/Graphics/*.pdf # Exclude test files generated by reportlab.
exclude Tests/Graphics/*.eps
exclude Tests/Blast/bt008* # Exclude large file.
recursive-exclude Tests/UnitTests * # Exclude unused testing framework.
recursive-include Martel * # Always distribute Martel
+
+
+# Make sure the proper files in EUtils are included.
+include Bio/EUtils/DTDs/*.dtd # Include DTD files for EUtils
View
5 README
@@ -32,8 +32,9 @@ o "mxTextTools 2.0.3":http://starship.python.net/~lemburg/mxTextTools.html
o "Numerical Python 15.3":http://numpy.sourceforge.net/ (optional)
This package is only used in the computationally-oriented modules.
- It is not required for most of the modules in Biopython. You can
- most likely skip this requirement. Please install if you are seeing
+ It is required for Bio.Cluster and a few other modules. If you
+ think you might need these modules, then please install Numeric
+ Python first. Also, please install if you are seeing
error messages such as:
ImportError: No module named Numeric
View
145 setup.py
@@ -21,7 +21,6 @@
"""
import sys
import os
-import shutil
# Make sure I have the right Python version.
if sys.version_info[:2] < (2, 2):
@@ -33,6 +32,7 @@
from distutils.core import Command
from distutils.command.install import install
from distutils.command.build_py import build_py
+from distutils.command.build_ext import build_ext
from distutils.extension import Extension
def get_yes_or_no(question, default):
@@ -53,6 +53,61 @@ def get_yes_or_no(question, default):
print "Please answer y or n."
return response[0] == 'y'
+_CHECKED = None
+def check_dependencies_once():
+ # Call check_dependencies, but cache the result for subsequent
+ # calls.
+ global _CHECKED
+ if _CHECKED is None:
+ _CHECKED = check_dependencies()
+ return _CHECKED
+
+def check_dependencies():
+ """Return whether the installation should continue."""
+ # There should be some way for the user to tell specify not to
+ # check dependencies. For example, it probably should not if
+ # the user specified "-q". However, I'm not sure where
+ # distutils stores that information. Also, install has a
+ # --force option that gets saved in self.user_options. It
+ # means overwrite previous installations. If the user has
+ # forced an installation, should we also ignore dependencies?
+ dependencies = [
+ ("mxTextTools", is_mxTextTools_installed, 1,
+ "http://www.lemburg.com/files/python/mxExtensions.html"),
+ #("Martel", is_Martel_installed, 1,
+ # "http://www.biopython.org/~dalke/Martel/"),
+ ("Numerical Python", is_Numpy_installed, 0,
+ "http://numpy.sourceforge.net/"),
+ ("Reportlab", is_reportlab_installed, 0,
+ "http://www.reportlab.com/download.html"),
+ ]
+
+ for name, is_installed_fn, is_required, url in dependencies:
+ if is_installed_fn():
+ continue
+
+ print "*** %s *** is either not installed or out of date." % name
+ if is_required:
+
+ print """
+This package is required for many Biopython features. Please install
+it before you install Biopython."""
+ default = 0
+ else:
+ print """
+This package is optional, which means it is only used in a few
+specialized modules in Biopython. You probably don't need this is you
+are unsure. You can ignore this requirement, and install it later if
+you see ImportErrors."""
+ default = 1
+ print "You can find %s at %s." % (name, url)
+ print
+
+ if not get_yes_or_no(
+ "Do you want to continue this installation?", default):
+ return 0
+ return 1
+
class install_biopython(install):
"""Override the standard install to check for dependencies.
@@ -63,59 +118,10 @@ class install_biopython(install):
Bio.EUtils.DTDs. This is not a pretty thing since we should
really only have pure python modules installed.
"""
- def check_dependencies(self):
- """S.check_dependencies() -> boolean
-
- Return whether the installation should continue.
-
- """
- # There should be some way for the user to tell specify not to
- # check dependencies. For example, it probably should not if
- # the user specified "-q". However, I'm not sure where
- # distutils stores that information. Also, install has a
- # --force option that gets saved in self.user_options. It
- # means overwrite previous installations. If the user has
- # forced an installation, should we also ignore dependencies?
- dependencies = [
- ("mxTextTools", is_mxTextTools_installed, 1,
- "http://www.lemburg.com/files/python/mxExtensions.html"),
- ("Martel", is_Martel_installed, 1,
- "http://www.biopython.org/~dalke/Martel/"),
- ("Numerical Python", is_Numpy_installed, 0,
- "http://numpy.sourceforge.net/"),
- ("Reportlab", is_reportlab_installed, 0,
- "http://www.reportlab.com/download.html"),
- ]
-
- for name, is_installed_fn, is_required, url in dependencies:
- if is_installed_fn():
- continue
-
- print "*** %s *** is either not installed or out of date." % name
- if is_required:
-
- print """
-This package is required for many Biopython features. Please install
-it before you install Biopython."""
- default = 0
- else:
- print """
-This package is optional, which means it is only used in a few
-specialized modules in Biopython. You probably don't need this is you
-are unsure. You can ignore this requirement, and install it later if
-you see ImportErrors."""
- default = 1
- print "You can find %s at %s." % (name, url)
- print
-
- if not get_yes_or_no(
- "Do you want to continue this installation?", default):
- return 0
- return 1
-
def install_eutils_dtds(self):
"""This is a hack to install DTDs needed for EUtils into Bio.
"""
+ import shutil
dtds_dir = os.path.join(os.getcwd(), "Bio", "EUtils", "DTDs")
install_dir = os.path.join(self.install_purelib, "Bio", "EUtils",
"DTDs")
@@ -126,21 +132,44 @@ def install_eutils_dtds(self):
shutil.copy(os.path.join(dtds_dir, potential_dtd),
install_dir)
-
def run(self):
- if self.check_dependencies():
+ if check_dependencies_once():
# Run the normal install.
install.run(self)
self.install_eutils_dtds()
class build_py_biopython(build_py):
def run(self):
+ if not check_dependencies_once():
+ return
# Check to see if Martel is installed. If not, then install
# it automatically.
if not is_Martel_installed():
self.packages.append("Martel")
+ # Only install the clustering software if Numpy is installed.
+ if is_Numpy_installed():
+ self.packages.append("Bio.Cluster")
build_py.run(self)
+class build_ext_biopython(build_ext):
+ def run(self):
+ if not check_dependencies_once():
+ return
+ # Only install the clustering software if Numpy is installed.
+ # Otherwise, it will not compile.
+ if is_Numpy_installed():
+ self.extensions.append(
+ Extension('Bio.Cluster.cluster',
+ ['Bio/Cluster/clustermodule.c',
+ 'Bio/Cluster/cluster.c',
+ 'Bio/Cluster/ranlib.c',
+ 'Bio/Cluster/com.c',
+ 'Bio/Cluster/linpack.c'],
+ include_dirs=["Bio/Cluster"]
+ )
+ )
+ build_ext.run(self)
+
class test_biopython(Command):
"""Run all of the tests for the package.
@@ -240,7 +269,6 @@ def is_reportlab_installed():
'Bio.builders.SeqRecord',
'Bio.CDD',
'Bio.Clustalw',
- 'Bio.Cluster',
'Bio.config',
'Bio.Crystal',
'Bio.Data',
@@ -349,14 +377,6 @@ def is_reportlab_installed():
'Bio/csupport.c'],
include_dirs=["Bio"]
),
- Extension('Bio.Cluster.cluster',
- ['Bio/Cluster/clustermodule.c',
- 'Bio/Cluster/cluster.c',
- 'Bio/Cluster/ranlib.c',
- 'Bio/Cluster/com.c',
- 'Bio/Cluster/linpack.c'],
- include_dirs=["Bio/Cluster"]
- ),
#Extension('Bio.KDTree._KDTreecmodule',
# ["Bio/KDTree/_KDTree.C",
# "Bio/KDTree/_KDTree.swig.C"],
@@ -377,6 +397,7 @@ def is_reportlab_installed():
cmdclass={
"install" : install_biopython,
"build_py" : build_py_biopython,
+ "build_ext" : build_ext_biopython,
"test" : test_biopython,
},
packages=PACKAGES,

0 comments on commit a8ae40f

Please sign in to comment.