Skip to content

Commit

Permalink
Bump for numpy2 rebuild.
Browse files Browse the repository at this point in the history
  • Loading branch information
rcurtin committed Jul 24, 2024
1 parent 026e481 commit fdd7748
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/windows-arm64-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ jobs:
git clone https://github.com/mlpack/mlpack
cd mlpack
git checkout $MLPACK_VERSION
sed -i.bk 's/${PACKAGE_VERSION}/${PACKAGE_VERSION}.post1/g' src/mlpack/bindings/python/setup.py.in
rm -f src/mlpack/bindings/python/setup.py.in.bk
patch -p1 < ../numpy2.patch
- name: Generate setup.py
shell: powershell
Expand Down
6 changes: 6 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ pipeline
cd mlpack/
git checkout $MLPACK_VERSION
# Temporary patch: increment build number.
sed -i.bk 's/${PACKAGE_VERSION}/${PACKAGE_VERSION}.post1/g' src/mlpack/bindings/python/setup.py.in
rm -f src/mlpack/bindings/python/setup.py.in.bk
# Apply patches.
patch -p1 < ../numpy2.patch
mkdir build/
cd build/
cmake -DBUILD_PYTHON_BINDINGS=ON ../
Expand Down
6 changes: 6 additions & 0 deletions azure-pipelines-macos-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ steps:
git clone https://github.com/mlpack/mlpack
cd mlpack
git checkout $(MLPACK_VERSION)
# Temporary patch: increment build number.
sed -i.bk 's/${PACKAGE_VERSION}/${PACKAGE_VERSION}.post1/g' src/mlpack/bindings/python/setup.py.in
rm -f src/mlpack/bindings/python/setup.py.in.bk
# Apply patches.
patch -p1 < ../numpy2.patch
displayName: Clone mlpack
- bash: |
Expand Down
6 changes: 6 additions & 0 deletions azure-pipelines-windows-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ steps:
git clone https://github.com/mlpack/mlpack
cd mlpack
git checkout $(MLPACK_VERSION)
# Temporary patch: increment build number.
sed -i.bk 's/${PACKAGE_VERSION}/${PACKAGE_VERSION}.post1/g' src/mlpack/bindings/python/setup.py.in
rm -f src/mlpack/bindings/python/setup.py.in.bk
# Apply patches.
patch -p1 < ../numpy2.patch
displayName: Clone mlpack
- powershell: |
Expand Down
14 changes: 14 additions & 0 deletions numpy2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--- mlpack-4.4.0/src/mlpack/bindings/python/mlpack/matrix_utils.py 2024-05-28 16:08:34.000000000 -0400
+++ mlpack/src/mlpack/bindings/python/mlpack/matrix_utils.py 2024-07-24 17:22:50.872603391 -0400
@@ -160,7 +160,10 @@
dims = len(x)

d = np.zeros([dims])
- out = np.array(x, dtype=dtype, copy=copy) # Try to avoid copy...
+ if np.lib.NumpyVersion(np.__version__) >= '2.0.0b1':
+ out = np.array(x, dtype=dtype, copy=(True if copy else None))
+ else:
+ out = np.array(x, dtype=dtype, copy=copy)

# Since we don't have a great way to check if these are using the same
# memory location, we will probe manually (ugh).

0 comments on commit fdd7748

Please sign in to comment.