mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
Rename commands to pip-sync
and pip-compile
(#123)
To free up the rest of the interface.
This commit is contained in:
parent
8cc4fe0d44
commit
e15b99b911
7 changed files with 30 additions and 31 deletions
|
@ -34,7 +34,6 @@ Puffin does not yet support:
|
||||||
- Source distributions
|
- Source distributions
|
||||||
- VCS dependencies
|
- VCS dependencies
|
||||||
- URL dependencies
|
- URL dependencies
|
||||||
- Uninstalling packages
|
|
||||||
- Windows
|
- Windows
|
||||||
- ...
|
- ...
|
||||||
|
|
||||||
|
@ -47,13 +46,13 @@ Like `pip-compile`, Puffin generates a platform-specific `requirements.txt` file
|
||||||
To resolve a `requirements.in` file:
|
To resolve a `requirements.in` file:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
cargo run -p puffin-cli -- compile requirements.in
|
cargo run -p puffin-cli -- pip-compile requirements.in
|
||||||
```
|
```
|
||||||
|
|
||||||
To install from a resolved `requirements.txt` file:
|
To install from a resolved `requirements.txt` file:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
cargo run -p puffin-cli -- sync requirements.txt
|
cargo run -p puffin-cli -- pip-sync requirements.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
For more, see `cargo run -p puffin-cli -- --help`:
|
For more, see `cargo run -p puffin-cli -- --help`:
|
||||||
|
|
|
@ -3,20 +3,20 @@ use std::time::Duration;
|
||||||
|
|
||||||
pub(crate) use add::add;
|
pub(crate) use add::add;
|
||||||
pub(crate) use clean::clean;
|
pub(crate) use clean::clean;
|
||||||
pub(crate) use compile::compile;
|
|
||||||
pub(crate) use freeze::freeze;
|
pub(crate) use freeze::freeze;
|
||||||
|
pub(crate) use pip_compile::pip_compile;
|
||||||
|
pub(crate) use pip_sync::{pip_sync, PipSyncFlags};
|
||||||
pub(crate) use remove::remove;
|
pub(crate) use remove::remove;
|
||||||
pub(crate) use sync::{sync, SyncFlags};
|
|
||||||
pub(crate) use uninstall::uninstall;
|
pub(crate) use uninstall::uninstall;
|
||||||
pub(crate) use venv::venv;
|
pub(crate) use venv::venv;
|
||||||
|
|
||||||
mod add;
|
mod add;
|
||||||
mod clean;
|
mod clean;
|
||||||
mod compile;
|
|
||||||
mod freeze;
|
mod freeze;
|
||||||
|
mod pip_compile;
|
||||||
|
mod pip_sync;
|
||||||
mod remove;
|
mod remove;
|
||||||
mod reporters;
|
mod reporters;
|
||||||
mod sync;
|
|
||||||
mod uninstall;
|
mod uninstall;
|
||||||
mod venv;
|
mod venv;
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ use crate::commands::{elapsed, ExitStatus};
|
||||||
use crate::printer::Printer;
|
use crate::printer::Printer;
|
||||||
|
|
||||||
/// Resolve a set of requirements into a set of pinned versions.
|
/// Resolve a set of requirements into a set of pinned versions.
|
||||||
pub(crate) async fn compile(
|
pub(crate) async fn pip_compile(
|
||||||
src: &Path,
|
src: &Path,
|
||||||
output_file: Option<&Path>,
|
output_file: Option<&Path>,
|
||||||
cache: Option<&Path>,
|
cache: Option<&Path>,
|
|
@ -24,17 +24,17 @@ use crate::printer::Printer;
|
||||||
|
|
||||||
bitflags! {
|
bitflags! {
|
||||||
#[derive(Debug, Copy, Clone, Default)]
|
#[derive(Debug, Copy, Clone, Default)]
|
||||||
pub struct SyncFlags: u8 {
|
pub struct PipSyncFlags: u8 {
|
||||||
/// Ignore any installed packages, forcing a re-installation.
|
/// Ignore any installed packages, forcing a re-installation.
|
||||||
const IGNORE_INSTALLED = 1 << 0;
|
const IGNORE_INSTALLED = 1 << 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Install a set of locked requirements into the current Python environment.
|
/// Install a set of locked requirements into the current Python environment.
|
||||||
pub(crate) async fn sync(
|
pub(crate) async fn pip_sync(
|
||||||
src: &Path,
|
src: &Path,
|
||||||
cache: Option<&Path>,
|
cache: Option<&Path>,
|
||||||
flags: SyncFlags,
|
flags: PipSyncFlags,
|
||||||
mut printer: Printer,
|
mut printer: Printer,
|
||||||
) -> Result<ExitStatus> {
|
) -> Result<ExitStatus> {
|
||||||
// Read the `requirements.txt` from disk.
|
// Read the `requirements.txt` from disk.
|
||||||
|
@ -59,7 +59,7 @@ pub(crate) async fn sync(
|
||||||
pub(crate) async fn sync_requirements(
|
pub(crate) async fn sync_requirements(
|
||||||
requirements: &[Requirement],
|
requirements: &[Requirement],
|
||||||
cache: Option<&Path>,
|
cache: Option<&Path>,
|
||||||
flags: SyncFlags,
|
flags: PipSyncFlags,
|
||||||
mut printer: Printer,
|
mut printer: Printer,
|
||||||
) -> Result<ExitStatus> {
|
) -> Result<ExitStatus> {
|
||||||
let start = std::time::Instant::now();
|
let start = std::time::Instant::now();
|
||||||
|
@ -216,11 +216,11 @@ pub(crate) async fn sync_requirements(
|
||||||
async fn find_uncached_requirements(
|
async fn find_uncached_requirements(
|
||||||
requirements: &[Requirement],
|
requirements: &[Requirement],
|
||||||
cache: Option<&Path>,
|
cache: Option<&Path>,
|
||||||
flags: SyncFlags,
|
flags: PipSyncFlags,
|
||||||
python: &PythonExecutable,
|
python: &PythonExecutable,
|
||||||
) -> Result<(Vec<LocalDistribution>, Vec<Requirement>)> {
|
) -> Result<(Vec<LocalDistribution>, Vec<Requirement>)> {
|
||||||
// Index all the already-installed packages in site-packages.
|
// Index all the already-installed packages in site-packages.
|
||||||
let site_packages = if flags.intersects(SyncFlags::IGNORE_INSTALLED) {
|
let site_packages = if flags.intersects(PipSyncFlags::IGNORE_INSTALLED) {
|
||||||
SitePackages::default()
|
SitePackages::default()
|
||||||
} else {
|
} else {
|
||||||
SitePackages::from_executable(python).await?
|
SitePackages::from_executable(python).await?
|
|
@ -34,9 +34,9 @@ struct Cli {
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
enum Commands {
|
enum Commands {
|
||||||
/// Compile a `requirements.in` file to a `requirements.txt` file.
|
/// Compile a `requirements.in` file to a `requirements.txt` file.
|
||||||
Compile(CompileArgs),
|
PipCompile(PipCompileArgs),
|
||||||
/// Sync dependencies from a `requirements.txt` file.
|
/// Sync dependencies from a `requirements.txt` file.
|
||||||
Sync(SyncArgs),
|
PipSync(PipSyncArgs),
|
||||||
/// Clear the cache.
|
/// Clear the cache.
|
||||||
Clean,
|
Clean,
|
||||||
/// Enumerate the installed packages in the current environment.
|
/// Enumerate the installed packages in the current environment.
|
||||||
|
@ -52,7 +52,7 @@ enum Commands {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args)]
|
#[derive(Args)]
|
||||||
struct CompileArgs {
|
struct PipCompileArgs {
|
||||||
/// Output `requirements.txt` file
|
/// Output `requirements.txt` file
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
output_file: Option<PathBuf>,
|
output_file: Option<PathBuf>,
|
||||||
|
@ -61,7 +61,7 @@ struct CompileArgs {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args)]
|
#[derive(Args)]
|
||||||
struct SyncArgs {
|
struct PipSyncArgs {
|
||||||
/// Path to the `requirements.txt` file to install.
|
/// Path to the `requirements.txt` file to install.
|
||||||
src: PathBuf,
|
src: PathBuf,
|
||||||
|
|
||||||
|
@ -120,8 +120,8 @@ async fn main() -> ExitCode {
|
||||||
let dirs = ProjectDirs::from("", "", "puffin");
|
let dirs = ProjectDirs::from("", "", "puffin");
|
||||||
|
|
||||||
let result = match &cli.command {
|
let result = match &cli.command {
|
||||||
Commands::Compile(args) => {
|
Commands::PipCompile(args) => {
|
||||||
commands::compile(
|
commands::pip_compile(
|
||||||
&args.src,
|
&args.src,
|
||||||
args.output_file.as_deref(),
|
args.output_file.as_deref(),
|
||||||
dirs.as_ref()
|
dirs.as_ref()
|
||||||
|
@ -131,16 +131,16 @@ async fn main() -> ExitCode {
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
Commands::Sync(args) => {
|
Commands::PipSync(args) => {
|
||||||
commands::sync(
|
commands::pip_sync(
|
||||||
&args.src,
|
&args.src,
|
||||||
dirs.as_ref()
|
dirs.as_ref()
|
||||||
.map(ProjectDirs::cache_dir)
|
.map(ProjectDirs::cache_dir)
|
||||||
.filter(|_| !cli.no_cache),
|
.filter(|_| !cli.no_cache),
|
||||||
if args.ignore_installed {
|
if args.ignore_installed {
|
||||||
commands::SyncFlags::IGNORE_INSTALLED
|
commands::PipSyncFlags::IGNORE_INSTALLED
|
||||||
} else {
|
} else {
|
||||||
commands::SyncFlags::empty()
|
commands::PipSyncFlags::empty()
|
||||||
},
|
},
|
||||||
printer,
|
printer,
|
||||||
)
|
)
|
||||||
|
|
|
@ -16,12 +16,12 @@ TARGET=${1}
|
||||||
# Resolution with a cold cache.
|
# Resolution with a cold cache.
|
||||||
###
|
###
|
||||||
hyperfine --runs 20 --warmup 3 --prepare "rm -f /tmp/requirements.txt" \
|
hyperfine --runs 20 --warmup 3 --prepare "rm -f /tmp/requirements.txt" \
|
||||||
"./target/release/puffin --no-cache compile ${TARGET} > /tmp/requirements.txt" \
|
"./target/release/puffin --no-cache pip-compile ${TARGET} > /tmp/requirements.txt" \
|
||||||
"./target/release/main --no-cache compile ${TARGET} > /tmp/requirements.txt"
|
"./target/release/main --no-cache pip-compile ${TARGET} > /tmp/requirements.txt"
|
||||||
|
|
||||||
###
|
###
|
||||||
# Resolution with a warm cache.
|
# Resolution with a warm cache.
|
||||||
###
|
###
|
||||||
hyperfine --runs 20 --warmup 3 --prepare "rm -f /tmp/requirements.txt" \
|
hyperfine --runs 20 --warmup 3 --prepare "rm -f /tmp/requirements.txt" \
|
||||||
"./target/release/puffin compile ${TARGET} > /tmp/requirements.txt" \
|
"./target/release/puffin pip-compile ${TARGET} > /tmp/requirements.txt" \
|
||||||
"./target/release/main compile ${TARGET} > /tmp/requirements.txt"
|
"./target/release/main pip-compile ${TARGET} > /tmp/requirements.txt"
|
||||||
|
|
|
@ -17,7 +17,7 @@ TARGET=${1}
|
||||||
###
|
###
|
||||||
hyperfine --runs 20 --warmup 3 \
|
hyperfine --runs 20 --warmup 3 \
|
||||||
--prepare "virtualenv --clear .venv" \
|
--prepare "virtualenv --clear .venv" \
|
||||||
"./target/release/puffin sync ${TARGET} --ignore-installed --no-cache" \
|
"./target/release/puffin pip-sync ${TARGET} --ignore-installed --no-cache" \
|
||||||
--prepare "rm -rf /tmp/site-packages" \
|
--prepare "rm -rf /tmp/site-packages" \
|
||||||
"pip install -r ${TARGET} --target /tmp/site-packages --ignore-installed --no-cache-dir --no-deps"
|
"pip install -r ${TARGET} --target /tmp/site-packages --ignore-installed --no-cache-dir --no-deps"
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ hyperfine --runs 20 --warmup 3 \
|
||||||
###
|
###
|
||||||
hyperfine --runs 20 --warmup 3 \
|
hyperfine --runs 20 --warmup 3 \
|
||||||
--prepare "virtualenv --clear .venv" \
|
--prepare "virtualenv --clear .venv" \
|
||||||
"./target/release/puffin sync ${TARGET} --ignore-installed" \
|
"./target/release/puffin pip-sync ${TARGET} --ignore-installed" \
|
||||||
--prepare "rm -rf /tmp/site-packages" \
|
--prepare "rm -rf /tmp/site-packages" \
|
||||||
"pip install -r ${TARGET} --target /tmp/site-packages --ignore-installed --no-deps"
|
"pip install -r ${TARGET} --target /tmp/site-packages --ignore-installed --no-deps"
|
||||||
|
|
||||||
|
@ -35,5 +35,5 @@ hyperfine --runs 20 --warmup 3 \
|
||||||
###
|
###
|
||||||
hyperfine --runs 20 --warmup 3 \
|
hyperfine --runs 20 --warmup 3 \
|
||||||
--setup "virtualenv --clear .venv && source .venv/bin/activate" \
|
--setup "virtualenv --clear .venv && source .venv/bin/activate" \
|
||||||
"./target/release/puffin sync ${TARGET}" \
|
"./target/release/puffin pip-sync ${TARGET}" \
|
||||||
"pip install -r ${TARGET} --no-deps"
|
"pip install -r ${TARGET} --no-deps"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue