Skip to content

Commit 1673bbb

Browse files
committed
Fix builds for PyTorch
1 parent 66d9543 commit 1673bbb

File tree

5 files changed

+37
-98
lines changed

5 files changed

+37
-98
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1466,8 +1466,8 @@
14661466
<module>libpostal</module>
14671467
<module>libraw</module>
14681468
<module>leptonica</module>
1469-
<module>pytorch</module>
14701469
<module>tesseract</module>
1470+
<module>pytorch</module>
14711471
<module>sentencepiece</module>
14721472
</modules>
14731473
<properties>

pytorch/cppbuild.sh

+30-38
Original file line numberDiff line numberDiff line change
@@ -86,41 +86,33 @@ CPYTHON_PATH="${CPYTHON_PATH//\\//}"
8686
OPENBLAS_PATH="${OPENBLAS_PATH//\\//}"
8787
NUMPY_PATH="${NUMPY_PATH//\\//}"
8888

89-
export PYTHONNOUSERSITE=1
90-
91-
TOOLS="setuptools==67.6.1 pyyaml==6.0.1 typing_extensions==4.8.0"
92-
93-
if [[ $PLATFORM == $PLATFORM_HOST ]]; then
94-
if [[ -f "$CPYTHON_PATH/include/python3.12/Python.h" ]]; then
95-
# setup.py won't pick up the right libgfortran.so without this
96-
export LD_LIBRARY_PATH="$OPENBLAS_PATH/lib/:$CPYTHON_PATH/lib/:$NUMPY_PATH/lib/"
97-
export PYTHON_BIN_PATH="$CPYTHON_PATH/bin/python3.12"
98-
export PYTHON_INCLUDE_PATH="$CPYTHON_PATH/include/python3.12/"
99-
export PYTHON_LIB_PATH="$CPYTHON_PATH/lib/python3.12/"
100-
export PYTHON_INSTALL_PATH="$INSTALL_PATH/lib/python3.12/site-packages/"
101-
export SSL_CERT_FILE="$CPYTHON_PATH/lib/python3.12/site-packages/pip/_vendor/certifi/cacert.pem"
102-
chmod +x "$PYTHON_BIN_PATH"
103-
elif [[ -f "$CPYTHON_PATH/include/Python.h" ]]; then
104-
CPYTHON_PATH=$(cygpath $CPYTHON_PATH)
105-
OPENBLAS_PATH=$(cygpath $OPENBLAS_PATH)
106-
NUMPY_PATH=$(cygpath $NUMPY_PATH)
107-
export PATH="$OPENBLAS_PATH:$CPYTHON_PATH:$NUMPY_PATH:$PATH"
108-
export PYTHON_BIN_PATH="$CPYTHON_PATH/bin/python.exe"
109-
export PYTHON_INCLUDE_PATH="$CPYTHON_PATH/include/"
110-
export PYTHON_LIB_PATH="$CPYTHON_PATH/lib/"
111-
export PYTHON_INSTALL_PATH="$INSTALL_PATH/lib/site-packages/"
112-
export SSL_CERT_FILE="$CPYTHON_PATH/lib/pip/_vendor/certifi/cacert.pem"
113-
fi
114-
export PYTHONPATH="$PYTHON_INSTALL_PATH:$NUMPY_PATH/python/"
115-
mkdir -p "$PYTHON_INSTALL_PATH"
116-
117-
export CFLAGS="-I$CPYTHON_PATH/include/ -I$PYTHON_LIB_PATH/include/python/ -L$CPYTHON_PATH/lib/ -L$CPYTHON_PATH/libs/"
118-
$PYTHON_BIN_PATH -m pip install --target=$PYTHON_LIB_PATH $TOOLS
119-
else # cross-compile
120-
export PYTHON_BIN_PATH="$CPYTHON_HOST_PATH/bin/python3.12"
121-
chmod +x $PYTHON_BIN_PATH
122-
$PYTHON_BIN_PATH -m pip install --target="$CPYTHON_HOST_PATH/lib/python3.12/" $TOOLS
89+
CPYTHON_PATH=CPYTHON_HOST_PATH
90+
if [[ -f "$CPYTHON_PATH/include/python3.12/Python.h" ]]; then
91+
# setup.py won't pick up the right libgfortran.so without this
92+
export LD_LIBRARY_PATH="$OPENBLAS_PATH/lib/:$CPYTHON_PATH/lib/:$NUMPY_PATH/lib/"
93+
export PYTHON_BIN_PATH="$CPYTHON_PATH/bin/python3.12"
94+
export PYTHON_INCLUDE_PATH="$CPYTHON_PATH/include/python3.12/"
95+
export PYTHON_LIB_PATH="$CPYTHON_PATH/lib/python3.12/"
96+
export PYTHON_INSTALL_PATH="$INSTALL_PATH/lib/python3.12/site-packages/"
97+
export SSL_CERT_FILE="$CPYTHON_PATH/lib/python3.12/site-packages/pip/_vendor/certifi/cacert.pem"
98+
chmod +x "$PYTHON_BIN_PATH"
99+
elif [[ -f "$CPYTHON_PATH/include/Python.h" ]]; then
100+
CPYTHON_PATH=$(cygpath $CPYTHON_PATH)
101+
OPENBLAS_PATH=$(cygpath $OPENBLAS_PATH)
102+
NUMPY_PATH=$(cygpath $NUMPY_PATH)
103+
export PATH="$OPENBLAS_PATH:$CPYTHON_PATH:$NUMPY_PATH:$PATH"
104+
export PYTHON_BIN_PATH="$CPYTHON_PATH/bin/python.exe"
105+
export PYTHON_INCLUDE_PATH="$CPYTHON_PATH/include/"
106+
export PYTHON_LIB_PATH="$CPYTHON_PATH/lib/"
107+
export PYTHON_INSTALL_PATH="$INSTALL_PATH/lib/site-packages/"
108+
export SSL_CERT_FILE="$CPYTHON_PATH/lib/pip/_vendor/certifi/cacert.pem"
123109
fi
110+
export PYTHONPATH="$PYTHON_INSTALL_PATH:$NUMPY_PATH/python/"
111+
mkdir -p "$PYTHON_INSTALL_PATH"
112+
113+
export CFLAGS="-I$CPYTHON_PATH/include/ -I$PYTHON_LIB_PATH/include/python/ -L$CPYTHON_PATH/lib/ -L$CPYTHON_PATH/libs/"
114+
export PYTHONNOUSERSITE=1
115+
$PYTHON_BIN_PATH -m pip install --target=$PYTHON_LIB_PATH setuptools==67.6.1 pyyaml==6.0.1 typing_extensions==4.8.0
124116

125117
case $PLATFORM in
126118
linux-x86)
@@ -131,10 +123,6 @@ case $PLATFORM in
131123
export CC="gcc -m64"
132124
export CXX="g++ -m64"
133125
;;
134-
macosx-x86_64)
135-
export CC="clang"
136-
export CXX="clang++"
137-
;;
138126
macosx-arm64)
139127
export CC="clang"
140128
export CXX="clang++"
@@ -143,6 +131,10 @@ case $PLATFORM in
143131
export USE_QNNPACK=OFF # not compatible with arm64 as of PyTorch 2.1.2
144132
export CMAKE_OSX_DEPLOYMENT_TARGET=11.00 # minimum needed for arm64 support
145133
;;
134+
macosx-x86_64)
135+
export CC="clang"
136+
export CXX="clang++"
137+
;;
146138
windows-x86_64)
147139
if which ccache.exe; then
148140
export CC="ccache.exe cl.exe"

pytorch/platform/gpu/pom.xml

-6
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@
3131
<artifactId>openblas-platform</artifactId>
3232
<version>0.3.26-${project.parent.version}</version>
3333
</dependency>
34-
<dependency>
35-
<groupId>org.bytedeco</groupId>
36-
<artifactId>numpy-platform</artifactId>
37-
<version>1.26.3-${project.parent.version}</version>
38-
<optional>true</optional>
39-
</dependency>
4034
<dependency>
4135
<groupId>${project.groupId}</groupId>
4236
<artifactId>${javacpp.moduleId}</artifactId>

pytorch/platform/pom.xml

-6
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@
3030
<artifactId>openblas-platform</artifactId>
3131
<version>0.3.26-${project.parent.version}</version>
3232
</dependency>
33-
<dependency>
34-
<groupId>org.bytedeco</groupId>
35-
<artifactId>numpy-platform</artifactId>
36-
<version>1.26.3-${project.parent.version}</version>
37-
<optional>true</optional>
38-
</dependency>
3933
<dependency>
4034
<groupId>${project.groupId}</groupId>
4135
<artifactId>${javacpp.moduleId}</artifactId>

pytorch/pom.xml

+6-47
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@
2424
<artifactId>openblas</artifactId>
2525
<version>0.3.26-${project.parent.version}</version>
2626
</dependency>
27-
<dependency>
28-
<groupId>org.bytedeco</groupId>
29-
<artifactId>numpy</artifactId>
30-
<version>1.26.3-${project.parent.version}</version>
31-
<optional>true</optional>
32-
</dependency>
3327
</dependencies>
3428

3529
<build>
@@ -54,6 +48,12 @@
5448
<artifactId>numpy-platform</artifactId>
5549
<version>1.26.3-${project.parent.version}</version>
5650
</dependency>
51+
<dependency>
52+
<groupId>org.bytedeco</groupId>
53+
<artifactId>cpython</artifactId>
54+
<version>3.12.1-${project.parent.version}</version>
55+
<classifier>${os.name}-${os.arch}</classifier>
56+
</dependency>
5757
</dependencies>
5858
<configuration>
5959
<classPaths>
@@ -137,45 +137,4 @@
137137
</plugins>
138138
</build>
139139

140-
<!-- cross-compilation profile for macosx-arm64 builds on macosx-x86_64 CI machines -->
141-
<profiles>
142-
<profile>
143-
<id>pytorch-cross-compile</id>
144-
<activation>
145-
<property>
146-
<name>javacpp.platform</name>
147-
<value>macosx-arm64</value>
148-
</property>
149-
</activation>
150-
<build>
151-
<plugins>
152-
<plugin>
153-
<groupId>org.bytedeco</groupId>
154-
<artifactId>javacpp</artifactId>
155-
<dependencies>
156-
<dependency>
157-
<groupId>org.bytedeco</groupId>
158-
<artifactId>cpython</artifactId>
159-
<version>3.12.1-${project.parent.version}</version>
160-
<classifier>${os.name}-${os.arch}</classifier>
161-
</dependency>
162-
<!-- we need to exclude target cpython until we have a macosx-arm64 build -->
163-
<dependency>
164-
<groupId>org.bytedeco</groupId>
165-
<artifactId>numpy-platform</artifactId>
166-
<version>1.26.3-${project.parent.version}</version>
167-
<exclusions>
168-
<exclusion>
169-
<groupId>org.bytedeco</groupId>
170-
<artifactId>cpython</artifactId>
171-
</exclusion>
172-
</exclusions>
173-
</dependency>
174-
</dependencies>
175-
</plugin>
176-
</plugins>
177-
</build>
178-
</profile>
179-
</profiles>
180-
181140
</project>

0 commit comments

Comments
 (0)