Welcome to mirror list, hosted at ThFree Co, Russian Federation.

make_py_wheel_mac.sh « python - github.com/marian-nmt/sentencepiece.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bc45fe8178f8d0783f2535667e16dfc8b1f486b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
# Copyright 2018 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.!

set -e  # exit immediately on error
set -x  # display all commands

build_python() {
  VERSION=$1
  URL=$2
  INSTALL_PATH="/Library/Frameworks/Python.framework/Versions/${VERSION}/bin"
  CURRENT_PATH=${PATH}

  curl -L -o python.pkg ${URL}
  sudo installer -pkg python.pkg -target /

  if [ -f "${INSTALL_PATH}/python3" ]; then
    ln -s ${INSTALL_PATH}/python3        ${INSTALL_PATH}/python
    ln -s ${INSTALL_PATH}/python3-config ${INSTALL_PATH}/python-config
    ln -s ${INSTALL_PATH}/pip3           ${INSTALL_PATH}/pip
  fi

  export PATH="${INSTALL_PATH}:${CURRENT_PATH}"
  ls -l ${INSTALL_PATH}
  which python
  which pip
  python --version
  sudo python get-pip.py --no-setuptools --no-wheel --ignore-installed
  pip install --upgrade setuptools
  pip install wheel
  pip install delocate
  python setup.py bdist_wheel --plat-name=macosx_10_6_x86_64
  python setup.py test
  delocate-listdeps dist/*.whl
  delocate-wheel -w dist/delocated_wheel dist/*.whl
  export PATH="${CURRENT_PATH}"

  ls -l dist/delocated_wheel
  rm -fr build
  rm -fr *.so
  rm -fr dist/*.whl
  rm -fr python.pkg
}

build() {
  cd python
  rm -fr build
  mkdir -p build
  cd build

  # Install sentencepiece
  cmake ../.. -DSPM_ENABLE_SHARED=OFF -DSPM_NO_THREADLOCAL=ON
  make -j4 VERBOSE=1
  make install
  cd ..

  mkdir -p dist/delocated_wheel
  curl -L -O https://bootstrap.pypa.io/get-pip.py

#  build_python 2.7 https://www.python.org/ftp/python/2.7.15/python-2.7.15-macosx10.6.pkg
# latest pip doesn't support Py3.4
# build_python 3.4 https://www.python.org/ftp/python/3.4.4/python-3.4.4-macosx10.6.pkg
  build_python 3.5 https://www.python.org/ftp/python/3.5.4/python-3.5.4-macosx10.6.pkg
  build_python 3.6 https://www.python.org/ftp/python/3.6.6/python-3.6.6-macosx10.6.pkg
  build_python 3.7 https://www.python.org/ftp/python/3.7.9/python-3.7.9-macosx10.9.pkg
  build_python 3.8 https://www.python.org/ftp/python/3.8.6/python-3.8.6-macosx10.9.pkg
  build_python 3.8 https://www.python.org/ftp/python/3.9.0/python-3.9.0-macosx10.9.pkg

  cd ..

  rm -fr build
}

build