python簡單製作whl安裝包

2021-10-22 13:26:54 字數 1875 閱讀 7981

(如cal_similarity)裡面包括以下五個簡單的檔案:

__init__.py         :用於說明這個資料夾是乙個python 的package包(可以為空檔案)

cal_similarity.py :這個是要打包的測試檔案

license           :這個是要打包支援的開源協議(可以為空檔案)

setup.py             :這個指令碼檔案使用setuptools對自己的檔案進行打包

readmed.md   :這個是對專案的一些使用方法的一些說明檔案(可以為空檔案)

資料夾內容如下:

為了簡單,我們假定其他都是空檔案,cal_similarity.py 和setup.py不為空檔案

cal_similarity.py的檔案是我們自己編寫的檔案:

def hello():

print("hello yes!!!")

setup.py 檔案內容是設定一些打包的配置資訊,打包任務需要重點掌握的地方

#!/usr/bin/env python

# coding=utf-8

from setuptools import setup, find_packages

# python setup.py sdist 打包成tar.gz的形式

# python setup.py bdist_wheel 打包成wheel格式

setup(

py_modules=["cal_similarity"], #需要打包的資料夾下的py檔案名詞cal_similarity.py

packages=find_packages(), #需要打包的目錄列表

name="cal_similarity", #包名稱,也就是資料夾名稱

version="1.0.0", #包的版本

description="cal_similar between two word", #對當前package的較短總結

long_description="***", #對當前package的詳細說明

author="yin", #作者姓名

author_email="72666*@qq.com", #作者郵箱

install_requires=['numpy'], #第三方依賴,這些依賴包會在程式安裝的時候也會安裝

zip_safe=false, #此項需要,否則解除安裝報windows error錯誤

license="mit licence", #支援的開源協議

python_requires=">=3.4.0", #指定python的安裝要求

include_package_data=true

)

cd進入工程目錄環境內:

python setup.py bdist_wheel        # 打包為whl檔案

python setup.py bdist_wheel         # 打包為egg檔案

python setup.py bdist_egg             # 打包為egg檔案

執行python setup.py bdist_wheel   就會生成wheel安裝包了.執行後會多三個資料夾:build,cal_similarity.egg-info,dist

之後就能通過pip install (路徑+包名)的方式安裝python離線包了。

python安裝whl檔案

第一步 這當然是預設的一步,首先你有了要安裝的.whl檔案,這裡有個 常見的.whl大致都能找到。第二步 在cmd模式下,進入包含要安裝的.whl檔案的資料夾,然後輸入pip install whl 這樣pip就自動幫你安裝了,一般安裝的檔案名字都很長,只要輸入 前幾個字母,然後按table鍵,cm...

python安裝whl檔案

1.安裝wheel庫 pip install wheel 本地安裝 2.安裝whl檔案 安裝完wheel後,1 如果已將 python27 scripts目錄新增到path中,可以直接在whl檔案所在目錄用管理員開啟乙個cmd視窗,直接執行下面的語句 pip install python dateu...

python安裝 whl檔案

先判斷要安裝的whl檔案所對應的python版本 判斷如下 scikit learn 0.19.1 cp27 cp27m win32.whl 這個檔案cp27 表示對應的時 python2.7 win32 指的時python為32 位的再比如 scikit learn 0.19.1 cp37 cp3...