Skip to content

Commit d924297

Browse files
authored
Merge pull request #234 from AviPeltz/master
Fix packaging for cross-platform installs and PyPI readiness
2 parents 1bdd853 + dec8a44 commit d924297

File tree

7 files changed

+441
-83
lines changed

7 files changed

+441
-83
lines changed

.github/workflows/build.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
branches: [main, master, develop]
6+
pull_request:
7+
branches: [main, master]
8+
9+
jobs:
10+
test:
11+
name: Test on ${{ matrix.os }} / Python ${{ matrix.python-version }}
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [ubuntu-latest, macos-latest]
17+
python-version: ["3.9", "3.10", "3.11", "3.12"]
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
27+
- name: Install build dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install build pytest
31+
32+
- name: Build and install package
33+
run: |
34+
pip install .
35+
36+
- name: Verify binaries are bundled
37+
run: |
38+
python -c "from smudgeplot.cli import get_binary_path; print(get_binary_path('hetmers'))"
39+
python -c "from smudgeplot.cli import get_binary_path; print(get_binary_path('extract_kmer_pairs'))"
40+
41+
- name: Test CLI
42+
run: |
43+
smudgeplot --version
44+
smudgeplot -h
45+
smudgeplot hetmers --help
46+
smudgeplot extract --help
47+
48+
build-wheels:
49+
name: Build wheels on ${{ matrix.os }}
50+
runs-on: ${{ matrix.os }}
51+
strategy:
52+
matrix:
53+
os: [ubuntu-latest, macos-13, macos-14] # macos-13=x86, macos-14=arm64
54+
55+
steps:
56+
- uses: actions/checkout@v4
57+
58+
- name: Build wheels
59+
uses: pypa/[email protected]
60+
# Config is read from pyproject.toml [tool.cibuildwheel]
61+
62+
- uses: actions/upload-artifact@v4
63+
with:
64+
name: wheels-${{ matrix.os }}
65+
path: ./wheelhouse/*.whl
66+
67+
build-sdist:
68+
name: Build source distribution
69+
runs-on: ubuntu-latest
70+
steps:
71+
- uses: actions/checkout@v4
72+
73+
- name: Build sdist
74+
run: |
75+
pip install build
76+
python -m build --sdist
77+
78+
- name: Verify sdist doesn't contain binaries
79+
run: |
80+
tar -tzf dist/*.tar.gz | grep -E 'bin/(hetmers|extract_kmer_pairs)$' && exit 1 || echo "Good: no binaries in sdist"
81+
82+
- uses: actions/upload-artifact@v4
83+
with:
84+
name: sdist
85+
path: dist/*.tar.gz
86+
87+
test-sdist:
88+
name: Test sdist on ${{ matrix.os }}
89+
needs: build-sdist
90+
runs-on: ${{ matrix.os }}
91+
strategy:
92+
matrix:
93+
os: [ubuntu-latest, macos-latest]
94+
95+
steps:
96+
- uses: actions/download-artifact@v4
97+
with:
98+
name: sdist
99+
path: dist
100+
101+
- name: Set up Python
102+
uses: actions/setup-python@v5
103+
with:
104+
python-version: "3.11"
105+
106+
- name: Install from sdist
107+
run: |
108+
pip install dist/*.tar.gz
109+
110+
- name: Verify binaries are compiled
111+
run: |
112+
python -c "from smudgeplot.cli import get_binary_path; print(get_binary_path('hetmers'))"
113+
python -c "from smudgeplot.cli import get_binary_path; print(get_binary_path('extract_kmer_pairs'))"
114+
115+
- name: Test compiled binaries execute
116+
run: |
117+
smudgeplot hetmers --help
118+
smudgeplot extract --help

.github/workflows/publish.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build-wheels:
9+
name: Build wheels on ${{ matrix.os }}
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
matrix:
13+
os: [ubuntu-latest, macos-13, macos-14]
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Build wheels
19+
uses: pypa/[email protected]
20+
# Config is read from pyproject.toml [tool.cibuildwheel]
21+
22+
- uses: actions/upload-artifact@v4
23+
with:
24+
name: wheels-${{ matrix.os }}
25+
path: ./wheelhouse/*.whl
26+
27+
build-sdist:
28+
name: Build source distribution
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- name: Build sdist
34+
run: |
35+
pip install build
36+
python -m build --sdist
37+
38+
- name: Verify sdist doesn't contain binaries
39+
run: |
40+
tar -tzf dist/*.tar.gz | grep -E 'bin/(hetmers|extract_kmer_pairs)$' && exit 1 || echo "Good: no binaries in sdist"
41+
42+
- uses: actions/upload-artifact@v4
43+
with:
44+
name: sdist
45+
path: dist/*.tar.gz
46+
47+
publish:
48+
name: Publish to PyPI
49+
needs: [build-wheels, build-sdist]
50+
runs-on: ubuntu-latest
51+
environment: pypi
52+
permissions:
53+
id-token: write # Required for trusted publishing
54+
55+
steps:
56+
- name: Download all artifacts
57+
uses: actions/download-artifact@v4
58+
with:
59+
path: dist
60+
merge-multiple: true
61+
62+
- name: List distribution files
63+
run: ls -la dist/
64+
65+
- name: Publish to PyPI
66+
uses: pypa/gh-action-pypi-publish@release/v1
67+
with:
68+
packages-dir: dist/

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ src/smudgeplot/__pycache__
1616
src/smudgeplot.egg-info
1717
dist
1818
.venv
19+
smudgeplot_dev/
20+
21+
# Compiled binaries (built during install)
22+
src/smudgeplot/bin/

MANIFEST.in

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
include LICENSE.md
2+
include README.md
3+
include Makefile
4+
5+
# Include C source files for compilation during install
6+
recursive-include src/lib *.c *.h
7+
8+
# Explicitly exclude compiled binaries - they must be built per-platform
9+
global-exclude src/smudgeplot/bin/*
10+
prune src/smudgeplot/bin

pyproject.toml

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,80 @@
11
[build-system]
2-
requires = ["setuptools>=61.0"]
2+
requires = ["setuptools>=61.0", "wheel"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "smudgeplot"
77
version = "0.5.1"
8-
dependencies = [
9-
"numpy >= 2.2.3",
10-
"matplotlib >= 3.10.0",
11-
"pandas >= 2.2.3"
12-
]
8+
description = "Inference of ploidy and heterozygosity structure using whole genome sequencing data"
9+
readme = "README.md"
10+
license = "Apache-2.0"
11+
license-files = ["LICENSE.md"]
12+
keywords = ["smudgeplot", "kmer", "ploidy", "genomics", "bioinformatics"]
13+
14+
# Relaxed Python version - works with 3.9+
15+
requires-python = ">=3.9"
1316

14-
requires-python = ">=3.11.11"
1517
authors = [
1618
{name = "Kamil S. Jaron", email = "[email protected]"},
1719
{name = "Sam Ebdon", email = "[email protected]"},
1820
]
19-
# add authors
2021

2122
maintainers = [
2223
{name = "Kamil Jaron", email = "[email protected]"},
2324
{name = "Sam Ebdon", email = "[email protected]"},
2425
]
2526

26-
description = "Smudgeplot description"
27-
readme = "README.md"
28-
license = "Apache-2.0"
29-
license-files = ["LICENSE.md"]
30-
keywords = ["smudgeplot","kmer","ploidy"]
27+
# Relaxed dependency versions for broader compatibility
28+
dependencies = [
29+
"numpy>=1.20.0",
30+
"matplotlib>=3.4.0",
31+
"pandas>=1.3.0",
32+
]
3133

3234
classifiers = [
33-
"Development Status :: 3 - Alpha",
34-
"Programming Language :: Python :: 3"
35+
"Development Status :: 4 - Beta",
36+
"Programming Language :: Python :: 3",
37+
"Programming Language :: Python :: 3.9",
38+
"Programming Language :: Python :: 3.10",
39+
"Programming Language :: Python :: 3.11",
40+
"Programming Language :: Python :: 3.12",
41+
"Operating System :: POSIX :: Linux",
42+
"Operating System :: MacOS",
43+
"Intended Audience :: Science/Research",
44+
"Topic :: Scientific/Engineering :: Bio-Informatics",
3545
]
3646

3747
[project.urls]
38-
Homepage = "https://github.com/KamilSJaron/smudgeplot/tree/sploidyplot_obj"
48+
Homepage = "https://github.com/KamilSJaron/smudgeplot"
49+
Documentation = "https://github.com/KamilSJaron/smudgeplot#readme"
50+
Repository = "https://github.com/KamilSJaron/smudgeplot"
3951
Issues = "https://github.com/KamilSJaron/smudgeplot/issues"
4052

4153
[project.scripts]
4254
smudgeplot = "smudgeplot.cli:main"
4355

4456
[tool.setuptools]
4557
package-dir = {"" = "src"}
58+
include-package-data = true
4659

4760
[tool.setuptools.packages.find]
4861
where = ["src"]
4962

50-
[tool.ruff]
51-
line-length = 120
63+
[tool.setuptools.package-data]
64+
smudgeplot = ["bin/*"]
5265

53-
[tool.ruff.lint]
54-
select = [
55-
"A",
56-
"ARG",
57-
"B",
58-
"BLE",
59-
"C4",
60-
"COM",
61-
"DTZ",
62-
"E",
63-
"EM",
64-
"F",
65-
"I",
66-
"ISC",
67-
"LOG",
68-
"N",
69-
"PYI",
70-
"S",
71-
"SIM",
72-
"U",
73-
]
74-
ignore = [
75-
"COM812",
76-
"C901",
77-
"LOG015",
78-
"N803",
79-
"N806",
80-
]
66+
[tool.cibuildwheel]
67+
# Skip 32-bit, PyPy, musllinux, and Windows (no Windows support for now)
68+
skip = ["*-win32", "*-win_amd64", "*-manylinux_i686", "pp*", "*-musllinux*"]
69+
build = ["cp39-*", "cp310-*", "cp311-*", "cp312-*"]
70+
71+
# Test that the CLI works after building
72+
test-command = "smudgeplot --version"
73+
74+
[tool.cibuildwheel.linux]
75+
# manylinux has gcc available
76+
before-all = "yum install -y gcc || apt-get update && apt-get install -y gcc || true"
77+
78+
[tool.cibuildwheel.macos]
79+
# macOS runners have clang available by default
80+
# Nothing special needed

0 commit comments

Comments
 (0)