[Biopython-dev] numpy setup-time dependency workaround

Peter Cock p.j.a.cock at googlemail.com
Fri Oct 23 15:12:11 UTC 2015


Hi Manuel,

The numpy specific hacks in Biopython's setup.py are a bit
of a pain, yes.

In my view, the main reason we have a "soft" dependency on
NumPy is that we also want to be able to use Biopython on
other Python implementations where NumPy is not available,
e.g. Jython and PyPy (we need to check how their NumPyPy
work is getting on, it may cover some of our usage now).

In practice, even if the traditional Python implementation (in C)
is used, there are times when it is helpful to be able to install
most of Biopython without NumPy - for example virtual machine
images for testing etc.

In practise, maybe we should remove this special case an
for the traditional Python implementation (in C) insist that
numpy is already installed?

(Modularising Biopython would be another practical solution
to the partial NumPy dependency, but vastly more work)

Peter

On Fri, Oct 23, 2015 at 2:56 PM, Manuel Nuno Melo
<manuel.nuno.melo at gmail.com> wrote:
> Dear biopython devs,
>
> I recently implemented in MDAnalysis a distutils/setuptools workaround
> (https://github.com/MDAnalysis/mdanalysis/pull/499) to the numpy
> dependency-at-setuptime problem, and I think biopython might benefit from
> it.
>
> The problem is that in setup.py distutils' setup() must be provided a list
> of Extension objects, which in turn must contain the list of directories in
> which to look for include files (namely, numpy's).
>
> If numpy isn't installed the Extensions objects can't be instantiated. If
> numpy is specified as a setup-time dependency it will get installed when
> setup() is called, but the instantiation of the Extensions happens before
> the call to setup(). We get a cyclic dependency in that we need to know the
> path to the numpy install before calling the function that will install
> numpy.
>
> My solution was to subclass Extension to have a managed include_dirs
> attribute which only probes for numpy at install-time. Since by then setup()
> has had time to install numpy, all works fine.
>
> I believe a similar workaround could work well for biopython (although it
> might involve setting numpy as as hard requirement, or at least asking the
> user beforehand whether to install it).
>
> Of course, it would also benefit us at MDAnalysis since we could then
> cleanly depend on biopython without worrying whether its install is
> numpy-complete or not.
>
> I'll be glad with helping with the implementation, if you think it's worthy.
>
> Cheers,
> Manel
>
> _______________________________________________
> Biopython-dev mailing list
> Biopython-dev at mailman.open-bio.org
> http://mailman.open-bio.org/mailman/listinfo/biopython-dev


More information about the Biopython-dev mailing list