Skip to content

Commit

Permalink
Add -dbg to the toolchain name for debug builds (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko authored May 30, 2023
1 parent d1ee4a8 commit f2806a2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ that were not yet released.

_Unreleased_

- When a Python debug build (`Py_DEBUG`) is registered as custom toolchain,
`-dbg` is automatically appended to the name by default. #269

- lto+pgo builds are now preferred for the Python toolchain builds when
available. #268

Expand Down
8 changes: 5 additions & 3 deletions docs/guide/toolchains/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ command.
rye toolchain register /path/to/python
```

The name of the toolchain is picked based on the interpreter. For instance linking a regular
cpython installation will be called `cpython@version`, whereas linking pypy would show up as
`pypy@version`. To override the name you can pass `--name`:
The name of the toolchain is picked based on the interpreter. For instance
linking a regular cpython installation will be called `cpython@version`, whereas
linking pypy would show up as `pypy@version`. From Rye 0.5.0 onwards `-dbg` is
appended to the name of the toolchain if it's a debug build. To override the
name you can pass `--name`:

```
rye toolchain register --name=custom /path/to/python
Expand Down
6 changes: 5 additions & 1 deletion rye/src/cli/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@ use crate::utils::symlink_file;
const INSPECT_SCRIPT: &str = r#"
import json
import platform
import sysconfig
print(json.dumps({
"python_implementation": platform.python_implementation(),
"python_version": platform.python_version(),
"python_debug": bool(sysconfig.get_config_var('Py_DEBUG')),
}))
"#;

#[derive(Debug, Deserialize)]
struct InspectInfo {
python_implementation: String,
python_version: String,
python_debug: bool,
}

/// Helper utility to manage Python toolchains.
Expand Down Expand Up @@ -98,8 +101,9 @@ fn register(cmd: RegisterCommand) -> Result<(), Error> {
Some(ref name) => format!("{}@{}", name, info.python_version),
None => {
format!(
"{}@{}",
"{}{}@{}",
info.python_implementation.to_ascii_lowercase(),
if info.python_debug { "-dbg" } else { "" },
info.python_version
)
}
Expand Down

0 comments on commit f2806a2

Please sign in to comment.