-
-
Notifications
You must be signed in to change notification settings - Fork 467
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
Add basic metadata importing to init command #265
Conversation
Does not include default file name fallback (requirements.txt,requirements-dev.txt,etc.)
One thought I have is that if |
e18f12d adds an assumed import. If you'd prefer waiting for user input or something similar/more explicit I'll modify it. |
I'm changing this PR to only tag #191 instead of closing. I think we'd want to close it when/if requirements parsing is fully supported, when we're able to import from poetry-managed projects (or other tooling), and after we'd decided if we see a future where Rye fully supports setup file managed projects. |
Marking this as ready for a review, but I'd like to do more testing later. Here's where it's at so far: See PR description for callouts.
|
} | ||
if let Some(Some(reqs)) = section.get("install_requires") { | ||
reqs.lines() | ||
.filter_map(|x| Requirement::from_str(x).ok()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will silently fail
reqs.iter() | ||
.map(ToString::to_string) | ||
.map(escape_string) | ||
.filter_map(|x| Requirement::from_str(&x).ok()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will silently fail
if let Some(Value::String(name)) = json.get("name") { | ||
if metadata.name.is_none() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if let Some(Value::String(name)) = json.get("name") { | |
if metadata.name.is_none() { | |
if metadata.name.is_none() { | |
if let Some(Value::String(name)) = json.get("name") { |
Might flip these
This looks pretty good but I will need to do some tests still. Will try to get to it on the weekend. |
Have you thought about how we want to do testing in general? I'm happy to introduce some here for this change, but I want to align with broader testing of rye. |
I've been concerned about the lack of extensive testing for rye, and if someone can add some tests as a reference (I lack experience in this area of rust), I'd be happy to contribute. |
I will merge this now. I did not make progress on tests yet, but that should not hold this up. |
Summary of changes
configparser
for INI file parsingmonotrail-utils
forRequirementsTxt
requirements file parsing.rye init
by default will attempt an import from setup.cfg and setup.py files (setup.py is prioritized)--no-import
argument-r
/--requirements
and--dev-requirements
arguments for requirements filesHow it works
If
--no-import
is not used:-r
/--requirements
/--dev-requirements
RequirementsTxt
is used frommonotrail-utils
for requirements file parsing.rye
attempts an import.--no-import
Tag #191
TODO: