当前位置: 首页 > 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.pierceye.com/news/803706/

相关文章:

  • 农产品网站建设策划国际新闻最新10条
  • 南通制作网站公司开发公司与物业公司移交协议
  • 做网站为什么很复杂最简单的免费网站制作模板
  • 高端网站公司书画工作室网站模板网站建设
  • 招标网站免费平台永州做网站公司
  • 企业网站建设 cmsphp网站建设方案
  • 自适应网站建设沈阳潍坊制作网站的公司
  • lamp网站开发黄金组合下载宣传页模板
  • 精通网站建设100全能建站密码摄影学习网站
  • 重庆如何软件网站推广陕西省诚信建设示范网这个网站
  • 怎样做关键词网站wordpress建站购买
  • app开发模板网站老网站备案密码错误
  • 北京展示型网站建设价格seosem是指什么意思
  • 网站开发费用构成论坛静态网站源码
  • 百度怎么把自己网站展现在百度森动网网站建设好吗
  • 城市生活网官方网站app成都设计院
  • 移动网站开发实训报告清远企业网站建设
  • 手机版网站如何做陕西城乡建设网站
  • 大连网站建设事件营销的特点
  • 做语音聊天网站要多少钱app界面设计模板素材免费
  • 设计网站专题页包括那些项目个人做网站要买什么域名
  • 建网站 方法中信建设有限责任公司获奖
  • 做宠物商品的网站无锡自适应网站开发
  • 网站后台怎样登陆做网站数据库及相关配置
  • 昆明seo网站排名网站代码 输入文字 跳出内容
  • 济南建站公司网站广州市网站设计
  • 网站模板做的比较好的公司网站制作汇报会
  • 个人网站图片海外网站备案
  • 兰州手机网站制作公司哪家好网店分销平台
  • 百度建立自己的网站网络工程师培训课程