|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
#compdef pdm
|
|
|
|
|
|
|
|
|
|
PDM_PYTHON="$HOME/.local/pipx/venvs/pdm/bin/python"
|
|
|
|
|
PDM_PYTHON="/home/daylin/projects/github/forks/pdm/venv/bin/python"
|
|
|
|
|
PDM_PIP_INDEXES=($(command ${PDM_PYTHON} -m pdm config pypi.url))
|
|
|
|
|
|
|
|
|
|
_pdm() {
|
|
|
|
@ -28,7 +28,6 @@ _pdm() {
|
|
|
|
|
'list:List packages installed in the current working set'
|
|
|
|
|
'lock:Resolve and lock dependencies'
|
|
|
|
|
'plugin:Manage the PDM plugins'
|
|
|
|
|
'publish:Build and publish the project to PyPI'
|
|
|
|
|
'remove:Remove packages from pyproject.toml'
|
|
|
|
|
'run:Run commands or scripts with local packages loaded'
|
|
|
|
|
'search:Search for PyPI packages'
|
|
|
|
@ -42,8 +41,8 @@ _pdm() {
|
|
|
|
|
$arguments \
|
|
|
|
|
{-c,--config}'[Specify another config file path(env var: PDM_CONFIG_FILE)]' \
|
|
|
|
|
{-V,--version}'[Show the version and exit]' \
|
|
|
|
|
{-I,--ignore-python}'[Ignore the Python path saved in the .pdm.toml config]' \
|
|
|
|
|
'--pep582:Print the command line to be eval by the shell:shell:(zsh bash fish tcsh csh)' \
|
|
|
|
|
{-I,--ignore-python}'[Ignore the Python path saved in the pdm.toml config]' \
|
|
|
|
|
'--pep582=[Print the command line to be eval by the shell]:shell:(zsh bash fish tcsh csh)' \
|
|
|
|
|
'*:: :->_subcmds' \
|
|
|
|
|
&& return 0
|
|
|
|
|
|
|
|
|
@ -68,10 +67,8 @@ _pdm() {
|
|
|
|
|
'--save-minimum[Save minimum version specifiers]'
|
|
|
|
|
'--update-reuse[Reuse pinned versions already present in lock file if possible]'
|
|
|
|
|
'--update-eager[Try to update the packages and their dependencies recursively]'
|
|
|
|
|
'--update-all[Update all dependencies and sub-dependencies]'
|
|
|
|
|
'--no-editable[Install non-editable versions for all packages]'
|
|
|
|
|
"--no-self[Don't install the project itself]"
|
|
|
|
|
{-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]'
|
|
|
|
|
{-u,--unconstrained}'[Ignore the version constraint of packages]'
|
|
|
|
|
{--pre,--prerelease}'[Allow prereleases to be pinned]'
|
|
|
|
|
{-e+,--editable+}'[Specify editable packages]:packages'
|
|
|
|
@ -85,7 +82,6 @@ _pdm() {
|
|
|
|
|
"--no-sdist[Don't build source tarballs]"
|
|
|
|
|
"--no-wheel[Don't build wheels]"
|
|
|
|
|
{-d+,--dest+}'[Target directory to put artifacts]:directory:_files -/'
|
|
|
|
|
{-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]'
|
|
|
|
|
'--no-clean[Do not clean the target directory]'
|
|
|
|
|
{-C,--config-setting}'[Pass options to the backend. options with a value must be specified after "=": "--config-setting=--opt(=value)" or "-C--opt(=value)"]'
|
|
|
|
|
"--no-isolation[do not isolate the build in a clean environment]"
|
|
|
|
@ -109,7 +105,7 @@ _pdm() {
|
|
|
|
|
args)
|
|
|
|
|
case $words[1] in
|
|
|
|
|
clear)
|
|
|
|
|
compadd -X type 'hashes' 'http' 'wheels' 'metadata' 'packages' && ret=0
|
|
|
|
|
compadd -X type 'hashes' 'http' 'wheels' 'metadata' && ret=0
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
_message "pattern" && ret=0
|
|
|
|
@ -143,7 +139,8 @@ _pdm() {
|
|
|
|
|
"--without-hashes[Don't include artifact hashes]"
|
|
|
|
|
{-L,--lockfile}'[Specify another lockfile path, or use `PDM_LOCKFILE` env variable. Default: pdm.lock]:lockfile:_files'
|
|
|
|
|
{-o+,--output+}"[Write output to the given file, or print to stdout if not given]:output file:_files"
|
|
|
|
|
{-G+,--group+}'[Select group of optional-dependencies or dev-dependencies(with -d). Can be supplied multiple times, use ":all" to include all groups under the same species]:group:_pdm_groups'
|
|
|
|
|
{-G+,--group+}'[Select group of optional-dependencies or dev-dependencies(with -d). Can be supplied multiple times, use ":all" to include all groups under the
|
|
|
|
|
same species]:group:_pdm_groups'
|
|
|
|
|
{-d,--dev}"[Select dev dependencies]"
|
|
|
|
|
{--prod,--production}"[Unselect dev dependencies]"
|
|
|
|
|
"--no-default[Don't include dependencies from the default group]"
|
|
|
|
@ -169,17 +166,16 @@ _pdm() {
|
|
|
|
|
arguments+=(
|
|
|
|
|
{-g,--global}'[Use the global project, supply the project root with `-p` option]'
|
|
|
|
|
{-n,--non-interactive}"[Don't ask questions but use default values]"
|
|
|
|
|
{-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]'
|
|
|
|
|
)
|
|
|
|
|
;;
|
|
|
|
|
install)
|
|
|
|
|
arguments+=(
|
|
|
|
|
{-g,--global}'[Use the global project, supply the project root with `-p` option]'
|
|
|
|
|
{-G+,--group+}'[Select group of optional-dependencies or dev-dependencies(with -d). Can be supplied multiple times, use ":all" to include all groups under the same species]:group:_pdm_groups'
|
|
|
|
|
{-G+,--group+}'[Select group of optional-dependencies or dev-dependencies(with -d). Can be supplied multiple times, use ":all" to include all groups under the
|
|
|
|
|
same species]:group:_pdm_groups'
|
|
|
|
|
{-d,--dev}"[Select dev dependencies]"
|
|
|
|
|
{-L,--lockfile}'[Specify another lockfile path, or use `PDM_LOCKFILE` env variable. Default: pdm.lock]:lockfile:_files'
|
|
|
|
|
{--prod,--production}"[Unselect dev dependencies]"
|
|
|
|
|
{-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]'
|
|
|
|
|
"--no-lock[Don't do lock if lock file is not found or outdated]"
|
|
|
|
|
"--no-default[Don\'t include dependencies from the default group]"
|
|
|
|
|
'--no-editable[Install non-editable versions for all packages]'
|
|
|
|
@ -203,7 +199,6 @@ _pdm() {
|
|
|
|
|
{-g,--global}'[Use the global project, supply the project root with `-p` option]'
|
|
|
|
|
{-L,--lockfile}'[Specify another lockfile path, or use `PDM_LOCKFILE` env variable. Default: pdm.lock]:lockfile:_files'
|
|
|
|
|
"--no-isolation[Do not isolate the build in a clean environment]"
|
|
|
|
|
{-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]'
|
|
|
|
|
"--refresh[Don't update pinned versions, only refresh the lock file]"
|
|
|
|
|
)
|
|
|
|
|
;;
|
|
|
|
@ -243,25 +238,12 @@ _pdm() {
|
|
|
|
|
esac
|
|
|
|
|
return $ret
|
|
|
|
|
;;
|
|
|
|
|
publish)
|
|
|
|
|
arguments+=(
|
|
|
|
|
{-r,--repository}'[The repository name or url to publish the package to }[env var: PDM_PUBLISH_REPO]]:repository:'
|
|
|
|
|
{-u,--username}'[The username to access the repository [env var: PDM_PUBLISH_USERNAME]]:username:'
|
|
|
|
|
{-P,--password}'[The password to access the repository [env var: PDM_PUBLISH_PASSWORD]]:password:'
|
|
|
|
|
{-S,--sign}'[Upload the package with PGP signature]'
|
|
|
|
|
{-i,--identity}'[GPG identity used to sign files.]:gpg identity:'
|
|
|
|
|
{-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]'
|
|
|
|
|
{-c,--comment}'[The comment to include with the distribution file.]:comment:'
|
|
|
|
|
"--no-build[Don't build the package before publishing]"
|
|
|
|
|
)
|
|
|
|
|
;;
|
|
|
|
|
remove)
|
|
|
|
|
arguments+=(
|
|
|
|
|
{-g,--global}'[Use the global project, supply the project root with `-p` option]'
|
|
|
|
|
{-G,--group}'[Specify the target dependency group to remove from]:group:_pdm_groups'
|
|
|
|
|
{-d,--dev}"[Remove packages from dev dependencies]"
|
|
|
|
|
{-L,--lockfile}'[Specify another lockfile path, or use `PDM_LOCKFILE` env variable. Default: pdm.lock]:lockfile:_files'
|
|
|
|
|
{-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]'
|
|
|
|
|
"--no-sync[Only write pyproject.toml and do not uninstall packages]"
|
|
|
|
|
'--no-editable[Install non-editable versions for all packages]'
|
|
|
|
|
"--no-self[Don't install the project itself]"
|
|
|
|
@ -274,7 +256,6 @@ _pdm() {
|
|
|
|
|
_arguments -s \
|
|
|
|
|
{-g,--global}'[Use the global project, supply the project root with `-p` option]' \
|
|
|
|
|
{-l,--list}'[Show all available scripts defined in pyproject.toml]' \
|
|
|
|
|
{-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]' \
|
|
|
|
|
{-s,--site-packages}'[Load site-packages from the selected interpreter]' \
|
|
|
|
|
'(-)1:command:->command' \
|
|
|
|
|
'*:arguments: _normal ' && return 0
|
|
|
|
@ -305,15 +286,15 @@ _pdm() {
|
|
|
|
|
sync)
|
|
|
|
|
arguments+=(
|
|
|
|
|
{-g,--global}'[Use the global project, supply the project root with `-p` option]'
|
|
|
|
|
{-G+,--group+}'[Select group of optional-dependencies or dev-dependencies(with -d). Can be supplied multiple times, use ":all" to include all groups under the same species]:group:_pdm_groups'
|
|
|
|
|
{-G+,--group+}'[Select group of optional-dependencies or dev-dependencies(with -d). Can be supplied multiple times, use ":all" to include all groups under the
|
|
|
|
|
same species]:group:_pdm_groups'
|
|
|
|
|
{-d,--dev}"[Select dev dependencies]"
|
|
|
|
|
{-L,--lockfile}'[Specify another lockfile path, or use `PDM_LOCKFILE` env variable. Default: pdm.lock]:lockfile:_files'
|
|
|
|
|
{--prod,--production}"[Unselect dev dependencies]"
|
|
|
|
|
{-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]'
|
|
|
|
|
'--dry-run[Only prints actions without actually running them]'
|
|
|
|
|
{-r,--reinstall}"[Force reinstall existing dependencies]"
|
|
|
|
|
'--clean[Clean unused packages]'
|
|
|
|
|
"--only-keep[Only keep the selected packages]"
|
|
|
|
|
"--no-clean[Don't clean unused packages]"
|
|
|
|
|
"--no-default[Don\'t include dependencies from the default group]"
|
|
|
|
|
'--no-editable[Install non-editable versions for all packages]'
|
|
|
|
|
"--no-self[Don't install the project itself]"
|
|
|
|
@ -323,7 +304,8 @@ _pdm() {
|
|
|
|
|
update)
|
|
|
|
|
arguments+=(
|
|
|
|
|
{-g,--global}'[Use the global project, supply the project root with `-p` option]'
|
|
|
|
|
{-G+,--group+}'[Select group of optional-dependencies or dev-dependencies(with -d). Can be supplied multiple times, use ":all" to include all groups under the same species]:group:_pdm_groups'
|
|
|
|
|
{-G+,--group+}'[Select group of optional-dependencies or dev-dependencies(with -d). Can be supplied multiple times, use ":all" to include all groups under the
|
|
|
|
|
same species]:group:_pdm_groups'
|
|
|
|
|
{-L,--lockfile}'[Specify another lockfile path, or use `PDM_LOCKFILE` env variable. Default: pdm.lock]:lockfile:_files'
|
|
|
|
|
'--save-compatible[Save compatible version specifiers]'
|
|
|
|
|
'--save-wildcard[Save wildcard version specifiers]'
|
|
|
|
@ -331,11 +313,9 @@ _pdm() {
|
|
|
|
|
'--save-minimum[Save minimum version specifiers]'
|
|
|
|
|
'--update-reuse[Reuse pinned versions already present in lock file if possible]'
|
|
|
|
|
'--update-eager[Try to update the packages and their dependencies recursively]'
|
|
|
|
|
'--update-all[Update all dependencies and sub-dependencies]'
|
|
|
|
|
'--no-editable[Install non-editable versions for all packages]'
|
|
|
|
|
"--no-self[Don't install the project itself]"
|
|
|
|
|
"--no-sync[Only update lock file but do not sync packages]"
|
|
|
|
|
{-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]'
|
|
|
|
|
{-u,--unconstrained}'[Ignore the version constraint of packages]'
|
|
|
|
|
{--pre,--prerelease}'[Allow prereleases to be pinned]'
|
|
|
|
|
{-d,--dev}'[Select dev dependencies]'
|
|
|
|
@ -385,18 +365,13 @@ _pdm_groups() {
|
|
|
|
|
|
|
|
|
|
_get_packages_with_python() {
|
|
|
|
|
command ${PDM_PYTHON} - << EOF
|
|
|
|
|
import sys
|
|
|
|
|
if sys.version_info >= (3, 11):
|
|
|
|
|
import tomllib
|
|
|
|
|
else:
|
|
|
|
|
import tomli as tomllib
|
|
|
|
|
import os, re
|
|
|
|
|
import os, re, tomli
|
|
|
|
|
PACKAGE_REGEX = re.compile(r'^[A-Za-z][A-Za-z0-9._-]*')
|
|
|
|
|
def get_packages(lines):
|
|
|
|
|
return [PACKAGE_REGEX.match(line).group() for line in lines]
|
|
|
|
|
|
|
|
|
|
with open('pyproject.toml', 'rb') as f:
|
|
|
|
|
data = tomllib.load(f)
|
|
|
|
|
data = tomli.load(f)
|
|
|
|
|
packages = get_packages(data.get('project', {}).get('dependencies', []))
|
|
|
|
|
for reqs in data.get('project', {}).get('optional-dependencies', {}).values():
|
|
|
|
|
packages.extend(get_packages(reqs))
|
|
|
|
|