-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build Python wheels for Windows (#260)
* Build Python wheels for Windows * Update Python README * Pin OS version when building wheels
- Loading branch information
1 parent
43df18f
commit 93a41a2
Showing
7 changed files
with
61 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,19 @@ | ||
import sys | ||
|
||
if sys.platform == "win32": | ||
import os | ||
import ctypes | ||
import pkg_resources | ||
|
||
module_name = sys.modules[__name__].__name__ | ||
package_dir = pkg_resources.resource_filename(module_name, "") | ||
|
||
add_dll_directory = getattr(os, "add_dll_directory", None) | ||
if add_dll_directory is not None: | ||
add_dll_directory(package_dir) | ||
|
||
for filename in os.listdir(package_dir): | ||
if filename.endswith(".dll"): | ||
ctypes.CDLL(os.path.join(package_dir, filename)) | ||
|
||
from ._ext import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
bindings/python/tools/prepare_build_environment_windows.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#! /bin/bash | ||
|
||
set -e | ||
set -x | ||
|
||
ROOT_DIR=$PWD | ||
ICU_VERSION=${ICU_VERSION:-69.1} | ||
|
||
curl -L -O -nv https://github.com/unicode-org/icu/releases/download/release-${ICU_VERSION/./-}/icu4c-${ICU_VERSION/./_}-Win64-MSVC2019.zip | ||
unzip *.zip -d icu | ||
|
||
rm -rf build | ||
mkdir build | ||
cd build | ||
cmake -DLIB_ONLY=ON -DICU_ROOT=$ROOT_DIR/icu/ -DCMAKE_INSTALL_PREFIX=$TOKENIZER_ROOT .. | ||
cmake --build . --config Release --target install | ||
|
||
cp $ROOT_DIR/icu/bin64/icudt*.dll $ROOT_DIR/bindings/python/pyonmttok/ | ||
cp $ROOT_DIR/icu/bin64/icuuc*.dll $ROOT_DIR/bindings/python/pyonmttok/ | ||
cp $TOKENIZER_ROOT/bin/OpenNMTTokenizer.dll $ROOT_DIR/bindings/python/pyonmttok/ |