[Biopython-dev] _pwm.c

Peter biopython at maubp.freeserve.co.uk
Thu Oct 28 10:27:04 EDT 2010


On Thu, Oct 28, 2010 at 3:16 PM, Dragoslav Zaric
<zaricdragoslav at gmail.com> wrote:
> Dear Peter,
>
> I wrote you this yesterday:
>
> I put this in setup.py:
>
> class build_ext_biopython(build_ext):
>   def run(self):
>       if not check_dependencies_once():
>           return
>       # add software that requires NumPy to install
>       # TODO - Convert these for Python 3
>       if is_Numpy_installed():
>           import numpy
>           numpy_include_dir = numpy.get_include()
>           #self.extensions.append(
>           #    Extension('Bio.Cluster.cluster',
>           #              ['Bio/Cluster/clustermodule.c',
>           #               'Bio/Cluster/cluster.c'],
>           #              include_dirs=[numpy_include_dir],
>           #              ))
>           #self.extensions.append(
>           #    Extension('Bio.KDTree._CKDTree',
>           #              ["Bio/KDTree/KDTree.c",
>           #               "Bio/KDTree/KDTreemodule.c"],
>           #              include_dirs=[numpy_include_dir],
>           #              ))
>           self.extensions.append(
>               Extension('Bio.Motif._pwm',
>                         ["Bio/Motif/_pwm.c"],
>                         include_dirs=[numpy_include_dir],
>                         ))
>       build_ext.run(self)
>
> and than I run:
>
> python3.1 setup.py build_ext
>
> This is output:
>
> Biopython does not yet officially support Python 3, but you
> can try it by first using the 2to3 script on our source code.
> For details on how to use 2to3 with Biopython see README.
> If you still haven't applied 2to3 to Biopython please abort now.
> Do you want to continue this installation? (y/N):
> y
> running build_ext
> building 'Bio.Motif._pwm' extension
> creating build/temp.linux-i686-3.1
> creating build/temp.linux-i686-3.1/Bio
> creating build/temp.linux-i686-3.1/Bio/Motif
> gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall
> -Wstrict-prototypes -fPIC
> -I/usr/local/lib/python3.1/site-packages/numpy/core/include
> -I/usr/local/include/python3.1 -c Bio/Motif/_pwm.c -o
> build/temp.linux-i686-3.1/Bio/Motif/_pwm.o
> Bio/Motif/_pwm.c: In function ‘init_pwm’:
> Bio/Motif/_pwm.c:123: warning: ‘return’ with a value, in function returning void
> Bio/Motif/_pwm.c:125: warning: implicit declaration of function ‘Py_InitModule4’
> Bio/Motif/_pwm.c:129: warning: assignment makes pointer from integer
> without a cast
> gcc -pthread -shared build/temp.linux-i686-3.1/Bio/Motif/_pwm.o -o
> build/lib/Bio/Motif/_pwm.so
>
>
> So as you can see this is compiling, but there are some warnings. So what is
> plan, to compile totally without warnings ??

Well ideally no warnings - but of those three warnings only the one about
Py_InitModule4 strikes me as important. This was part of the Python 2.x
C API used to tell Python about the functions your code provides, and has
been changed in Python 3.x (I think you must use PyModule_Create instead).

What happens if you try to use the compiled module in Python 3? e.g.

from Bio import Motif
from Bio.Motif import _pwm

Bartek - could you give us a short (Python 2) example of Bio.Motif
which uses the C module _pwm?

Peter



More information about the Biopython-dev mailing list