From e8b78a08992f5a327836b6902c98366aacac33f8 Mon Sep 17 00:00:00 2001 From: Kyle Willmon Date: Fri, 5 May 2023 15:25:07 -0500 Subject: [PATCH] Use pip-compile for pyproject.toml pyproject.toml is a standard Python file which is not specific to poetry. By using pip-compile instead of poetry, we can support any Python build backend. --- lockfile/src/python.rs | 13 ++++--------- lockfile_generator/src/lib.rs | 1 - lockfile_generator/src/poetry.rs | 20 -------------------- 3 files changed, 4 insertions(+), 30 deletions(-) delete mode 100644 lockfile_generator/src/poetry.rs diff --git a/lockfile/src/python.rs b/lockfile/src/python.rs index 7ffb7f836..03eb36a77 100644 --- a/lockfile/src/python.rs +++ b/lockfile/src/python.rs @@ -6,8 +6,6 @@ use anyhow::{anyhow, Context}; #[cfg(feature = "generator")] use lockfile_generator::pip::Pip as PipGenerator; #[cfg(feature = "generator")] -use lockfile_generator::poetry::Poetry as PoetryGenerator; -#[cfg(feature = "generator")] use lockfile_generator::python_requirements::PythonRequirements as PythonRequirementsGenerator; #[cfg(feature = "generator")] use lockfile_generator::Generator; @@ -43,6 +41,7 @@ impl Parse for PyRequirements { fn is_path_manifest(&self, path: &Path) -> bool { path.file_name() == Some(OsStr::new("requirements.in")) + || path.file_name() == Some(OsStr::new("pyproject.toml")) || path.file_name() == Some(OsStr::new("setup.cfg")) || path.file_name() == Some(OsStr::new("setup.py")) || self.is_path_lockfile(path) @@ -147,13 +146,9 @@ impl Parse for Poetry { path.file_name() == Some(OsStr::new("poetry.lock")) } - fn is_path_manifest(&self, path: &Path) -> bool { - path.file_name() == Some(OsStr::new("pyproject.toml")) - } - - #[cfg(feature = "generator")] - fn generator(&self) -> Option<&'static dyn Generator> { - Some(&PoetryGenerator) + fn is_path_manifest(&self, _path: &Path) -> bool { + // `pyproject.toml` is handled by PyRequirements parser + false } } diff --git a/lockfile_generator/src/lib.rs b/lockfile_generator/src/lib.rs index a1297848d..abbef41de 100644 --- a/lockfile_generator/src/lib.rs +++ b/lockfile_generator/src/lib.rs @@ -10,7 +10,6 @@ pub mod gradle; pub mod maven; pub mod npm; pub mod pip; -pub mod poetry; pub mod python_requirements; pub mod yarn; diff --git a/lockfile_generator/src/poetry.rs b/lockfile_generator/src/poetry.rs deleted file mode 100644 index 724273fa7..000000000 --- a/lockfile_generator/src/poetry.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! Python poetry ecosystem. - -use std::path::Path; -use std::process::Command; - -use crate::Generator; - -pub struct Poetry; - -impl Generator for Poetry { - fn lockfile_name(&self) -> &'static str { - "poetry.lock" - } - - fn command(&self, _manifest_path: &Path) -> Command { - let mut command = Command::new("poetry"); - command.args(["lock"]); - command - } -}