当前位置: 首页 > news >正文

湖北海厦建设有限公司网站长沙网站推广工具

湖北海厦建设有限公司网站,长沙网站推广工具,wordpress需要多大内存,网站哪家做的比较好的前提条件#xff1a; 确保电脑已经安装gcc且终端能检索到确保Python中已经安装cython包#xff0c;若未安装#xff0c;则先使用pip install cython进行安装 打包方法#xff1a; step1#xff1a;编写编译脚本setup.py#xff0c;代码如下#xff1a; # encoding ut…前提条件 确保电脑已经安装gcc且终端能检索到确保Python中已经安装cython包若未安装则先使用pip install cython进行安装 打包方法 step1编写编译脚本setup.py代码如下 # encoding utf-8 from distutils.core import setup from Cython.Build import cythonize setup( name libname, ext_modules cythonize([file1.py, file2.py, dir/file3.py], language_level 3) )step2终端中执行: python3 setup.py build_ext需要注意的点 setup()中的ext_modules不是exe_modules千万不要打错了如果打错了你会发现只编译成了.c文件而没用生成.so生成的.so只能在打包计算机相同系统、相同平台及相同python版本环境下使用要想在其他平台或环境下使用需要在指定平台或环境下重新打包存在多个python版本时如在linux下博主python2和python3共存需要指定编译用的python版本否则终端会报警告FutureWarning: Cython directive ‘language_level’ not set, using 2 for now (Py2)。指定版本有两种方式 method 1: 在每个要打包的py文件头部写入# cython:language_level3 method 2: 像上述setup.py中一样在cythonize函数中加入language_level 3选项 打包完的.so文件结构会被打乱如上述dir中的file3.py生成的file3.so与其他两个同目录而不是在dir文件夹下如果不做调整执行脚本时可能存在import错误因此还要手动调整一下文件结构 附批量打包的代码 import os import sys import shutil import numpy import tempfilefrom setuptools import setup from setuptools.extension import Extensionfrom Cython.Build import cythonize from Cython.Distutils import build_ext import platform# code from: https://blog.csdn.net/qq_33375598/article/details/118677130# 构建后存放的文件目录 build_root_dir build/lib. platform.system().lower() - platform.machine() - str(sys.version_info.major) . str(sys.version_info.minor)print(build_root_dir)extensions [] ignore_folders [build, test, tests] conf_folders [conf]def get_root_path(root):if os.path.dirname(root) in [, .]: # 得到文件的文件路径return os.path.basename(root) # 返回path最后的文件名else:return get_root_path(os.path.dirname(root))def copy_file(src, dest):if os.path.exists(dest): # 目的文件存在返回returnif not os.path.exists(os.path.dirname(dest)): # 目的文件夹不存在递归创建文件夹os.makedirs(os.path.dirname(dest))if os.path.isdir(src): # 判断某一路径是否为目录shutil.copytree(src, dest) # 拷贝整个文件夹(目的文件夹需要不存在否则会失败)else:shutil.copyfile(src, dest) # 拷贝整个文件def touch_init_file(): # 在临时文件夹中创建initinit_file_name os.path.join(tempfile.mkdtemp(), __init__.py)with open(init_file_name, w):passreturn init_file_nameinit_file touch_init_file() print(init_file)def compose_extensions(root.):for file_ in os.listdir(root): # 当前目录下的所有文件abs_file os.path.join(root, file_) # 路径拼接if os.path.isfile(abs_file):if abs_file.endswith(.py):extensions.append(Extension(get_root_path(abs_file) .*, [abs_file]))elif abs_file.endswith(.c) or abs_file.endswith(.pyc):continueelse:copy_file(abs_file, os.path.join(build_root_dir, abs_file))if abs_file.endswith(__init__.py): # 用空白的__init__.py替代原有的copy_file(init_file, os.path.join(build_root_dir, abs_file))else:if os.path.basename(abs_file) in ignore_folders: # 忽略的文件不拷贝continueif os.path.basename(abs_file) in conf_folders: # 配置文件一同拷贝copy_file(abs_file, os.path.join(build_root_dir, abs_file))compose_extensions(abs_file)compose_extensions() os.remove(init_file)setup(nameyour_project_name,version1.0,ext_modulescythonize(extensions,nthreads16,compiler_directivesdict(always_allow_keywordsTrue),include_path[numpy.get_include()], language_level3),cmdclassdict(build_extbuild_ext))参考链接 https://blog.csdn.net/qq_33375598/article/details/118677130https://blog.csdn.net/weixin_36755535/article/details/127300870
http://www.zqtcl.cn/news/100737/

相关文章:

  • 苏州新区做网站公司pc网站建设费用
  • 做影视网站需要多少钱2003网站建设
  • 河南智能网站建设哪家好重庆在建工程项目
  • 爱站网站长工具网站查看空间商
  • 网站营销活动页面制作wordpress 只显示一个主题
  • 电子网站建设怎么做秦皇岛网站制作公司
  • 网站建站模板样例平台推广怎么做
  • 网站建设首选亿企联盟做网站宣传有用吗
  • 网站建设公司行业苏州高端网站建设咨询
  • 电商平台网站开发过程江苏省建设科技发展中心网站简介
  • 空间租用 网站开发重庆手机网站推广资料
  • 新余 网站建设网站建设行业新闻
  • 做301网站打不开网上智慧团建网站
  • 四川省住房与城乡建设厅官方网站免费域名解析ip
  • 芜湖网站建设价格这么做网站原型图
  • 做传奇网站怎么弄的南京微网站开发
  • 网站建设基础教程人教版网站域名选择的原则
  • u盘做网站网站建设公司公司介绍
  • 嘉兴网站排名优化报windows wordpress 轻量级
  • html5网站开发方案海珠网站建设公
  • 津做网站建筑网课平台
  • 佛山制作手机网站汕头网站定制
  • 网站域名解释怎么做济南集团网站建设
  • 网站怎么做咨询网站开发商
  • 建立网站的第一步网站的管理系统
  • 安远做网站做宣传册网站
  • 网站建设概况君隆网站建设
  • 富源县住房和城乡建设局网站备案信息 网站名
  • 做门窗的网站宁波附近的seo推广
  • 上海网站建设解决方案怎样设计网站