Skip to content

Commit

Permalink
Update to version 4.3.0 and try to include headers in result.
Browse files Browse the repository at this point in the history
  • Loading branch information
rcurtin committed Dec 12, 2023
1 parent 1cf9c21 commit 86c0ba8
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 4 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/windows-arm64-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build Windows ARM64 wheels
on: [push]

env:
MLPACK_COMMIT: 4.2.1
MLPACK_COMMIT: 4.3.0
CIBW_TEST_COMMAND: python -c 'import mlpack; import numpy as np; x = np.random.rand(100, 10); o = mlpack.pca(input_=x, new_dimensionality=5, verbose=True)'

jobs:
Expand Down Expand Up @@ -87,6 +87,10 @@ jobs:
git clone https://github.com/mlpack/mlpack
cd mlpack
git checkout $MLPACK_VERSION
# Apply patches to install Python headers.
cp ../ConfigureFileOnly.cmake CMake/
cp ../mlpack.pc.in src/mlpack/bindings/python/
patch -p1 < ../python-install-headers.patch
- name: Generate setup.py
shell: powershell
Expand Down
11 changes: 11 additions & 0 deletions ConfigureFileOnly.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ConfigureFileOnly.cmake: generate an mlpack binding file given input
# arguments, using the @ONLY option.
#
# This file depends on the following variables being set:
#
# * GENERATE_CPP_IN: the .cpp.in file to configure.
# * GENERATE_CPP_OUT: the .cpp file we'll generate.
#
# Any other defined variables will be passed on to the file that is being
# generated.
configure_file(${GENERATE_CPP_IN} ${GENERATE_CPP_OUT} @ONLY)
7 changes: 6 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pipeline

environment
{
MLPACK_VERSION = '4.2.1'
MLPACK_VERSION = '4.3.0'
TWINE_PYPI_TOKEN = credentials('twine-pypi-token')
}

Expand All @@ -23,6 +23,11 @@ pipeline
cd mlpack/
git checkout $MLPACK_VERSION
# Apply patches.
cp ../ConfigureFileOnly.cmake CMake/
cp ../mlpack.pc.in src/mlpack/bindings/python/
patch -p1 < ../python-install-headers.patch
mkdir build/
cd build/
cmake -DBUILD_PYTHON_BINDINGS=ON ../
Expand Down
5 changes: 5 additions & 0 deletions azure-pipelines-macos-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ steps:
git clone https://github.com/mlpack/mlpack
cd mlpack
git checkout $(MLPACK_VERSION)
# Apply patches to install Python headers.
cp ../ConfigureFileOnly.cmake CMake/
cp ../mlpack.pc.in src/mlpack/bindings/python/
patch -p1 < ../python-install-headers.patch
displayName: Clone mlpack
- bash: |
Expand Down
5 changes: 5 additions & 0 deletions azure-pipelines-windows-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ steps:
git clone https://github.com/mlpack/mlpack
cd mlpack
git checkout $(MLPACK_VERSION)
# Apply patches to install Python headers.
cp ../ConfigureFileOnly.cmake CMake/
cp ../mlpack.pc.in src/mlpack/bindings/python/
patch -p1 < ../python-install-headers.patch
displayName: Clone mlpack
- powershell: |
Expand Down
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
timeoutInMinutes: 0 # No limit for build time.
pool: {vmImage: 'macOS-11'}
variables:
MLPACK_VERSION: 4.2.1
MLPACK_VERSION: 4.3.0
CIBW_TEST_COMMAND: python -c 'import mlpack; import numpy as np; x = np.random.rand(100, 10); o = mlpack.pca(input_=x, new_dimensionality=5, verbose=True)'
# The PYPI_TOKEN variable is automatically set by Azure Pipelines.
TWINE_PYPI_TOKEN: $(PYPI_TOKEN)
Expand Down Expand Up @@ -163,7 +163,7 @@ jobs:
timeoutInMinutes: 0 # No limit for build time.
pool: {vmImage: 'windows-2019'}
variables:
MLPACK_VERSION: 4.2.1
MLPACK_VERSION: 4.3.0
# The PYPI_TOKEN variable is automatically set by Azure Pipelines.
TWINE_PYPI_TOKEN: $(PYPI_TOKEN)
steps:
Expand Down
7 changes: 7 additions & 0 deletions mlpack.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
prefix=${pcfiledir}/../../
includedir=${prefix}/include

Name: mlpack
Description: a flexible, fast machine learning library
Version: @PACKAGE_VERSION@
Cflags: -I${includedir}
50 changes: 50 additions & 0 deletions python-install-headers.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
--- mlpack-4.3.0/src/mlpack/bindings/python/setup.py.in 2023-11-27 13:27:20.000000000 -0500
+++ mlpack-4.3.0-mod/src/mlpack/bindings/python/setup.py.in 2023-12-11 16:58:43.457383940 -0500
@@ -116,6 +116,12 @@
else '${DISABLE_CFLAGS}'.split(' ')) \
for name in pyxs]

+# Find all include files.
+include_files = []
+for (path, directories, filenames) in os.walk('include/'):
+ for filename in filenames:
+ include_files.append(os.path.join('..', path, filename))
+
setup(name='mlpack',
version='${PACKAGE_VERSION}',
description='a flexible, fast machine learning library',
@@ -141,6 +147,8 @@
install_requires=['cython>=0.24', 'numpy', 'pandas'],
package_dir={ '': '.' }, # Might be superfluous.
packages=['mlpack'],
+ package_data={ '': include_files + ['share/pkgconfig/mlpack.pc'] },
+ include_package_data=True,
cmdclass={ 'build_ext': build_ext },
ext_modules = modules,
setup_requires=['cython', 'pytest-runner'],
--- mlpack-4.3.0/src/mlpack/bindings/python/CMakeLists.txt 2023-11-27 13:27:20.000000000 -0500
+++ mlpack-4.3.0-mod/src/mlpack/bindings/python/CMakeLists.txt 2023-12-11 16:59:03.689447094 -0500
@@ -158,6 +158,23 @@
${CMAKE_CURRENT_SOURCE_DIR}/setup_readme.md
${CMAKE_BINARY_DIR}/src/mlpack/bindings/python/)

+# Copy all mlpack headers for inclusion in the package.
+add_custom_command(TARGET python_copy PRE_BUILD
+ COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory
+ ${CMAKE_SOURCE_DIR}/src/
+ ${CMAKE_BINARY_DIR}/src/mlpack/bindings/python/include/)
+
+# Generate pkgconfig file for easy use of included headers.
+add_custom_target(python_pkgconfig
+ COMMAND ${CMAKE_COMMAND}
+ -D GENERATE_CPP_IN=${CMAKE_SOURCE_DIR}/src/mlpack/bindings/python/mlpack.pc.in
+ -D GENERATE_CPP_OUT=${CMAKE_BINARY_DIR}/src/mlpack/bindings/python/share/pkgconfig/mlpack.pc
+ -D PACKAGE_VERSION="${PACKAGE_VERSION}"
+ -P "${CMAKE_SOURCE_DIR}/CMake/ConfigureFileOnly.cmake"
+ BYPRODUCTS "${CMAKE_BINARY_DIR}/src/mlpack/bindings/python/share/pkgconfig/mlpack.pc"
+ COMMENT "Configuring Python mlpack.pc...")
+add_dependencies(python_copy python_pkgconfig)
+
if (BUILD_TESTS)
foreach(test_file ${TEST_SOURCES})
add_custom_command(TARGET python_copy PRE_BUILD

0 comments on commit 86c0ba8

Please sign in to comment.