forked from gijzelaerr/python-snap7
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrepack_wheel.sh
More file actions
62 lines (53 loc) · 1.49 KB
/
repack_wheel.sh
File metadata and controls
62 lines (53 loc) · 1.49 KB
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
#!/bin/bash
set -e
echo $PWD
get_absolute_path () {
if [[ $1 == /* ]]
then
echo $1
else
echo "$PWD/${1#./}"
fi
}
unpack_wheel () {
local wheel=$1
local unpack_dir=$(mktemp -dt "tempdir.XXX")
local packagename=$(python3 -m wheel unpack $wheel -d $unpack_dir | sed -e 's/.*\/\(.*\)...OK/\1/')
echo $unpack_dir/$packagename
}
extract_lib () {
local wheel=$1
local package_path=$(unpack_wheel $wheel)
echo $package_path/$lib_src_path/$lib_name*.$lib_ext
}
repack_wheel () {
local wheel=$1
local lib_path=$2
local output_dir=$3
local package_path=$(unpack_wheel $wheel)
mkdir -p $package_path/$lib_dest_path
mv $lib_path $package_path/$lib_dest_path/$lib_name.$lib_ext
mkdir -p $output_dir
python3 -m wheel pack $package_path -d $output_dir
}
lib_dest_path=snap7/lib
lib_name=libsnap7
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
lib_src_path=python_snap7.libs/
lib_ext=so
ls_pattern=manylinux
else
lib_src_path=snap7/.dylibs/
lib_ext=dylib
ls_pattern=macosx
fi
# set absolute path for directories from args. Default value is current directory
platform_wheel_dir=$(get_absolute_path $1)
pure_wheel_dir=$(get_absolute_path $2)
output_dir=$(get_absolute_path $3)
echo $(ls -la $platform_wheel_dir)
platform_wheel=$(ls $platform_wheel_dir/*.whl | head -n1)
pure_wheel=$(ls $pure_wheel_dir/*.whl | head -n1)
lib_path=$(extract_lib $platform_wheel)
echo $lib_path
repack_wheel $pure_wheel $lib_path $output_dir