python-nanomsg 的安装

艾昊明
2023-12-01

一、 下载

nanomsg 最新版本 1.1.5,下载文件:1.1.5.tar.gz  下载地址:

https://github.com/nanomsg/nanomsg/releases

nanomsg-python 最新版本 1.0 下载文件:1.0.tar.gz  下载地址:
https://github.com/tonysimpson/nanomsg-python/releases

二、 编译,编译环境mac

nanomsg 编译

  tar zxvf 1.1.5.tar.gz
  cd nanomsg-1.1.5
  ./configure --prefix=../nanomsg
  make
  make install

nanomsg-python 编译

  tar zxvf 1.0.tar.gz
  cd nanomsg-python-1.0
  export C_INCLUDE_PATH=../nanomsg/include
  export LIBRARY_PATH=../nanomsg/lib
  python setup.py build
  python setup.py install

 

编译脚本 Build.sh  1.1.5.tar.gz  1.0.tar.gz 放在同一目录  注册设置 LD_LIBRARY_PATH 环境变量

参考编译脚本: Build.sh 

#!/bin/sh

DownloadNanoMsg()
{
  if [ ! -f nanomsg-1.1.5.tar.gz ]; then
    axel https://github.com/nanomsg/nanomsg/archive/1.1.5.tar.gz
  else
    echo "The file nanomsg-1.1.5.tar.gz already exists."
  fi
}

DownloadNanoMsgPython()
{
  if [ ! -f nanomsg-python-1.0.tar.gz ]; then
    axel https://github.com/tonysimpson/nanomsg-python/archive/1.0.tar.gz
  else
    echo "The file nanomsg-python-1.0.tar.gz already exists."
  fi
}

BuildNanoMsg()
{
  if [ ! -d './nanomsg-1.1.5' ]; then
    tar zxvf nanomsg-1.1.5.tar.gz
  fi
  if [ ! -d './nanomsg' ]; then
    cd nanomsg-1.1.5
    ./configure --prefix=../nanomsg
    make
    make install
    cd ..
  fi
}

BuildNanoMsgPython()
{
  if [ ! -d './nanomsg-python-1.0' ]; then
    tar zxvf nanomsg-python-1.0.tar.gz
  fi
  cd nanomsg-python-1.0
  export C_INCLUDE_PATH=../nanomsg/include
  export LIBRARY_PATH=../nanomsg/lib
  python setup.py build
  cd ..
}

InstallNanoMsg()
{
  cd nanomsg-python-1.0
  python setup.py install
  cd ..
  cp nanomsg/lib/libnanomsg.5.dylib ../venv/lib/
}

CleanNanoMsg()
{
  if [ -d './nanomsg' ]; then
    rm -rf ./nanomsg
  fi

  if [ -d './nanomsg-1.1.5' ]; then
    rm -rf ./nanomsg-1.1.5
  fi
}

CleanNanoMsgPython()
{
  if [ -d './nanomsg-python-1.0' ]; then
    rm -rf ./nanomsg-python-1.0
  fi
}

if [ "$1"x = "download"x ]; then
  DownloadNanoMsg
  DownloadNanoMsgPython
elif [ "$1"x = "build"x ]; then
  BuildNanoMsg
  BuildNanoMsgPython
elif [ "$1"x = "install"x ]; then
  InstallNanoMsg
elif [ "$1"x = 'clean'x ]; then
  CleanNanoMsg
  CleanNanoMsgPython
else
  echo "unknown operation."
  echo "./Build.sh download"
  echo "./Build.sh build"
  echo "./Build.sh install"
  echo "./Build.sh clean"
fi

 

 类似资料: