Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make dashes underscores in python package names #2073

Merged
Merged
Changes from 1 commit
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
9 changes: 7 additions & 2 deletions src/cli/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ platforms = {{ platforms }}
{%- endif %}

[tool.pixi.pypi-dependencies]
{{ name }} = { path = ".", editable = true }
{{ pypi_package_name }} = { path = ".", editable = true }

[tool.pixi.tasks]

Expand Down Expand Up @@ -334,12 +334,16 @@ pub async fn execute(args: Args) -> miette::Result<()> {

// Create a 'pyproject.toml' manifest
} else if pyproject {
// Python package names cannot contain '-', so we replace them with '_'
let pypi_package_name = default_name.replace("-", "_");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps better to parse the name as PackageName and use the dist info name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it!


let rv = env
.render_named_str(
consts::PYPROJECT_MANIFEST,
NEW_PYROJECT_TEMPLATE,
context! {
name => default_name,
pypi_package_name,
version,
author,
channels,
Expand All @@ -350,7 +354,8 @@ pub async fn execute(args: Args) -> miette::Result<()> {
)
.unwrap();
save_manifest_file(&pyproject_manifest_path, rv)?;
let src_dir = dir.join("src").join(default_name);

let src_dir = dir.join("src").join(pypi_package_name);
tokio::fs::create_dir_all(&src_dir)
.await
.into_diagnostic()
Expand Down
Loading