File: install_python.sh

package info (click to toggle)
imath 3.1.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,468 kB
  • sloc: cpp: 44,687; ansic: 171; sh: 153; python: 60; makefile: 32
file content (43 lines) | stat: -rwxr-xr-x 1,234 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env bash

# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) Contributors to the OpenEXR Project.

set -ex

PYTHON_VERSION="$1"
PYTHON_MAJOR="$(echo ${PYTHON_VERSION} | cut -f 1 -d .)"

MACOS_MAJOR="$(sw_vers -productVersion | cut -f 1 -d .)"
MACOS_MINOR="$(sw_vers -productVersion | cut -f 2 -d .)"

echo "Installing Python ${PYTHON_VERSION} Major ${PYTHON_MAJOR}"

# This workaround is needed for building Python on macOS >= 10.14:
#   https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes

if [[ "$MACOS_MAJOR" -gt 9 && "$MACOS_MINOR" -gt 13 ]]; then
    sudo installer \
        -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_${MACOS_MAJOR}.${MACOS_MINOR}.pkg \
        -target /
fi

unset CFLAGS

brew update
brew install pyenv openssl 

CFLAGS="-I/usr/local/Cellar/openssl/1.0.2s/include"
LDFLAGS="-L/usr/local/Cellar/openssl/1.0.2s/lib"

echo 'eval "$(pyenv init -)"' >> .bash_profile
source .bash_profile
env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install -v ${PYTHON_VERSION}
pyenv global ${PYTHON_VERSION}

sudo pip install --upgrade pip
if [[ $PYTHON_MAJOR -eq 2 ]]; then
    sudo pip install numpy
else
    sudo pip3 install numpy
fi