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

Implement emitting of some project dependencies #17

Merged
merged 7 commits into from
Jul 15, 2023

Conversation

sjlongland
Copy link
Collaborator

This picks up setup_requires and install_requires, and puts those in the build dependencies and project dependencies TOML output.

If setuptools is already listed by the project, we avoid duplicating it. Dependencies are also "normalised" in alphabetical order, with duplicates removed.

@sjlongland sjlongland requested a review from diazona July 8, 2023 09:16
Copy link
Owner

@diazona diazona left a comment

Choose a reason for hiding this comment

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

Nice to see the main functionality moving forward 😄

Don't take this to imply that any of what you did here is somehow "wrong", but I have some thoughts on how the tests are going to work. When I was writing that first test, it occurred to me that it's kind of inefficient to have the plugin generate a data structure and write it out into TOML, only to parse the TOML back into a data structure again. So I was thinking of refactoring the plugin to separate the part that actually generates the pyproject data structure from the part that writes that out into a TOML file, and that way most of our tests could be unit tests on the former part, so they wouldn't have to go through the full complexity of rendering and then re-parsing the TOML. We could just keep a couple of tests that write out the TOML file to make sure that the file-writing part doesn't fail.

Though, now that I think about it, even if you're on board with that, it is very possible that the best way to move forward is to just merge this and then I can refactor the tests in a separate PR to show you what I mean. What do you think?

src/setuptools_pyproject_migration/__init__.py Outdated Show resolved Hide resolved
src/setuptools_pyproject_migration/__init__.py Outdated Show resolved Hide resolved
src/setuptools_pyproject_migration/__init__.py Outdated Show resolved Hide resolved
@diazona diazona added this to the Initial release milestone Jul 8, 2023
sjlongland added a commit that referenced this pull request Jul 8, 2023
I had it in my brain that `sorted()` returned an iterator and thus this
needed to be captured into a list.  Wrong, it actually does return a
list, so the extra `list()` is redundant.

Credit: #17 (comment)
sjlongland added a commit that referenced this pull request Jul 8, 2023
sjlongland added a commit that referenced this pull request Jul 9, 2023
I had it in my brain that `sorted()` returned an iterator and thus this
needed to be captured into a list.  Wrong, it actually does return a
list, so the extra `list()` is redundant.

Credit: #17 (comment)
sjlongland added a commit that referenced this pull request Jul 9, 2023
@sjlongland sjlongland force-pushed the feature/emit-dependencies branch from 91f66fa to bf4e849 Compare July 9, 2023 05:52
Copy link
Owner

@diazona diazona left a comment

Choose a reason for hiding this comment

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

It turns out that the refactoring I had in mind above is a little more complex than I anticipated, so I think it makes sense to leave that for a separate PR. I'll make that PR when I have the code ready.

Just one last suggestion about the possibly-redundant comments, but I'm approving this regardless because that's not worth blocking the merge. I leave it up to you @sjlongland to decide whether to remove those comments or not, and then once you do, feel free to merge it yourself. (Or you can re-request review and I'll merge it if you feel better doing it that way.)

tests/test_setup_command.py Outdated Show resolved Hide resolved
tests/test_setup_command.py Show resolved Hide resolved
This simplifies the logic needed to parse `install_requires`,
`setup_requires`, etc.
This hopefully should copy across the dependencies from the original
project `setup.py`.

Omit project dependencies if none are specified.
I suspect different versions of `tomlkit` may at times, return slightly
differing outputs which, whilst syntactically equivalent, will trip up a
simple string comparison.

Instead, parse the reference and returned TOML documents, then compare
those parsed object trees.  This should be less sensitive to formatting
differences whilst still catching issues when they arise.
I had it in my brain that `sorted()` returned an iterator and thus this
needed to be captured into a list.  Wrong, it actually does return a
list, so the extra `list()` is redundant.

Credit: #17 (comment)
@sjlongland sjlongland force-pushed the feature/emit-dependencies branch from bf4e849 to 6ecd03c Compare July 15, 2023 01:02
@diazona
Copy link
Owner

diazona commented Jul 15, 2023

Hmm I'm using the app and it's not showing me what is blocking the merge now... Assuming my approval went through, feel free to merge this yourself @sjlongland, and if it didn't then I'll figure this out when I get back to my computer.

@sjlongland
Copy link
Collaborator Author

Yeah, I think Github got its knickers in a twist over the comments that I removed, it didn't notice the suggestion was basically implemented and that the comment was now resolved. :-)

@sjlongland sjlongland merged commit 83416e9 into main Jul 15, 2023
@sjlongland sjlongland deleted the feature/emit-dependencies branch July 15, 2023 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants