Skip to content

Commit

Permalink
Merge pull request #91 from mvdbeek/fix_cython_3_compile
Browse files Browse the repository at this point in the history
Fix compilation with cython 3
  • Loading branch information
nsoranzo authored Jul 26, 2023
2 parents 6f7e5ca + ab55cde commit e65d255
Show file tree
Hide file tree
Showing 83 changed files with 90 additions and 183 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ jobs:
CIBW_ARCHS: ${{matrix.arch}}
# Skip building musllinux wheels for now, they take too long to build,
# mainly because numpy doesn't have musllinux wheels on PyPI yet.
# Skip also building for PyPy 3.7, which is deprecated upstream.
CIBW_SKIP: '*-musllinux* pp37-*'
# Skip also building for PyPy 3.7-3.8, which are deprecated upstream.
CIBW_SKIP: '*-musllinux* pp37-* pp38-*'
- name: Check packages
run: twine check dist/*
- uses: actions/upload-artifact@v3
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.10']
python-version: ['3.7', '3.11']
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install flake8
run: pip install flake8
- name: Install tox
run: pip install tox
- name: Lint
run: flake8 .
run: tox -e lint
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
Expand All @@ -34,4 +34,4 @@ jobs:
- name: Install tox
run: pip install tox
- name: Test
run: tox
run: tox -e py
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ recursive-include src *.c
recursive-include lib *.h
recursive-include lib *.c
recursive-include lib *.pyx
recursive-include lib *.pxd
2 changes: 1 addition & 1 deletion lib/bx/_seqmapping.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ cdef class IntToIntMapping:
cdef int *t_buf
# Get direct access to string
PyObject_AsReadBuffer( src, <const void **> &s_buf, &s_len )
s_len = s_len / sizeof( int )
s_len = s_len // sizeof( int )
assert s_len == len( src ), "`src` argument must be a buffer of 32bit integers"
# Initialize empty array
rval = zeros( s_len, 'i' )
Expand Down
2 changes: 1 addition & 1 deletion lib/bx/align/epo_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def ch(c, ci):
assert c[th : th + l] == "-" * l
th += l

for (a, b) in self.epo_records:
for a, b in self.epo_records:
ca, cb = cigar_pairs[int(a.gabid)]
ch(ca, a.cigar_iter(False))
ch(cb, b.cigar_iter(False))
Expand Down
7 changes: 3 additions & 4 deletions lib/bx/align/lav.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def build_alignment(self, score, pieces):
self.open_seqs()
text1 = text2 = ""
end1 = end2 = None
for (start1, start2, length, _pctId) in pieces:
for start1, start2, length, _pctId in pieces:
if end1 is not None:
if start1 == end1: # insertion in sequence 2
text1 += self.seq1_gap * (start2 - end2)
Expand Down Expand Up @@ -438,7 +438,6 @@ def build_alignment(self, score, pieces):


class Writer:

# blockHash is a hash from (src1,strand1,src2,strand2) to a list of blocks;
# the blocks are collected on each call to write(), but the actual writing
# does not occur until close().
Expand Down Expand Up @@ -568,7 +567,7 @@ def write_a_stanza(self, alignment):
print(" s %s" % score, file=self.file)
print(" b %d %d" % (start1 + 1, start2 + 1), file=self.file)
print(" e %d %d" % (end1, end2), file=self.file)
for (start1, start2, size, pctId) in pieces:
for start1, start2, size, pctId in pieces:
print(" l %d %d %d %d %d" % (start1 + 1, start2 + 1, start1 + size, start2 + size, pctId), file=self.file)
print("}", file=self.file)

Expand Down Expand Up @@ -625,7 +624,7 @@ def rc_or_nothing(strand):


def do_path_subs(path, path_subs):
for (prefix, replacement) in path_subs:
for prefix, replacement in path_subs:
if path.startswith(prefix):
return replacement + path[len(prefix) :]
return path
1 change: 0 additions & 1 deletion lib/bx/align/lav_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

class lavTestCase(unittest.TestCase):
def testReader(self):

reader = lav.Reader(open(test_lav))

a = next(reader)
Expand Down
4 changes: 0 additions & 4 deletions lib/bx/align/maf_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@


def test_reader():

reader = maf.Reader(StringIO(test_maf))
assert reader.attributes["version"] == "1"
assert reader.attributes["scoring"] == "humor.v4"
Expand All @@ -103,7 +102,6 @@ def test_reader():


def test_writer():

val = StringIO()
writer = maf.Writer(val, {"scoring": "foobar"})

Expand Down Expand Up @@ -134,7 +132,6 @@ def test_writer():


def test_slice():

b = complex_maf.slice_by_component(0, 101, 105)

check_component(b.components[0], src="human_hoxa", start=101, size=4, strand="+", src_size=100257, text="CA-TT")
Expand Down Expand Up @@ -181,7 +178,6 @@ def test_slice():


def test_reverse_complement():

b = complex_maf.reverse_complement()

check_component(
Expand Down
2 changes: 0 additions & 2 deletions lib/bx/arrays/array_tree.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ from numpy import *

cimport numpy

cimport bx.arrays.wiggle

from bx.misc.binary_file import (
BinaryFileReader,
BinaryFileWriter,
Expand Down
14 changes: 9 additions & 5 deletions lib/bx/bbi/bbi_file.pxd
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
from types cimport *

from bpt_file cimport BPTFile
from cirtree_file cimport CIRTreeFile

import numpy

cimport numpy

from .bpt_file cimport BPTFile
from .cirtree_file cimport CIRTreeFile
from .types cimport (
bits16,
bits32,
bits64,
boolean,
)


cdef class SummaryBlock:
"""
Expand Down
34 changes: 16 additions & 18 deletions lib/bx/bbi/bbi_file.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,25 @@ mirrors Jim Kent's 'bbiRead.c' mostly.

from cpython.version cimport PY_MAJOR_VERSION

import math
import sys

cimport cython

import zlib
from collections import deque

from types cimport *

from bpt_file cimport BPTFile
from cirtree_file cimport CIRTreeFile
from libc cimport limits
from io import BytesIO

import numpy

cimport numpy
from bx.misc.binary_file import BinaryFileReader

import math
import zlib
from io import BytesIO
cimport cython
from libc cimport limits

from bx.misc.binary_file import BinaryFileReader
from .bpt_file cimport BPTFile
from .cirtree_file cimport CIRTreeFile
from .types cimport (
bits32,
bits64,
)


cdef extern from "Python.h":
Expand Down Expand Up @@ -95,7 +93,7 @@ cdef class SummarizedData:
e = self.end
if s >= e:
return
base_step = ( self.end - self.start ) / self.size
base_step = ( self.end - self.start ) // self.size
for j from 0 <= j < self.size:
base_start = self.start + ( base_step * j )
base_end = base_start + base_step
Expand Down Expand Up @@ -206,8 +204,8 @@ cdef class BBIFile:

# Find appropriate zoom level
cdef bits32 base_size = end - start
cdef int full_reduction = base_size / summary_size
cdef int zoom = full_reduction / 2
cdef int full_reduction = base_size // summary_size
cdef int zoom = full_reduction // 2
if zoom < 0:
zoom = 0
cdef ZoomLevel zoom_level = self._best_zoom_level( zoom )
Expand Down Expand Up @@ -418,7 +416,7 @@ cdef class ZoomLevel:
reader.seek( self.index_offset )
summaries = self._summary_blocks_in_region(chrom_id, start, end)

base_step = (end - start) / summary_size
base_step = (end - start) // summary_size
base_start = start
base_end = start

Expand Down
19 changes: 11 additions & 8 deletions lib/bx/bbi/bigbed_file.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@
BigBed file.
"""

from bbi_file cimport *
from cirtree_file cimport CIRTreeFile
import zlib
from io import BytesIO

import numpy

from types cimport *
from bx.intervals.io import GenomicInterval
from bx.misc.binary_file import BinaryFileReader

cimport numpy

import zlib
from io import BytesIO

from bx.intervals.io import GenomicInterval
from bx.misc.binary_file import BinaryFileReader
from .bbi_file cimport (
BBIFile,
BlockHandler,
SummarizedData,
)
from .cirtree_file cimport CIRTreeFile
from .types cimport bits32

DEF big_bed_sig = 0x8789F2EB

Expand Down
23 changes: 15 additions & 8 deletions lib/bx/bbi/bigwig_file.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,28 @@
BigWig file.
"""

import zlib
from collections import deque

from bbi_file cimport *
from cirtree_file cimport CIRTreeFile
from io import BytesIO

import numpy

from types cimport *
from bx.misc.binary_file import BinaryFileReader

cimport numpy

import zlib
from io import BytesIO

from bx.misc.binary_file import BinaryFileReader
from .bbi_file cimport (
BBIFile,
BlockHandler,
SummarizedData,
)
from .cirtree_file cimport CIRTreeFile
from .types cimport (
bits8,
bits16,
bits32,
UBYTE,
)

DEF big_wig_sig = 0x888FFC26
DEF bwg_bed_graph = 1
Expand Down
2 changes: 1 addition & 1 deletion lib/bx/bbi/bpt_file.pxd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from bx.misc.binary_file import BinaryFileReader

from types cimport *
from .types cimport *


cdef class BPTFile:
Expand Down
2 changes: 1 addition & 1 deletion lib/bx/bbi/cirtree_file.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from types cimport *
from .types cimport *


cdef class CIRTreeFile:
Expand Down
12 changes: 6 additions & 6 deletions lib/bx/bbi/types.pxd
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
ctypedef unsigned char UBYTE
ctypedef signed char BYTE
ctypedef unsigned short UWORD
ctypedef short WORD
ctypedef unsigned long long bits64
ctypedef unsigned bits32
ctypedef unsigned char UBYTE
ctypedef signed char BYTE
ctypedef unsigned short UWORD
ctypedef short WORD
ctypedef unsigned long long bits64
ctypedef unsigned bits32
ctypedef unsigned short bits16
ctypedef unsigned char bits8
ctypedef int signed32
Expand Down
Loading

0 comments on commit e65d255

Please sign in to comment.