Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
fengzch-das
multibuild
Commits
0714f52e
Unverified
Commit
0714f52e
authored
Dec 08, 2023
by
Matti Picus
Committed by
GitHub
Dec 08, 2023
Browse files
Merge pull request #519 from matthew-brett/python-on-macos
Try PYTHON_EXE and python3 if no python
parents
14c305ae
e64bc440
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
6 deletions
+17
-6
common_utils.sh
common_utils.sh
+17
-6
No files found.
common_utils.sh
View file @
0714f52e
#!/bin/bash
# Utilities for both OSX and Docker Linux
#
P
ython should be on the PATH
#
python or p
ython
3
should be on the PATH
# Only source common_utils once
if
[
-n
"
$COMMON_UTILS_SOURCED
"
]
;
then
...
...
@@ -78,20 +78,31 @@ function stop_spinner {
>
&2
echo
"Building libraries finished."
}
function
any_python
{
for
cmd
in
$PYTHON_EXE
python3 python
;
do
if
[
-n
"
$(
type
-t
$cmd
)
"
]
;
then
echo
$cmd
return
fi
done
echo
"Could not find python or python3"
exit
1
}
function
abspath
{
# Can work with any Python; need not be our installed Python.
python
-c
"import os.path; print(os.path.abspath('
$1
'))"
$(
any_
python
)
-c
"import os.path; print(os.path.abspath('
$1
'))"
}
function
relpath
{
# Path of first input relative to second (or $PWD if not specified)
# Can work with any Python; need not be our installed Python.
python
-c
"import os.path; print(os.path.relpath('
$1
','
${
2
:-
$PWD
}
'))"
$(
any_
python
)
-c
"import os.path; print(os.path.relpath('
$1
','
${
2
:-
$PWD
}
'))"
}
function
realpath
{
# Can work with any Python; need not be our installed Python.
python
-c
"import os; print(os.path.realpath('
$1
'))"
$(
any_
python
)
-c
"import os; print(os.path.realpath('
$1
'))"
}
function
lex_ver
{
...
...
@@ -405,13 +416,13 @@ function pip_opts {
function get_os {
# Report OS as given by uname
# Use any Python that comes to hand.
python -c 'import platform; print(platform.uname()[0])'
$(
any_
python
)
-c 'import platform; print(platform.uname()[0])'
}
function get_platform {
# Report platform as given by uname
# Use any Python that comes to hand.
python -c 'import platform; print(platform.uname()[4])'
$(
any_
python
)
-c 'import platform; print(platform.uname()[4])'
}
if [ "
$(
get_platform
)
" == x86_64 ] ||
\
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment