zoukankan      html  css  js  c++  java
  • 编译可移植的python

    1. 在低版本系统机器上,编译python:
      cd  Python-2.7.15/Modules
      vim Setup.dist
      修改下述代码:
      ###########
    sed -i 's/#SSL=/usr/local/ssl/SSL=/usr/local/ansible_python/openssl_for_python/g' Modules/Setup.dist
    sed -i 's/#_ssl _ssl.c/_ssl _ssl.c/g' Modules/Setup.dist
    sed -i 's/#	-DUSE_SSL/	-DUSE_SSL/g' Modules/Setup.dist
    sed -i 's/#	-L$(SSL)/	-L$(SSL)/g' Modules/Setup.dist
    sed -i 's/#_md5 md5module.c md5.c/_md5 md5module.c md5.c/g' Modules/Setup.dist
    sed -i 's/#zlib zlibmodule.c/zlib zlibmodule.c/g' Modules/Setup.dist
    sed -i 's/#binascii binascii.c/binascii binascii.c/g' Modules/Setup.dist
    sed -i 's/#_sha1 sha1module.c/_sha1 sha1module.c/g' Modules/Setup.dist
    sed -i 's/#_sha256 sha256module.c/_sha256 sha256module.c/g' Modules/Setup.dist
    sed -i 's/#_sha512 sha512module.c/_sha512 sha512module.c/g' Modules/Setup.dist
    ############
    2. 指定openssl库
      编译新的openssl库
      cd  openssl-1.0.2o
      ./configure  --prefix=/usr/local/ansible_python/openssl_for_python
      make
      make install
    3. 由于python编译的时候需要去/usr/local/ssl/目录下寻找openssl库(具体可看setup.py),所以需要创建新编译openssl的软链接
      ln  -s  /usr/local/ansible_python/openssl_for_python  /usr/local/ssl
    4. cd Python-2.7.15
      ./configure  –prefix=/usr/local/ansible_python/python
      make
      make install
      安装完成后,可以安装anshible等模块,方便移植
    5. 将自己编译的openssl库放进系统共享库
       echo  “/usr/local/ansible_python/openssl_for_ansible/lib” >> /etc/ld.so.conf.d/ansible.conf
    ldconfig
    6. 压缩编译好的python和openssl,以便于移植 tar -cvjf ansible_python.tar.bz2 ansible_python 7. 将压缩包拷贝到新机器上/tmp目录后,解压 /tmp/ansible_python.tar.bz2 tar -xvjf /tmp/ansible_python.tar.bz2 得到 /tmp/ansible_python 8. 拷贝文件 cp -r /tmp/ansible_python /usr/local/ 9. 修改权限,使普通用户具有执行权限 chown -R ops:ops /usr/local/ansible_python/openssl_for_ansible/ chmod 755 /usr/local/ansible_python/python/bin/* 10. 创建指定的ssl库的软链 ln -s /usr/local/ansible_python/openssl_for_ansible/ /usr/local/ssl 11. 将指定的ssl库添加到系统共享库 echo “/usr/local/ansible_python/openssl_for_ansible/lib” >> /etc/ld.so.conf.d/ansible.conf 12. 执行命令 ldconfig 13. 此时新python已经可以使用 /usr/local/ansible_python/python/bin/python

    二、安装python3.8

    首先安装依赖库文件

    1.安装openssl

    cd /tmp/openssl-1.1.1g
    
    ./config enable-ec_nistp_64_gcc_128 -Wl,--enable-new-dtags,-rpath,'$(LIBRPATH)' --prefix=/usr/local/python38/openssl
    
    make
    
    make install

    2.将新安装的openssl加入到动态链接库

    vim /etc/ld.so.conf.d/python38.conf

    /usr/local/python38/openssl/lib

    ldconfig

    3.安装python3.8

    3.1 修改Modules/Setup

    将以下部分取消注释
    # Socket module helper for socket(2)
    _socket socketmodule.c
    
    # Socket module helper for SSL support; you must comment out the other
    # socket line above, and possibly edit the SSL variable:
    SSL=/usr/local/python38/openssl
    _ssl _ssl.c 
            -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl 
            -L$(SSL)/lib -lssl -lcrypto

    3.2. 编译安装python3.8

    cd  /tmp/Python-3.8.5
    
    ./configure --prefix=/usr/local/python38/python38  --with-openssl=/usr/local/python38/openssl
    make make install
  • 相关阅读:
    驱动编程杂谈
    mysql数据库之视图
    mysql编程
    添加内核编译选项
    内核编译遇到的一些问题
    jffs2和yaffs2文件系统
    宿主机挂载和使用嵌入式文件系统
    只读文件系统
    Makefile的简单编写
    UITableview delegate dataSource调用探究
  • 原文地址:https://www.cnblogs.com/wt11/p/9437784.html
Copyright © 2011-2022 走看看