Skip to content

Commit

Permalink
Change build-time dependency to numpy 2, Drop Python 3.8, add 3.12, A…
Browse files Browse the repository at this point in the history
…dd pyproject.toml
  • Loading branch information
jeromekelleher authored and benjeffery committed Jun 27, 2024
1 parent f467db6 commit ffead55
Show file tree
Hide file tree
Showing 31 changed files with 200 additions and 268 deletions.
17 changes: 7 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,12 @@ jobs:
command: |
cd python
rm -fR build
python setup.py sdist
python setup.py check
python -m twine check dist/*.tar.gz
python -m pip install build
python -m venv venv
source venv/bin/activate
pip install --upgrade setuptools pip wheel
python setup.py build_ext
python setup.py egg_info
python setup.py bdist_wheel
pip install dist/*.tar.gz
python -m build --sdist
python -m twine check dist/*.tar.gz
python -m build --wheel
pip install dist/*.whl
tskit --help
build-32:
Expand All @@ -218,6 +214,7 @@ workflows:
test:
jobs:
- build
- build-32
#Temporarily disabled due avoid compiling numpy on 32bit
# - build-32


9 changes: 3 additions & 6 deletions .github/workflows/docker/buildwheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@ cd python
for V in "${PYTHON_VERSIONS[@]}"; do
PYBIN=/opt/python/$V/bin
rm -rf build/ # Avoid lib build by narrow Python is used by wide python
# Instead of letting setup.py install a newer numpy we install it here
# using the oldest supported version for ABI compatibility
$PYBIN/pip install oldest-supported-numpy
$PYBIN/python setup.py build_ext --inplace
$PYBIN/python setup.py bdist_wheel
$PYBIN/python -m pip install build
$PYBIN/python -m build --wheel
done

cd dist
for whl in *.whl; do
auditwheel repair "$whl"
rm "$whl"
done
done
2 changes: 1 addition & 1 deletion .github/workflows/docker/shared.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PYTHON_VERSIONS=(
cp312-cp312
cp311-cp311
cp310-cp310
cp39-cp39
cp38-cp38
)
40 changes: 24 additions & 16 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ on:

env:
COMMIT_EMAIL: [email protected]
DOXYGEN: true
MAKE_TARGET: -C python
OWNER: tskit-dev
REPO: tskit
REQUIREMENTS: python/requirements/CI-docs/requirements.txt
APTGET: doxygen

jobs:
build-deploy-docs:
name: Docs
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
Expand All @@ -28,33 +29,40 @@ jobs:

- uses: actions/checkout@v4

- name: Install apt deps
if: env.APTGET
run: sudo apt-get install -y ${{env.APTGET}}
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: tskit-docs-env
use-mamba: true

- uses: actions/setup-python@v5
- name: Cache Conda env
uses: actions/cache@v3
with:
python-version: "3.10"
cache: 'pip'
path: ${{ env.CONDA }}/envs
key: conda-${{ runner.os }}--${{ runner.arch }}--${{ hashFiles(env.REQUIREMENTS) }}-${{ env.CACHE_NUMBER }}
env:
CACHE_NUMBER: 0
id: cache

- name: Create venv and install deps
- name: Update environment
run: |
pip install --upgrade pip wheel
pip install -r ${{env.REQUIREMENTS}}
mamba install -y python=3.10 doxygen pip
pip install -r ${{ env.REQUIREMENTS }}
if: steps.cache.outputs.cache-hit != 'true'

- name: Build C module
if: env.MAKE_TARGET
run: |
make $MAKE_TARGET
run: make $MAKE_TARGET

- name: Build Docs
run: |
make -C docs
run: make -C docs

- name: Trigger docs site rebuild
if: github.ref == 'refs/heads/main'
run: |
curl -X POST https://api.github.com/repos/tskit-dev/tskit-site/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
-u AdminBot-tskit:${{ secrets.ADMINBOT_TOKEN }} \
--data '{"event_type":"build-docs"}'
--data '{"event_type":"build-docs"}'
7 changes: 1 addition & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: [ 3.8, 3.9, "3.11" ]
python: [ 3.9, 3.11 ]
os: [ macos-latest, ubuntu-latest, windows-latest ]
defaults:
run:
Expand Down Expand Up @@ -133,11 +133,6 @@ jobs:
conda activate anaconda-client-env
python setup.py build_ext --inplace
- name: Remove py311 incompatible tests (lack of numba support for 3.11, needed for lshmm)
if: matrix.python == '3.11'
run: |
rm python/tests/test_*matching*
- name: Run tests
working-directory: python
run: |
Expand Down
55 changes: 17 additions & 38 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
python: [3.8, 3.9, "3.10", 3.11]
python: [3.9, "3.10", 3.11, 3.12]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -25,21 +25,11 @@ jobs:
python-version: ${{ matrix.python }}
- name: Install deps
run: |
# Upgrade pip to get bdist_wheel
pip install --upgrade pip
pip install setuptools wheel
# Instead of letting setup.py install a newer numpy we install it here
# using the oldest supported version for ABI compatibility
pip install oldest-supported-numpy
- name: Build C extension
run: |
cd python
python -VV
python setup.py build_ext --inplace
pip install build
- name: Build Wheel
run: |
cd python
python setup.py bdist_wheel
python -m build --wheel
- name: Delocate to bundle dynamic libs
run: |
cd python
Expand All @@ -55,7 +45,7 @@ jobs:
runs-on: windows-latest
strategy:
matrix:
python: [3.8, 3.9, "3.10", 3.11]
python: [3.9, "3.10", 3.11, 3.12]
wordsize: [64]
steps:
- name: Checkout
Expand All @@ -66,12 +56,8 @@ jobs:
shell: bash
run: |
set -ex
${PYTHON} -m pip install --upgrade pip
${PYTHON} -m pip install setuptools wheel
# Instead of letting setup.py install a newer numpy we install it here
# using the oldest supported version for ABI compatibility
${PYTHON} -m pip install oldest-supported-numpy
- name: Build C Extension
${PYTHON} -m pip install build
- name: Build Wheel
env:
PYTHON: "py -${{ matrix.python }}-${{ matrix.wordsize }}"
shell: bash
Expand All @@ -86,15 +72,7 @@ jobs:
cp -r --dereference ../c/subprojects lib/.
cp -r --dereference ../c/tskit lib/.
cp ../c/tskit.h lib/.
${PYTHON} setup.py build_ext --inplace
- name: Build Wheel
env:
PYTHON: "py -${{ matrix.python }}-${{ matrix.wordsize }}"
shell: bash
run: |
set -ex
cd python
${PYTHON} setup.py bdist_wheel
${PYTHON} -m build --wheel
- name: Upload Wheels
uses: actions/upload-artifact@v4
with:
Expand All @@ -107,16 +85,17 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.9

- name: Build sdist
shell: bash
run: |
cd python
python setup.py sdist
python -m pip install build
python -m build --sdist
- name: Upload sdist
uses: actions/upload-artifact@v4
Expand All @@ -140,7 +119,7 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
python: [3.8, 3.9, "3.10", 3.11]
python: [3.9, "3.10", 3.11, 3.12]
steps:
- name: Download wheels
uses: actions/download-artifact@v4
Expand All @@ -162,7 +141,7 @@ jobs:
runs-on: windows-latest
strategy:
matrix:
python: [3.8, 3.9, "3.10", 3.11]
python: [3.9, "3.10", 3.11, 3.12]
wordsize: [64]
steps:
- name: Download wheels
Expand All @@ -186,17 +165,17 @@ jobs:
needs: ['manylinux']
strategy:
matrix:
python: [3.8, 3.9, "3.10", 3.11]
python: [3.9, "3.10", 3.11, 3.12]
include:

- python: 3.8
wheel: cp38
- python: 3.9
wheel: cp39
- python: "3.10"
wheel: cp310
- python: 3.11
wheel: cp311
- python: 3.12
wheel: cp312
steps:
- name: Download wheels
uses: actions/download-artifact@v4
Expand Down Expand Up @@ -234,4 +213,4 @@ jobs:
repository_url: https://test.pypi.org/legacy/
- name: Publish distribution to PRODUCTION PyPI
if: github.event_name == 'release' && !startsWith(github.event.release.tag_name, 'C_')
uses: pypa/gh-action-pypi-publish@release/v1
uses: pypa/gh-action-pypi-publish@release/v1
2 changes: 1 addition & 1 deletion c/tests/test_minimal_cpp.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* * MIT License
*
* Copyright (c) 2019-2023 Tskit Developers
* Copyright (c) 2019-2024 Tskit Developers
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion c/tskit.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2019 Tskit Developers
* Copyright (c) 2019-2024 Tskit Developers
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion c/tskit/tables.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2019-2023 Tskit Developers
* Copyright (c) 2019-2024 Tskit Developers
* Copyright (c) 2017-2018 University of Oxford
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
2 changes: 1 addition & 1 deletion python/lwt_interface/dict_encoding_testlib.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2018-2022 Tskit Developers
# Copyright (c) 2018-2024 Tskit Developers
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
67 changes: 67 additions & 0 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
[build-system]
requires = ["setuptools>=45", "wheel", "numpy>=2.0"]
build-backend = "setuptools.build_meta"

[project]
name = "tskit"
dynamic = ["version"]
authors = [
{name = "Tskit Developers", email = "[email protected]"},
]
description = "The tree sequence toolkit."
readme = "README.rst"
license = {text = "MIT"}
classifiers = [
"Programming Language :: C",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3 :: Only",
"Development Status :: 5 - Production/Stable",
"Environment :: Other Environment",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Operating System :: POSIX",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Bio-Informatics",
]
keywords = [
"population genetics",
"tree sequence",
"ancestral recombination graph",
"evolutionary tree",
"statistical genetics",
"phylogenetics",
"tskit",
]
requires-python = ">=3.9"
dependencies = [
"jsonschema>=3.0.0",
"numpy>=1.23.5",
"svgwrite>=1.1.10",
]

[project.urls]
Homepage = "https://tskit.dev/tskit"
Documentation = "https://tskit.dev/tskit/docs/stable"
Changelog = "https://tskit.dev/tskit/docs/stable/changelogs.html"
"Bug Tracker" = "https://github.com/tskit-dev/tskit/issues"
GitHub = "https://github.com/tskit-dev/tskit/"

[project.scripts]
tskit = "tskit.cli:tskit_main"

[tool.setuptools]
packages = ["tskit"]

[tool.setuptools.dynamic]
version = {attr = "tskit._version.tskit_version"}

[tool.pytest.ini_options]
addopts = "-n 4"
testpaths = ["tests"]
Loading

0 comments on commit ffead55

Please sign in to comment.