pip wheel¶
用法¶
python -m pip wheel [options] <requirement specifier> ...
python -m pip wheel [options] -r <requirements file> ...
python -m pip wheel [options] [-e] <vcs project url> ...
python -m pip wheel [options] [-e] <local project path> ...
python -m pip wheel [options] <archive url/path> ...
py -m pip wheel [options] <requirement specifier> ...
py -m pip wheel [options] -r <requirements file> ...
py -m pip wheel [options] [-e] <vcs project url> ...
py -m pip wheel [options] [-e] <local project path> ...
py -m pip wheel [options] <archive url/path> ...
說明¶
為需求和相依性建立輪件封存檔。
輪件是一種內建封裝格式,並提供一個優點:在每次安裝時不會重新編譯軟體。更多詳細資料,請參閱輪件文件:https://wheel.readthedocs.io/en/latest/
「pip wheel」使用在此說明的建置系統介面:https://pip.dev.org.tw/en/stable/reference/build-system/
建置系統介面
這已在建置系統介面中說明。
與build
的差異¶
build是一種簡單的工具,其中一項功能是為使用標準pyproject.toml
為基礎的建置介面的專案建置輪件。這部分與執行pip wheel --no-deps .
相當。它也可以建置無法使用pip
建置的原始碼發行版。pip wheel
涵蓋了build
的輪件範圍,但提供了許多額外的功能。
選項¶
- -w, --wheel-dir <dir>¶
將輪件建置到
,預設是目前的作業目錄。 (環境變數:
PIP_WHEEL_DIR
)
- --no-binary <format_control>¶
不使用二進位套件。可以提供多於一次,每次都會加入既有值。接受「:全部:」來停用所有二進位套件,「:無:」來清空設定(注意冒號),或一個或多個以逗號區隔的套件名稱(不含冒號)。請注意,有些套件很難編譯,當對這些套件使用這個選項時可能會安裝失敗。
(環境變數:
PIP_NO_BINARY
)
- --only-binary <格式控制>¶
不要使用來源套件。可提供多次,而且每次都會加入現有的值。接受「:all:」來停用所有來源套件、「:none:」來清空設定,或使用逗點區隔一個或多個套件名稱。如果套件沒有二進位發行版,則會於使用這個選項時安裝失敗。
(環境變數:
PIP_ONLY_BINARY
)
- --prefer-binary¶
優先選擇二進位套件而不是來源套件,即使來源套件較新。
(環境變數:
PIP_PREFER_BINARY
)
- --no-build-isolation¶
在建置最新的來源發行版時停用隔離。如果使用了這個選項,則必須已安裝由 PEP 518 指定的建置相依性。
(環境變數:
PIP_NO_BUILD_ISOLATION
)
- --use-pep517¶
使用 PEP 517 建置來源發行版(使用 --no-use-pep517 可強制套用舊有行為)。
(環境變數:
PIP_USE_PEP517
)
- --check-build-dependencies¶
在使用 PEP517 時檢查建置相依性。
(環境變數:
PIP_CHECK_BUILD_DEPENDENCIES
)
- -c, --constraint <檔案>¶
使用提供的約束檔案約束版本。這個選項可以使用多次。
(環境變數:
PIP_CONSTRAINT
)
- -e, --editable <路徑/網址>¶
從本機專案路徑或 VCS 網址以可編輯模式(即 setuptools 的「develop 模式」)安裝專案。
(環境變數:
PIP_EDITABLE
)
- -r, --requirement <檔案>¶
從指定的 requirement 檔案安裝。此選項可多次使用。
(環境變數:
PIP_REQUIREMENT
)
- --src <目錄>¶
可供檢出的可編輯專案目錄。在虛擬環境中,預設為「<venv 路徑>/src」。在全球安裝中,預設為「<目前目錄>/src」。
(環境變數:
PIP_SRC
,PIP_SOURCE
,PIP_SOURCE_DIR
,PIP_SOURCE_DIRECTORY
)
- --ignore-requires-python¶
忽略 Requires-Python 資訊。
(環境變數:
PIP_IGNORE_REQUIRES_PYTHON
)
- --no-deps¶
不安裝套件相依性。
(環境變數:
PIP_NO_DEPS
,PIP_NO_DEPENDENCIES
)
- --progress-bar <progress_bar>¶
指定是否應使用進度條 [on, off, raw](預設:on)
(環境變數:
PIP_PROGRESS_BAR
)
- --no-verify¶
不驗證建置的 wheel 是否有效。
(環境變數:
PIP_NO_VERIFY
)
- -C, --config-settings <設定>¶
要傳遞給 PEP 517 建置後端的組態設定。設定格式為 KEY=VALUE。使用多個 --config-settings 選項傳遞多個金鑰到後端。
(環境變數:
PIP_CONFIG_SETTINGS
)
- --build-option <選項>¶
要提供給「setup.py bdist_wheel」的其他引數。
(環境變數:
PIP_BUILD_OPTION
)
- --global-option <選項>¶
在安裝或 bdist_wheel 指令執行前,要提供給 setup.py 呼叫的額外全域選項。
(環境變數:
PIP_GLOBAL_OPTION
)
- --pre¶
包含前瞻版本和開發版本。預設情況下,pip 僅尋找穩定版本。
(環境變數:
PIP_PRE
)
- --require-hashes¶
要求雜湊值來比對每個需求,以進行重複安裝。如果需求檔案中的任何套件具有 --hash 選項,則會採用這個選項。
(環境變數:
PIP_REQUIRE_HASHES
)
- --no-clean¶
不清除建置目錄。
(環境變數:
PIP_NO_CLEAN
)
- -i, --index-url <網址>¶
Python 套件索引的基礎網址(預設值 https://pypi.org/simple)。應指向符合 PEP 503(簡單儲存庫 API)的儲存庫或採用相同格式佈局的本機目錄。
(環境變數:
PIP_INDEX_URL
,PIP_PYPI_URL
)
- --extra-index-url <網址>¶
除了 --index-url 外,還要使用的其他套件索引網址。應遵循與 --index-url 相同的規則。
(環境變數:
PIP_EXTRA_INDEX_URL
)
- --no-index¶
忽略套件索引(僅查看 --find-links URL)。
(環境變數:
PIP_NO_INDEX
)
範例¶
建立一個需求的輪子(以及所有依賴),然後安裝
python -m pip wheel --wheel-dir=/tmp/wheelhouse SomePackage python -m pip install --no-index --find-links=/tmp/wheelhouse SomePackage
py -m pip wheel --wheel-dir=/tmp/wheelhouse SomePackage py -m pip install --no-index --find-links=/tmp/wheelhouse SomePackage
從來源建立一個套件的輪子
python -m pip wheel --no-binary SomePackage SomePackage
py -m pip wheel --no-binary SomePackage SomePackage