8000 Merge release workflow updates · pysam-developers/pysam@f25e4f3 · GitHub
[go: up one dir, main page]

Skip to content

Commit f25e4f3

Browse files
committed
Merge release workflow updates
2 parents 313b5fd + 4c97a24 commit f25e4f3

File tree

6 files changed

+90
-14
lines changed

6 files changed

+90
-14
lines changed

.cirrus.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ build_wheels_task:
88
architecture: arm64
99
platform: linux
1010
matrix:
11-
- name: Build ARM Linux py3.6-9 wheels
11+
- name: Build ARM Linux py3.8-9 wheels
1212
env:
13-
CIBW_BUILD: "cp36-* cp37-* cp38-* cp39-*"
14-
- name: Build ARM Linux py3.10-13 wheels
13+
CIBW_BUILD: "cp38-* cp39-*"
14+
- name: Build ARM Linux py3.10-11 wheels
1515
env:
16-
CIBW_BUILD: "cp310-* cp311-* cp312-* cp313-*"
16+
CIBW_BUILD: "cp310-* cp311-*"
17+
- name: Build ARM Linux py3.12-13 wheels
18+
env:
19+
CIBW_BUILD: "cp312-* cp313-*"
1720

1821
- name: Build ARM macOS wheels
1922
macos_instance:
@@ -29,17 +32,17 @@ build_wheels_task:
2932
VENV: $HOME/relenv
3033
PATH: $VENV/bin:$PATH
3134

32-
CIBW_SKIP: "*-musllinux_*"
3335
CIBW_BUILD_VERBOSITY: 1
3436

3537
# Avoid linking with non-system library libdeflate.dylib
3638
CIBW_ENVIRONMENT_MACOS: HTSLIB_CONFIGURE_OPTIONS="--without-libdeflate"
3739

3840
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28
41+
CIBW_MUSLLINUX_AARCH64_IMAGE: musllinux_1_2
3942

4043
install_script: |
4144
python3 -m venv $VENV
42-
pip3 install cibuildwheel==2.22.0
45+
pip3 install cibuildwheel==2.23.3
4346
4447
build_script: |
4548
cibuildwheel

.github/workflows/release.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
matrix:
1515
os: [ubuntu-latest, macos-13]
16-
build: ["cp36-* cp37-* cp38-* cp39-*", "cp310-* cp311-* cp312-* cp313-*"]
16+
build: ["cp38-* cp39-*", "cp310-* cp311-*", "cp312-* cp313-*"]
1717
x64image: [manylinux_2_28]
1818
nametag: [none]
1919

@@ -31,10 +31,9 @@ jobs:
3131
run: devtools/check-platform.sh ${{ matrix.os }}
3232

3333
- name: Build wheels
34-
uses: pypa/cibuildwheel@v2.22.0
34+
uses: pypa/cibuildwheel@v2.23.3
3535
env:
3636
CIBW_BUILD: ${{ matrix.build }}
37-
CIBW_SKIP: "*-musllinux_*"
3837
CIBW_BUILD_VERBOSITY: 1
3938

4039
# Avoid linking with non-system library libdeflate.dylib
@@ -46,6 +45,7 @@ jobs:
4645
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.x64image }}
4746
CIBW_MANYLINUX_I686_IMAGE: manylinux2014
4847
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28
48+
CIBW_MUSLLINUX_X86_64_IMAGE: musllinux_1_2
4949

5050
- name: Check wheelhouse
5151
run: devtools/artifactname.py wheelhouse/*.whl >> $GITHUB_ENV

devtools/emulate-tools.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env python3
2+
"""
3+
This script can be symlinked to samtools, bcftools, bgzip, or tabix.
4+
When invoked under one of those names, it will emulate that tool's
5+
behaviour by using pysam's facilities.
6+
"""
7+
8+
import argparse
9+
import gzip
10+
import os
11+
import sys
12+
import tempfile
13+
14+
import pysam
15+
16+
command = os.path.basename(sys.argv[0])
17+
18+
if command in ("samtools", "bcftools"):
19+
if len(sys.argv) > 1:
20+
try:
21+
tool = pysam.utils.PysamDispatcher(command, sys.argv[1])
22+
tool(*sys.argv[2:], catch_stdout=None)
23+
print(tool.stderr, end="", file=sys.stderr)
24+
except pysam.utils.SamtoolsError as e:
25+
sys.exit(f"emulate-tools.py: {e}")
26+
27+
else:
28+
version = getattr(pysam.version, f"__{command}_version__")
29+
print(f"Program: {command}\nVersion: {version}", file=sys.stderr)
30+
31+
else:
32+
parser = argparse.ArgumentParser()
33+
parser.add_argument("-c", "--stdout", action="store_true")
34+
parser.add_argument("-d", "--decompress", action="store_true")
35+
parser.add_argument("-f", "--force", action="store_true")
36+
parser.add_argument("-p", "--preset")
37+
parser.add_argument("input_file", nargs="?")
38+
opt = parser.parse_args()
39+
40+
if command == "bgzip":
41+
if opt.decompress:
42+
with gzip.open(sys.stdin.buffer, "rb") as f:
43+
sys.stdout.buffer.write(f.read())
44+
45+
elif opt.input_file and opt.stdout:
46+
pysam.tabix_compress(opt.input_file, "-", force=True)
47+
48+
else:
49+
f = tempfile.NamedTemporaryFile(delete=False)
50+
f.write(sys.stdin.buffer.read())
51+
f.close()
52+
pysam.tabix_compress(f.name, "-", force=True)
53+
os.remove(f.name)
54+
55+
elif command == "tabix":
56+
pysam.tabix_index(opt.input_file, preset=opt.preset, force=opt.force)
57+
58+
else:
59+
sys.exit(f"emulate-tools.py: unknown command {command!r}")

devtools/install-prerequisites.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ elif test -x /usr/bin/yum; then
1212
else
1313
echo Installing non-test prerequisites via yum...
1414
yum -y install zlib-devel bzip2-devel xz-devel curl-devel openssl-devel
15+
emulate=yes
1516
fi
1617

1718
elif test -d /etc/dpkg; then
@@ -23,6 +24,7 @@ elif test -x /sbin/apk; then
2324
echo Installing non-test prerequisites via apk...
2425
apk update
2526
apk add zlib-dev bzip2-dev xz-dev curl-dev openssl-dev
27+
emulate=yes
2628

2729
elif test -x ${HOMEBREW_PREFIX-/usr/local}/bin/brew; then
2830
echo Installing prerequisites via brew...
@@ -32,3 +34,14 @@ elif test -x ${HOMEBREW_PREFIX-/usr/local}/bin/brew; then
3234
else
3335
echo No package manager detected
3436
fi
37+
38+
if test -n "$emulate" && test $# -ge 2; then
39+
emulator=$1
40+
bindir=$2
41+
echo Creating symlinks to $emulator in $bindir...
42+
mkdir -p $bindir
43+
ln -s $emulator $bindir/samtools
44+
ln -s $emulator $bindir/bcftools
45+
ln -s $emulator $bindir/bgzip
46+
ln -s $emulator $bindir/tabix
47+
fi

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ license = { text = "MIT License" }
55
authors = [
66
{ name = "Andreas Heger", email = "andreas.heger@gmail.com"}
77
]
8-
requires-python = ">=3.6"
8+
requires-python = ">=3.8"
99

1010
dynamic = [
1111
"classifiers",
@@ -22,7 +22,7 @@ requires = ["setuptools>=59.0", "Cython>=0.29.12,<4"]
2222
build-backend = "setuptools.build_meta:__legacy__"
2323

2424
[tool.cibuildwheel]
25-
before-all = "{project}/devtools/install-prerequisites.sh"
25+
before-all = "{project}/devtools/install-prerequisites.sh {project}/devtools/emulate-tools.py /usr/local/bin"
2626
# Necessary until we build libhts.a out-of-tree from within build_temp
2727
before-build = "make -C {project}/htslib distclean"
2828

@@ -32,7 +32,7 @@ test-command = "REF_PATH=: pytest {project}/tests"
3232
[tool.tox]
3333
legacy_tox_ini = """
3434
[tox]
35-
envlist = py36, py311
35+
envlist = py38, py311
3636
3737
[testenv]
3838
deps = pytest

pysam/libcutils.pyx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ from libc.stdint cimport INT32_MAX, int32_t
1919
from libc.stdio cimport fprintf, stderr, fflush
2020
from libc.stdio cimport stdout as c_stdout
2121
from posix.fcntl cimport open as c_open, O_WRONLY, O_CREAT, O_TRUNC
22-
from posix.unistd cimport SEEK_SET, SEEK_CUR, SEEK_END
22+
from posix.unistd cimport dup as c_dup, SEEK_SET, SEEK_CUR, SEEK_END, STDOUT_FILENO
2323

2424
from pysam.libcsamtools cimport samtools_dispatch, samtools_set_stdout, samtools_set_stderr, \
2525
samtools_close_stdout, samtools_close_stderr, samtools_set_stdout_fn
@@ -361,7 +361,8 @@ def _pysam_dispatch(collection,
361361
else:
362362
samtools_set_stdout_fn("-")
363363
bcftools_set_stdout_fn("-")
364-
stdout_h = c_open(b"/dev/null", O_WRONLY)
364+
if catch_stdout is None: stdout_h = c_dup(STDOUT_FILENO)
365+
else: stdout_h = c_open(b"/dev/null", O_WRONLY)
365366

366367
# setup the function call to samtools/bcftools main
367368
cdef char ** cargs

0 commit comments

Comments
 (0)
0