39.集群环境共享
1.
--py-files get_ctx.py,get_distance.so,depend.zip
需要配置集群上依赖的环境
/home/makexu/test/data
    build.sh
    get_distance.pyx
    req.txt
    pack.sh
    setup.py
1.编写算法pyx代码
        
2.编写set_up.py文件
        
        #!/usr/bin/env python
        # encoding=utf-8
        
        from distutils.core import setup
        from Cython.Build import cythonize
        #cythonize:编译源代码为C或C++,返回一个distutils Extension对象列表
        setup(ext_modules=cythonize('get_distance.pyx'))
3.执行build脚本
        
        #!/bin/bash
        python setup.py build_ext --inplace
4.生成环境依赖文件
        
        pip freeze > req.txt
5.打包环境依赖
        pip install --process-dependency-links --upgrade --target=depend -r req.txt
6.生成zip文件
        
        cd depend
        zip -9mrv ../depend.zip .
7.最终文件列表
        build
        build.sh
        depend
        depend.zip
        get_distance.c
        get_distance.pyx
        get_distance.so
        req.txt
        setup.py
6.spark集群启动--py-files配置
        --py-files get_ctx.py,get_distance.so,depend.zip
7.app中使用算法
        from get_distance import calc_dis_int
    http://www.cnblogs.com/makexu/

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号