Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ischaojie committed Jun 17, 2023
1 parent 1314cfc commit 1afffe0
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions rye/src/cli/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,17 @@ impl ReqExtras {
};
} else if let Some(ref path) = self.path {
let mut pyproject_toml = PyProject::discover()?;
let project_dir = match &self.project {
Some(name) => {
pyproject_toml = find_project_by_name(&name)?;
let project_dir = match self.project {
Some(ref name) => {
pyproject_toml = find_project_by_name(name)?;
pyproject_toml.root_path().as_ref().to_owned()
}
None => env::current_dir()?,
};
// For hatchling build backend, it use {root:uri} for file relative path,
// but this not supported by pip-tools,
// and use ${PROJECT_ROOT} will cause error in hatchling, so force absolute path.
let is_hatchling =
pyproject_toml.build_backend().unwrap() == BuildSystem::Hatchling;
let is_hatchling = pyproject_toml.build_backend().unwrap() == BuildSystem::Hatchling;
let file_url = if self.absolute || is_hatchling {
Url::from_file_path(project_dir.join(path))
.map_err(|_| anyhow!("unable to interpret '{}' as path", path.display()))?
Expand Down Expand Up @@ -206,7 +205,7 @@ pub fn execute(cmd: Args) -> Result<(), Error> {
python_path.push(VENV_BIN);
python_path.push("python");
let mut pyproject_toml = match cmd.req_extras.project {
Some(ref name) => find_project_by_name(&name)?,
Some(ref name) => find_project_by_name(name)?,
None => PyProject::discover()?,
};
let py_ver = match pyproject_toml.target_python_version() {
Expand Down

0 comments on commit 1afffe0

Please sign in to comment.