Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ and listed with their assets on the

## [Unreleased]

### Added

- **`devstack init` sets `PYTHONUTF8 = "1"` for Python apps.** On Windows a
native Python process opens text files in the ANSI code page (cp1252)
unless the code passes `encoding=`, while the same code in a container
reads UTF-8: UTF-8 fixtures turned into mojibake only under devstack. The
draft now gives each Django, FastAPI and Flask service the variable in its
`env`, and the stack file reference and the `devstack-config` skill name
the pitfall (#464).

### Changed

- **devstack finds the stack file from any folder of the repository.**
Expand Down
20 changes: 19 additions & 1 deletion crates/devstack/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,13 @@ fn python(repo: &Path, dir: &Path, all: &[PathBuf]) -> Option<Svc> {
} else {
return None;
}
// On Windows, Python opens text files in the ANSI code page (cp1252)
// unless told otherwise; in a container the same code reads UTF-8 (#464).
let _ = writeln!(b, "\n[services.{name}.env]");
let _ = writeln!(
b,
"PYTHONUTF8 = \"1\" # files as UTF-8, as on Linux (Windows reads them as cp1252 otherwise)"
);
Some(Svc { name, body: b })
}

Expand Down Expand Up @@ -1002,7 +1009,18 @@ mod tests {
"{}",
d.text
);
devstack_config::from_str(&d.text, &r.join("devstack.toml")).expect("the draft loads");
let stack =
devstack_config::from_str(&d.text, &r.join("devstack.toml")).expect("the draft loads");
// Python reads files as UTF-8 on Windows too (#464); nothing else gets it.
for n in ["api", "admin"] {
assert_eq!(
stack.services[n].env.get("PYTHONUTF8").map(String::as_str),
Some("1"),
"{n}\n{}",
d.text
);
}
assert!(!stack.services["orders"].env.contains_key("PYTHONUTF8"));
}

#[test]
Expand Down
4 changes: 4 additions & 0 deletions docs/stack-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,10 @@ Telemetry__Endpoint = "http://127.0.0.1:4317"
telemetry.
- On Windows, variable names that differ only in case are one variable: the
later layer wins, and `${PATH}` finds `Path`.
- On Windows, Python opens text files in the ANSI code page (cp1252) unless
the code passes `encoding=`; in a container the same code reads UTF-8. Give
native Python services and commands `PYTHONUTF8 = "1"` in `env` (harmless
on Linux and macOS); `devstack init` writes it for the Python apps it finds.
- `rewrite_hosts` needs `compose`; each entry is a service the service's own
group starts, or `<group>.<service>` of another. `workers.env` names at
least one variable.
Expand Down
4 changes: 4 additions & 0 deletions skills/devstack-config/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ without a stack file starts from `devstack init` (a draft with TODOs).
instance, only one of them may run schedulers and queue consumers: put their
switches into `[services.<name>.workers] env = { X = "{is_main}" }`, not into
`env`.
- **Python on Windows reads files as cp1252.** A native Python service or
command opens text files in the ANSI code page unless the code passes
`encoding=`, so UTF-8 fixtures turn into mojibake only under devstack. Set
`PYTHONUTF8 = "1"` in its `env`.
- **Lanes have their own containers.** A worktree runs as a lane with its
ports moved (`[lanes] port_step`) and its own Compose project, so its
database is its own and needs no `{lane_suffix}`. Every lane starts all of
Expand Down