@@ -335,6 +335,21 @@ pub enum Commands {
335
335
after_long_help = ""
336
336
) ]
337
337
Venv ( VenvArgs ) ,
338
+ /// Build Python packages into source distributions and wheels.
339
+ ///
340
+ /// By default, `uv build` will build a source distribution ("sdist")
341
+ /// from the source directory, and a binary distribution ("wheel") from
342
+ /// the source distribution.
343
+ ///
344
+ /// `uv build --sdist` can be used to build only the source distribution,
345
+ /// `uv build --wheel` can be used to build only the binary distribution,
346
+ /// and `uv build --sdist --wheel` can be used to build both distributions
347
+ /// from source.
348
+ #[ command(
349
+ after_help = "Use `uv help build` for more details." ,
350
+ after_long_help = ""
351
+ ) ]
352
+ Build ( BuildArgs ) ,
338
353
/// Manage uv's cache.
339
354
#[ command(
340
355
after_help = "Use `uv help cache` for more details." ,
@@ -1125,7 +1140,7 @@ pub struct PipSyncArgs {
1125
1140
1126
1141
/// The Python interpreter into which packages should be installed.
1127
1142
///
1128
- /// By default, syncing requires a virtual environment. An path to an
1143
+ /// By default, syncing requires a virtual environment. A path to an
1129
1144
/// alternative Python can be provided, but it is only recommended in
1130
1145
/// continuous integration (CI) environments and should be used with
1131
1146
/// caution, as it can modify the system Python installation.
@@ -1407,7 +1422,7 @@ pub struct PipInstallArgs {
1407
1422
1408
1423
/// The Python interpreter into which packages should be installed.
1409
1424
///
1410
- /// By default, installation requires a virtual environment. An path to an
1425
+ /// By default, installation requires a virtual environment. A path to an
1411
1426
/// alternative Python can be provided, but it is only recommended in
1412
1427
/// continuous integration (CI) environments and should be used with
1413
1428
/// caution, as it can modify the system Python installation.
@@ -1572,7 +1587,7 @@ pub struct PipUninstallArgs {
1572
1587
1573
1588
/// The Python interpreter from which packages should be uninstalled.
1574
1589
///
1575
- /// By default, uninstallation requires a virtual environment. An path to an
1590
+ /// By default, uninstallation requires a virtual environment. A path to an
1576
1591
/// alternative Python can be provided, but it is only recommended in
1577
1592
/// continuous integration (CI) environments and should be used with
1578
1593
/// caution, as it can modify the system Python installation.
@@ -1923,6 +1938,49 @@ pub struct PipTreeArgs {
1923
1938
pub compat_args : compat:: PipGlobalCompatArgs ,
1924
1939
}
1925
1940
1941
+ #[ derive( Args ) ]
1942
+ #[ allow( clippy:: struct_excessive_bools) ]
1943
+ pub struct BuildArgs {
1944
+ /// The directory from which source distributions and/or wheels should be built.
1945
+ ///
1946
+ /// Defaults to the current working directory.
1947
+ #[ arg( value_parser = parse_file_path) ]
1948
+ pub src_dir : Option < PathBuf > ,
1949
+
1950
+ /// Build a source distribution ("sdist") from the given directory.
1951
+ #[ arg( long) ]
1952
+ pub sdist : bool ,
1953
+
1954
+ /// Build a built distribution ("wheel") from the given directory.
1955
+ #[ arg( long) ]
1956
+ pub wheel : bool ,
1957
+
1958
+ /// The Python interpreter to use for the build environment.
1959
+ ///
1960
+ /// By default, builds are executed in isolated virtual environments. The
1961
+ /// discovered interpreter will be used to create those environments, and
1962
+ /// will be symlinked or copied in depending on the platform.
1963
+ ///
1964
+ /// See `uv help python` to view supported request formats.
1965
+ #[ arg(
1966
+ long,
1967
+ short,
1968
+ env = "UV_PYTHON" ,
1969
+ verbatim_doc_comment,
1970
+ help_heading = "Python options"
1971
+ ) ]
1972
+ pub python : Option < String > ,
1973
+
1974
+ #[ command( flatten) ]
1975
+ pub resolver : ResolverArgs ,
1976
+
1977
+ #[ command( flatten) ]
1978
+ pub build : BuildOptionsArgs ,
1979
+
1980
+ #[ command( flatten) ]
1981
+ pub refresh : RefreshArgs ,
1982
+ }
1983
+
1926
1984
#[ derive( Args ) ]
1927
1985
#[ allow( clippy:: struct_excessive_bools) ]
1928
1986
pub struct VenvArgs {
@@ -2298,7 +2356,7 @@ pub struct RunArgs {
2298
2356
pub installer : ResolverInstallerArgs ,
2299
2357
2300
2358
#[ command( flatten) ]
2301
- pub build : BuildArgs ,
2359
+ pub build : BuildOptionsArgs ,
2302
2360
2303
2361
#[ command( flatten) ]
2304
2362
pub refresh : RefreshArgs ,
@@ -2426,7 +2484,7 @@ pub struct SyncArgs {
2426
2484
pub installer : ResolverInstallerArgs ,
2427
2485
2428
2486
#[ command( flatten) ]
2429
- pub build : BuildArgs ,
2487
+ pub build : BuildOptionsArgs ,
2430
2488
2431
2489
#[ command( flatten) ]
2432
2490
pub refresh : RefreshArgs ,
@@ -2479,7 +2537,7 @@ pub struct LockArgs {
2479
2537
pub resolver : ResolverArgs ,
2480
2538
2481
2539
#[ command( flatten) ]
2482
- pub build : BuildArgs ,
2540
+ pub build : BuildOptionsArgs ,
2483
2541
2484
2542
#[ command( flatten) ]
2485
2543
pub refresh : RefreshArgs ,
@@ -2593,7 +2651,7 @@ pub struct AddArgs {
2593
2651
pub installer : ResolverInstallerArgs ,
2594
2652
2595
2653
#[ command( flatten) ]
2596
- pub build : BuildArgs ,
2654
+ pub build : BuildOptionsArgs ,
2597
2655
2598
2656
#[ command( flatten) ]
2599
2657
pub refresh : RefreshArgs ,
@@ -2662,7 +2720,7 @@ pub struct RemoveArgs {
2662
2720
pub installer : ResolverInstallerArgs ,
2663
2721
2664
2722
#[ command( flatten) ]
2665
- pub build : BuildArgs ,
2723
+ pub build : BuildOptionsArgs ,
2666
2724
2667
2725
#[ command( flatten) ]
2668
2726
pub refresh : RefreshArgs ,
@@ -2722,7 +2780,7 @@ pub struct TreeArgs {
2722
2780
pub frozen : bool ,
2723
2781
2724
2782
#[ command( flatten) ]
2725
- pub build : BuildArgs ,
2783
+ pub build : BuildOptionsArgs ,
2726
2784
2727
2785
#[ command( flatten) ]
2728
2786
pub resolver : ResolverArgs ,
@@ -2819,7 +2877,7 @@ pub struct ExportArgs {
2819
2877
pub resolver : ResolverArgs ,
2820
2878
2821
2879
#[ command( flatten) ]
2822
- pub build : BuildArgs ,
2880
+ pub build : BuildOptionsArgs ,
2823
2881
2824
2882
#[ command( flatten) ]
2825
2883
pub refresh : RefreshArgs ,
@@ -2844,6 +2902,38 @@ pub struct ExportArgs {
2844
2902
pub python : Option < String > ,
2845
2903
}
2846
2904
2905
+ #[ derive( Args ) ]
2906
+ #[ allow( clippy:: struct_excessive_bools) ]
2907
+ pub struct BuildNamespace {
2908
+ #[ command( subcommand) ]
2909
+ pub command : BuildCommand ,
2910
+ }
2911
+
2912
+ #[ derive( Subcommand ) ]
2913
+ pub enum BuildCommand {
2914
+ /// Run a command provided by a Python package.
2915
+ ///
2916
+ /// By default, the package to install is assumed to match the command name.
2917
+ ///
2918
+ /// The name of the command can include an exact version in the format
2919
+ /// `<package>@<version>`, e.g., `uv tool run [email protected] `. If more complex
2920
+ /// version specification is desired or if the command is provided by a
2921
+ /// different package, use `--from`.
2922
+ ///
2923
+ /// If the tool was previously installed, i.e., via `uv tool install`, the
2924
+ /// installed version will be used unless a version is requested or the
2925
+ /// `--isolated` flag is used.
2926
+ ///
2927
+ /// `uvx` is provided as a convenient alias for `uv tool run`, their
2928
+ /// behavior is identical.
2929
+ ///
2930
+ /// If no command is provided, the installed tools are displayed.
2931
+ ///
2932
+ /// Packages are installed into an ephemeral virtual environment in the uv
2933
+ /// cache directory.
2934
+ Run ( BuildOptionsArgs ) ,
2935
+ }
2936
+
2847
2937
#[ derive( Args ) ]
2848
2938
#[ allow( clippy:: struct_excessive_bools) ]
2849
2939
pub struct ToolNamespace {
@@ -2966,7 +3056,7 @@ pub struct ToolRunArgs {
2966
3056
pub installer : ResolverInstallerArgs ,
2967
3057
2968
3058
#[ command( flatten) ]
2969
- pub build : BuildArgs ,
3059
+ pub build : BuildOptionsArgs ,
2970
3060
2971
3061
#[ command( flatten) ]
2972
3062
pub refresh : RefreshArgs ,
@@ -3018,7 +3108,7 @@ pub struct ToolInstallArgs {
3018
3108
pub installer : ResolverInstallerArgs ,
3019
3109
3020
3110
#[ command( flatten) ]
3021
- pub build : BuildArgs ,
3111
+ pub build : BuildOptionsArgs ,
3022
3112
3023
3113
#[ command( flatten) ]
3024
3114
pub refresh : RefreshArgs ,
@@ -3103,7 +3193,7 @@ pub struct ToolUpgradeArgs {
3103
3193
pub installer : ResolverInstallerArgs ,
3104
3194
3105
3195
#[ command( flatten) ]
3106
- pub build : BuildArgs ,
3196
+ pub build : BuildOptionsArgs ,
3107
3197
}
3108
3198
3109
3199
#[ derive( Args ) ]
@@ -3407,7 +3497,7 @@ pub struct RefreshArgs {
3407
3497
3408
3498
#[ derive( Args ) ]
3409
3499
#[ allow( clippy:: struct_excessive_bools) ]
3410
- pub struct BuildArgs {
3500
+ pub struct BuildOptionsArgs {
3411
3501
/// Don't build source distributions.
3412
3502
///
3413
3503
/// When enabled, resolving will not run arbitrary Python code. The cached wheels of
0 commit comments