Skip to content

Commit

Permalink
Change build backend to scikit_build "core" (#1284)
Browse files Browse the repository at this point in the history
* move most setup from setup.cfg to pyproject.toml
* Update CMakeLists to install compiled products.
  (Needed so that they end up in wheels.)
* Update CI and deployment work flows.
  • Loading branch information
molpopgen committed Apr 4, 2024
1 parent 24ee4d4 commit b39f6db
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 50 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/macos_x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,21 @@ jobs:
python -m pytest -n 4 tests
python -m pytest -n 2 tests_with_cpp
- name: Clean up build and venv
run: |
rm -rf build venv
- name: Test pip install from dist in fresh venv
run: |
python -m pip install build
python -m build -o dist -w .
cd dist
python -m venv venv
source venv/bin/activate
which python
python -m pip install --no-cache-dir ./fwdpy11*.whl
python -m fwdpy11 --includes
python -c "import fwdpy11;print(fwdpy11.__version__)"
python -c "import fwdpy11;print(fwdpy11.__file__)"
11 changes: 8 additions & 3 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ jobs:
run: |
cmake --build build -t test
- name: Clean cmake build
run: |
rm -rf build
- name: Manualy run setuptools_scm
run: |
python -m setuptools_scm
Expand Down Expand Up @@ -148,15 +152,16 @@ jobs:
- name: Test pip install from dist in fresh venv
run: |
python -m pip install --upgrade setuptools pip wheel build
python -m build . --config-setting=--disable_lto
python -m pip install build
python -m build -o dist -w .
cd dist
python -m venv venv
source venv/bin/activate
which python
# The CPPFLAGS contain stuff for C++ that makes no sense for C.
# The flags are also too strict for tskit to build under Py 3.12
CPPFLAGS= python -m pip install --no-cache-dir ./fwdpy11*-linux*.whl
ls
CPPFLAGS= python -m pip install --no-cache-dir ./fwdpy11*-*linux*.whl
python -m fwdpy11 --includes
python -c "import fwdpy11;print(fwdpy11.__version__)"
python -c "import fwdpy11;print(fwdpy11.__file__)"
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ include doc/fwdpp.doxygen
include doc/Makefile
recursive-include doc *.md *.png
recursive-include tests *.yaml
recursive-include tests_with_cpp *.txt *.cc *.py
2 changes: 2 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,5 @@ if (ENABLE_PROFILING)
set_target_properties(_fwdpy11 PROPERTIES CXX_VISIBILITY_PRESET "default")
endif()
target_link_libraries(_fwdpy11 PRIVATE GSL::gsl GSL::gslcblas fwdpy11core)
# The install directory is the output (wheel) directory
install(TARGETS _fwdpy11 DESTINATION fwdpy11)
12 changes: 6 additions & 6 deletions deployment/linux_wheels/wheel_workflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ git config --global --add safe.directory /project

# BUILD WHEEL INSIDE A VENV

$(which $PYTHON) -m venv venv
source venv/bin/activate
$(which $PYTHON) -m venv /venv
source /venv/bin/activate
python -m pip install --upgrade pip setuptools build
python -m build .
deactivate
rm -rf build venv
rm -rf build /venv

cd dist
for whl in *.whl; do
Expand All @@ -45,8 +45,8 @@ cd ..

# INSTALL WHEEL INTO VENV FOR TESTING

$(which $PYTHON) -m venv venv
source venv/bin/activate
$(which $PYTHON) -m venv /venv
source /venv/bin/activate
python -m pip install --upgrade pip
python -m pip install wheel
python -m pip install fwdpy11 --pre --no-cache-dir --only-binary fwdpy11 --find-links dist/wheelhouse
Expand All @@ -67,4 +67,4 @@ python -m pytest tests -n 4
rm -rf $TESTDIR
cd ..
deactivate
rm -rf venv
rm -rf /venv
2 changes: 1 addition & 1 deletion fwdpy11/_types/tree_iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__(
update_samples: bool = False,
ancient_samples: Union[List[int], np.ndarray] = None,
begin: float = 0.0,
end: Optional[float] = None
end: Optional[float] = None,
):
_end = end
if _end is None:
Expand Down
2 changes: 1 addition & 1 deletion fwdpy11/_types/variant_iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(
begin: float = 0.0,
end: Optional[float] = None,
include_neutral_variants: bool = True,
include_selected_variants: bool = True
include_selected_variants: bool = True,
):
if end is not None:
_end = end
Expand Down
2 changes: 1 addition & 1 deletion fwdpy11/discrete_demography.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def from_demes(
dg: typing.Union[str, demes.Graph],
burnin: int = 10,
*,
round_non_integer_sizes: typing.Optional[bool] = None
round_non_integer_sizes: typing.Optional[bool] = None,
) -> DemographicModelDetails:
"""
Build a :class:`fwdpy11.DemographicModelDetails` object using demes.
Expand Down
2 changes: 1 addition & 1 deletion fwdpy11/tskit_tools/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def from_table_row(cls, ind: tskit.IndividualTableRow):
**ind.metadata,
alive=alive,
preserved=preserved,
first_generation=first_generation
first_generation=first_generation,
)


Expand Down
2 changes: 2 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ add_library(fwdpy11core SHARED ${ALL_SOURCES})
add_dependencies(fwdpy11core cargo-build_fp11rust header)
target_link_libraries(fwdpy11core LINK_PRIVATE ${CMAKE_BINARY_DIR}/rust/libfp11rust.a)
target_link_libraries(fwdpy11core PRIVATE GSL::gsl GSL::gslcblas)
# The install directory is the output (wheel) directory
install(TARGETS fwdpy11core DESTINATION fwdpy11)
44 changes: 40 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,49 @@
[build-system]
# We need setup.cfg support, which setuptools indtroduced in 30.3.0.
requires = [
"setuptools>=30.3.0",
"wheel",
"setuptools_scm<8",
"scikit-build-core>=0.3.3",
"setuptools_scm>=8",
"pybind11[global]==2.11.1",
"cmake>=3.27.2"
]
build-backend = "setuptools.build_meta"
build-backend = "scikit_build_core.build"

[project]
name = "fwdpy11"
authors = [
{name = "Kevin R. Thornton", email = "krthornt@uci.edu"}
]
license = {text = "GNU GPL3+"}
description = "Forward-time population genetic simulation in Python"
readme = {file = "README.rst", content-type = "text/x-rst"}
classifiers = [
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering :: Bio-Informatics",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
]
dynamic = ["version"]
dependencies = [
"attrs >= 20.3.0",
"black",
"numpy < 2.0",
"scipy",
"tskit >= 0.5.6",
"demes ~= 0.2.2",
"Deprecated",
]
requires-python = ">=3.8, <3.13"

[project.scripts]
fwdpy11 = "fwdpy11.__main__:main"

[project.urls]
Repository = "https://github.com/molpopgen/fwdpy11"
Issues = "https://github.com/molpopgen/fwdpy11/issues"
Documentation = "https://molpopgen.github.io/fwdpy11"

[tool.scikit-build]
metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
sdist.include = ["fwdpy11/_version.py"]

[tool.setuptools_scm]
write_to = "fwdpy11/_version.py"
Expand Down
33 changes: 0 additions & 33 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,39 +1,6 @@
[metadata]
name = fwdpy11
author = Kevin R. Thornton
author_email = krthornt@uci.edu
license = GNU GPL3+
description = Forward-time population genetic simulation in Python
long_description = file: README.rst
long_description_content_type = text/x-rst
url = https://github.com/molpopgen/fwdpy11
classifiers =
Intended Audience :: Science/Research
Topic :: Scientific/Engineering :: Bio-Informatics
License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)

[options]
zip_safe = False # https://mypy.readthedocs.io/en/latest/installed_packages.html
include_package_data = True
python_requires = >=3.8, <3.13
# NOTE: any pinning should also be coordinated
# with requirements.in and doc/requirements.in
# and may require regenerating the .txt files.
install_requires =
attrs >= 20.3.0
black
numpy < 2.0
scipy
tskit >= 0.5.6
demes ~= 0.2.2
Deprecated
setup_requires =
setuptools
setuptools_scm

[options.entry_points]
console_scripts =
fwdpy11 = fwdpy11.__main__:main

[mypy]
files = fwdpy11
Expand Down

0 comments on commit b39f6db

Please sign in to comment.