mirror of
https://github.com/junjiem/dify-plugin-repackaging.git
synced 2025-12-08 16:22:28 +08:00
add MacOS supporting and cross-platform repacking (#22)
This commit is contained in:
22
README.md
22
README.md
@ -3,9 +3,15 @@
|
|||||||
|
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
|
||||||
Operating System: Linux amd64
|
Operating System: Linux amd64/aarch64, MacOS x86_64/arm64
|
||||||
|
|
||||||
|
**Notes**: The script uses `yum` to install `unzip` which is only avialable on RPM-based Linux systems(such as `Red Hat Enterprise Linux`, `CentOS`, `Fedora`, and `Oracle Linux`), and is now replaced by `dnf` in latest version. To use the script on other distributions, please install `unzip` command in advance.
|
||||||
|
|
||||||
|
**注意:**本脚本使用`yum`安装`unzip`命令,这只适用于基于RPM的Linux系统(如`Red Hat Enterprise Linux`, `CentOS`, `Fedora`, and `Oracle Linux`)。并且在较新的分发版中,它已被`dnf`所替代。
|
||||||
|
因此,当使用其他Linux分发版或者无法使用`yum`时,请事先安装`unzip`命令。
|
||||||
|
|
||||||
|
Python version: Should be as the same as the version in `dify-plugin-daemon` which is currently 3.12.x
|
||||||
|
|
||||||
Requires Python version is 3.11 or higher
|
|
||||||
|
|
||||||
#### Clone
|
#### Clone
|
||||||
```shell
|
```shell
|
||||||
@ -60,7 +66,13 @@ git clone https://github.com/junjiem/dify-plugin-repackaging.git
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
#### Platform Crossing Repacking
|
||||||
|
|
||||||
|
For repacking the plugins in different platforms between operating and running environment,
|
||||||
|
please using `-p` option with a pip platform string.
|
||||||
|
|
||||||
|
Typically, uses `manylinux2014_x86_64` for plugins running on an `x86_64/amd64` OS,
|
||||||
|
and `manylinux2014_aarch64` for `aarch64/arm64`.
|
||||||
|
|
||||||
### Update Dify platform env Dify平台放开限制
|
### Update Dify platform env Dify平台放开限制
|
||||||
|
|
||||||
@ -89,9 +101,3 @@ Visit the Dify platform's plugin management page, choose Local Package File to c
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Star history
|
|
||||||
|
|
||||||
[](https://star-history.com/#junjiem/dify-plugin-repackaging&Date)
|
|
||||||
|
|
||||||
|
|||||||
BIN
dify-plugin-darwin-amd64-5g
Executable file
BIN
dify-plugin-darwin-amd64-5g
Executable file
Binary file not shown.
BIN
dify-plugin-darwin-arm64-5g
Executable file
BIN
dify-plugin-darwin-arm64-5g
Executable file
Binary file not shown.
@ -14,12 +14,16 @@ cd $CURR_DIR
|
|||||||
CURR_DIR=`pwd`
|
CURR_DIR=`pwd`
|
||||||
USER=`whoami`
|
USER=`whoami`
|
||||||
ARCH_NAME=`uname -m`
|
ARCH_NAME=`uname -m`
|
||||||
|
OS_TYPE=$(uname)
|
||||||
|
OS_TYPE=$(echo "$OS_TYPE" | tr '[:upper:]' '[:lower:]')
|
||||||
|
|
||||||
CMD_NAME="dify-plugin-linux-amd64-5g"
|
CMD_NAME="dify-plugin-${OS_TYPE}-amd64-5g"
|
||||||
if [[ "arm64" == "$ARCH_NAME" || "aarch64" == "$ARCH_NAME" ]]; then
|
if [[ "arm64" == "$ARCH_NAME" || "aarch64" == "$ARCH_NAME" ]]; then
|
||||||
CMD_NAME="dify-plugin-linux-arm64-5g"
|
CMD_NAME="dify-plugin-${OS_TYPE}-arm64-5g"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
PIP_PLATFORM=""
|
||||||
|
|
||||||
market(){
|
market(){
|
||||||
if [[ -z "$2" || -z "$3" || -z "$4" ]]; then
|
if [[ -z "$2" || -z "$3" || -z "$4" ]]; then
|
||||||
echo ""
|
echo ""
|
||||||
@ -105,14 +109,27 @@ repackage(){
|
|||||||
echo "Unzip success."
|
echo "Unzip success."
|
||||||
echo "Repackaging ..."
|
echo "Repackaging ..."
|
||||||
cd ${CURR_DIR}/${PACKAGE_NAME}
|
cd ${CURR_DIR}/${PACKAGE_NAME}
|
||||||
pip download -r requirements.txt -d ./wheels --index-url ${PIP_MIRROR_URL}
|
pip download ${PIP_PLATFORM} -r requirements.txt -d ./wheels --index-url ${PIP_MIRROR_URL} --trusted-host mirrors.aliyun.com
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
echo "Pip download failed."
|
echo "Pip download failed."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
sed -i '1i\--no-index --find-links=./wheels/' requirements.txt
|
if [[ "linux" == "$OS_TYPE"]]; then
|
||||||
|
sed -i '1i\--no-index --find-links=./wheels/' requirements.txt
|
||||||
|
elif [[ "darwin" == "$OS_TYPE"]]; then
|
||||||
|
sed -i ".bak" '1i\
|
||||||
|
--no-index --find-links=./wheels/
|
||||||
|
' requirements.txt
|
||||||
|
rm -f requirements.txt.bak
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -f .difyignore ]; then
|
if [ -f .difyignore ]; then
|
||||||
sed -i '/^wheels\//d' .difyignore
|
if [[ "linux" == "$OS_TYPE"]]; then
|
||||||
|
sed -i '/^wheels\//d' .difyignore
|
||||||
|
elif [[ "darwin" == "$OS_TYPE"]]; then
|
||||||
|
sed -i ".bak" '/^wheels\//d' .difyignore
|
||||||
|
rm -f .difyignore.bak
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
cd ${CURR_DIR}
|
cd ${CURR_DIR}
|
||||||
chmod 755 ${CURR_DIR}/${CMD_NAME}
|
chmod 755 ${CURR_DIR}/${CMD_NAME}
|
||||||
@ -131,6 +148,20 @@ install_unzip(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print_usage() {
|
||||||
|
echo "usage: $0 [-p platform] {market|github|local}"
|
||||||
|
echo "-p platform: python packages' platform. Using for crossing repacking."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
while getopts "p:" opt; do
|
||||||
|
case "$opt" in
|
||||||
|
p) PIP_PLATFORM="--platform ${OPTARG} --only-binary=:all:"; shift $((OPTIND - 1)) ;;
|
||||||
|
*) print_usage; exit 1 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "$1"
|
||||||
case "$1" in
|
case "$1" in
|
||||||
'market')
|
'market')
|
||||||
market $@
|
market $@
|
||||||
@ -143,7 +174,7 @@ case "$1" in
|
|||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
||||||
echo "usage: $0 {market|github|local}"
|
print_usage
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
Reference in New Issue
Block a user