Skip to content

Commit 4126467

Browse files
authored
fix: supports custom distribution files path for pdm publish (#2724)
Fixes #2723 Signed-off-by: Frost Ming <[email protected]>
1 parent ca0a27a commit 4126467

File tree

6 files changed

+16
-6
lines changed

6 files changed

+16
-6
lines changed

news/2723.feature.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Supports custom distribution files path via `-d/--dest` option for `pdm publish`.

src/pdm/cli/commands/publish/__init__.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ def add_arguments(self, parser: argparse.ArgumentParser) -> None:
6262
dest="build",
6363
help="Don't build the package before publishing",
6464
)
65+
parser.add_argument(
66+
"-d",
67+
"--dest",
68+
help="The directory to upload the package from",
69+
default="dist",
70+
)
6571
parser.add_argument(
6672
"--skip-existing",
6773
action="store_true",
@@ -157,10 +163,11 @@ def handle(self, project: Project, options: argparse.Namespace) -> None:
157163
hooks.try_emit("pre_publish")
158164

159165
if options.build:
160-
build.Command.do_build(project, hooks=hooks)
166+
build.Command.do_build(project, dest=options.dest, hooks=hooks)
161167

162-
package_files = [str(p) for p in project.root.joinpath("dist").iterdir() if not p.name.endswith(".asc")]
163-
signatures = {p.stem: str(p) for p in project.root.joinpath("dist").iterdir() if p.name.endswith(".asc")}
168+
upload_dir = project.root.joinpath(options.dest)
169+
package_files = [str(p) for p in upload_dir.iterdir() if not p.name.endswith(".asc")]
170+
signatures = {p.stem: str(p) for p in upload_dir.iterdir() if p.name.endswith(".asc")}
164171

165172
repository = self.get_repository(project, options)
166173
uploaded: list[PackageFile] = []

src/pdm/cli/completions/pdm.bash

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ _pdm_a919b69078acdf0a_complete()
8989
;;
9090

9191
(publish)
92-
opts="--ca-certs --comment --help --identity --no-build --no-very-ssl --password --project --quiet --repository --sign --skip --skip-existing --username --verbose"
92+
opts="--ca-certs --comment --dest --help --identity --no-build --no-very-ssl --password --project --quiet --repository --sign --skip --skip-existing --username --verbose"
9393
;;
9494

9595
(py)

src/pdm/cli/completions/pdm.fish

+2-1
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ complete -c pdm -A -n '__fish_seen_subcommand_from plugin; and __fish_seen_subco
308308
complete -c pdm -f -n '__fish_pdm_a919b69078acdf0a_complete_no_subcommand' -a publish -d 'Build and publish the project to PyPI'
309309
complete -c pdm -A -n '__fish_seen_subcommand_from publish' -l ca-certs -d 'The path to a PEM-encoded Certificate Authority bundle to use for publish server validation [env var: PDM_PUBLISH_CA_CERTS]'
310310
complete -c pdm -A -n '__fish_seen_subcommand_from publish' -l comment -d 'The comment to include with the distribution file.'
311+
complete -c pdm -A -n '__fish_seen_subcommand_from publish' -l dest -d 'The directory to upload the package from'
311312
complete -c pdm -A -n '__fish_seen_subcommand_from publish' -l help -d 'Show this help message and exit.'
312313
complete -c pdm -A -n '__fish_seen_subcommand_from publish' -l identity -d 'GPG identity used to sign files.'
313314
complete -c pdm -A -n '__fish_seen_subcommand_from publish' -l no-build -d 'Don\'t build the package before publishing'
@@ -525,7 +526,7 @@ complete -c pdm -A -n '__fish_seen_subcommand_from update' -l verbose -d 'Use `-
525526
complete -c pdm -A -n '__fish_seen_subcommand_from update' -l without -d 'Exclude groups of optional-dependencies or dev-dependencies'
526527

527528
# use
528-
complete -c pdm -f -n '__fish_pdm_a919b69078acdf0a_complete_no_subcommand' -a use -d 'Use the given python version or path as base interpreter'
529+
complete -c pdm -f -n '__fish_pdm_a919b69078acdf0a_complete_no_subcommand' -a use -d 'Use the given python version or path as base interpreter. If not found, PDM will try to install one.'
529530
complete -c pdm -A -n '__fish_seen_subcommand_from use' -l first -d 'Select the first matched interpreter'
530531
complete -c pdm -A -n '__fish_seen_subcommand_from use' -l global -d 'Use the global project, supply the project root with `-p` option'
531532
complete -c pdm -A -n '__fish_seen_subcommand_from use' -l help -d 'Show this help message and exit.'

src/pdm/cli/completions/pdm.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ function TabExpansion($line, $lastWord) {
382382
@(
383383
[Option]::new(@(
384384
"-r", "--repository", "-u", "--username", "-P", "--password", "-S", "--sign", "-i", "--identity", "-c", "--comment",
385-
"--no-build", "--ca-certs", "--no-verify-ssl", "--skip-existing"
385+
"--no-build", "--ca-certs", "--no-verify-ssl", "--skip-existing", "-d", "--dest"
386386
)),
387387
$skipOption,
388388
$projectOption

src/pdm/cli/completions/pdm.zsh

+1
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ _pdm() {
369369
{-i,--identity}'[GPG identity used to sign files.]:gpg identity:'
370370
{-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]'
371371
{-c,--comment}'[The comment to include with the distribution file.]:comment:'
372+
{-d,--dest}'[The directory to upload the package from]:dest:_files'
372373
"--no-verify-ssl[Disable SSL verification]"
373374
"--ca-certs[The path to a PEM-encoded Certificate Authority bundle to use for publish server validation]:cacerts:_files"
374375
"--no-build[Don't build the package before publishing]"

0 commit comments

Comments
 (0)