Skip to content

Conversation

telamonian
Copy link

fixes #2523

Done at SciPy sprints 2025! @wolfv @ruben-arts

Currently produces a valid pyproject.toml file, probably not yet complete. There's kind of a tangle of conditionals in init.rs, so we should probably have a conversation about intended behavior.

Might also have some overlap with #4096

…rror

- produces a valid pyproject.toml file, probably not yet complete
@baszalmstra baszalmstra requested a review from ruben-arts July 14, 2025 07:13
@baszalmstra baszalmstra added the enhancement New features label Jul 14, 2025
@lucascolley lucascolley added area:init Related to pixi init pyproject labels Jul 21, 2025
@lucascolley
Copy link
Collaborator

I'll review this after gh-4096 is merged.

@lucascolley lucascolley self-requested a review July 22, 2025 14:20
@lucascolley
Copy link
Collaborator

will this also close gh-3499?

@lucascolley lucascolley mentioned this pull request Jul 24, 2025
14 tasks
@lucascolley lucascolley changed the title init --import enviornment.yml --format pyproject now runs without error feat(init): support --import with --format pyproject Jul 29, 2025
Copy link
Collaborator

@lucascolley lucascolley left a comment

Choose a reason for hiding this comment

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

thanks @telamonian, looks like a good start!

Please could you add some tests, following the style of https://github.com/prefix-dev/pixi/blob/main/tests/integration_python/test_import.py ? I think one test for a successful import and one test for the user dialog would be a good start, we can add some more later. Don't worry about including any snapshots in the tests yet though, we are in the process of updating our contributor guidance for that.

} else {
config.default_channels().to_vec()
};
// Check if the 'pixi.toml' file doesn't already exist. We don't want to
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// Check if the 'pixi.toml' file doesn't already exist. We don't want to
// Check that the 'pixi.toml' file doesn't already exist. We don't want to

Comment on lines 423 to +428
eprintln!(
"\nA '{}' file already exists.\n",
console::style(consts::PYPROJECT_MANIFEST).bold()
"{}Created {}",
console::style(console::Emoji("✔ ", "")).green(),
// Canonicalize the path to make it more readable, but if it fails just use the path as
// is.
workspace.workspace.provenance.path.display()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we want to include this in the pyproject path also?

.map(|name| name.as_dist_info_name().to_string())
.unwrap_or_else(|_| name.clone());

let rv = env
Copy link
Collaborator

Choose a reason for hiding this comment

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

what does rv stand for?

format!("Could not create file {}.", init_file.display())
});
}
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

have I missed something, or does the pyproject path not use (conda_deps, pypi_deps) from above? If so, I think import will not work properly.

Copy link
Collaborator

@lucascolley lucascolley left a comment

Choose a reason for hiding this comment

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

see above review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:init Related to pixi init enhancement New features pyproject
Projects
None yet
Development

Successfully merging this pull request may close these issues.

init: Allow '--import <ENV_FILE>' and '--format <FORMAT>' together
3 participants