Skip to content

Commit 0eb24d2

Browse files
committed
docs: add windows build instructions
1 parent 9263680 commit 0eb24d2

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

python/README.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Python wrapper for SentencePiece. This API will offer the encoding, decoding and training of Sentencepiece.
44

55
## Build and Install SentencePiece
6-
For Linux (x64/i686), macOS, and Windows(win32/x64) environment, you can simply use pip command to install SentencePiece python module.
6+
For Linux (x64/i686), macOS, and Windows(win32/x64/arm64) environment, you can simply use pip command to install SentencePiece python module.
77

88
```
99
% pip install sentencepiece
@@ -27,6 +27,20 @@ If you don’t have write permission to the global site-packages directory or do
2727
% python setup.py install --user
2828
```
2929

30+
For Windows users who want to build from source, you can build and install the Python wrapper using Visual Studio. First, you need to install the `pwsh.exe` (Powershell 7). Use `winget install --id Microsoft.Powershell --source winget` to install directly. Then open the `Developer PowerShell for VS 2022`, and execute the following commands.
31+
```
32+
git clone https://github.com/google/sentencepiece.git
33+
cd sentencepiece
34+
mkdir build
35+
cd build
36+
cmake .. -DSPM_ENABLE_SHARED=OFF -DCMAKE_INSTALL_PREFIX=".\root"
37+
cmake --build . --config Release --target install
38+
cd ../python
39+
pip install wheel
40+
python setup.py bdist_wheel
41+
Get-ChildItem .\dist\sentencepiece*.whl | ForEach-Object { pip install $_.FullName }
42+
```
43+
3044
## Usage
3145

3246
See [this google colab page](https://github.com/google/sentencepiece/blob/master/python/sentencepiece_python_module_example.ipynb) to run sentencepiece interactively.

0 commit comments

Comments
 (0)