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

Add poetry_requirements macro for Poetry support #12174

Merged
merged 15 commits into from
Jun 25, 2021

Conversation

wilsonliam
Copy link
Contributor

@wilsonliam wilsonliam commented Jun 3, 2021

Closes #10655.

# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
@wilsonliam wilsonliam changed the title Add support for a Poetry-style pyproject.toml file Add support for a Poetry-style pyproject.toml file [WIP] Jun 3, 2021
@wilsonliam wilsonliam marked this pull request as draft June 3, 2021 12:27
@wilsonliam wilsonliam marked this pull request as ready for review June 3, 2021 12:28
Copy link
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

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

Exciting stuff!

src/python/pants/backend/python/macros/poetry_project.py Outdated Show resolved Hide resolved
src/python/pants/backend/python/macros/poetry_project.py Outdated Show resolved Hide resolved
src/python/pants/backend/python/macros/poetry_project.py Outdated Show resolved Hide resolved
src/python/pants/backend/python/macros/poetry_project.py Outdated Show resolved Hide resolved
src/python/pants/backend/python/macros/poetry_project.py Outdated Show resolved Hide resolved
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
…into poetry_support

[ci skip-rust]

[ci skip-build-wheels]
@wilsonliam wilsonliam changed the title Add support for a Poetry-style pyproject.toml file [WIP] Add support for a Poetry-style pyproject.toml file Jun 17, 2021
Copy link
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

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

Shaping up really well! Good work :)

Copy link
Member

@stuhood stuhood left a comment

Choose a reason for hiding this comment

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

Thanks, looks good! One blocking comment.

It's particularly helpful that the tests are thorough, because that would ease porting the parsing to a parsing library at some point in the future.

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
's fix

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
@wilsonliam
Copy link
Contributor Author

@benjyw Should be complete -- if you have time, your input would be great to have

Copy link
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

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

Awesome. Other than two small code style things + adding tests for versions like 2.2.0.dev0, this looks excellent and ready to land.

proj_name: str, attributes: str | dict[str, Any] | list[dict[str, Any]], fp: str
) -> tuple[Requirement, ...]:
if isinstance(attributes, str):
# E.g. `foo = "~1.1~'.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# E.g. `foo = "~1.1~'.
# E.g. `foo = "~1.1~"`.

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
Comment on lines 69 to 70
("~1.0.0rc0", ">=1.0.0,<1.1.0"),
("^1.0.0rc0", ">=1.0.0,<2.0.0"),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that these are wrong, should likely be >=1.0.0rc0 for both. In the production code, that can be fixed by restoring your old min_version code as the raw string w/ prefix chopped off.

Copy link
Contributor Author

@wilsonliam wilsonliam Jun 24, 2021

Choose a reason for hiding this comment

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

The caret/tilde operators are somewhat variable; I have this as agreeing with NPM at the moment...I wasn't 100% sure how to check this with Poetry.

An easier fix vs going back to prior code is just to use .public instead of .base_version I think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, looks like .public does the trick!

Copy link
Contributor

Choose a reason for hiding this comment

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

Bump on this and fixing the tests. Lgtm otherwise :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh oops -- changed now; thought I was supposed to leave to match NPM.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! I'm not sure why NPM does that, this seems like more correct behavior

wilsonliam and others added 3 commits June 24, 2021 18:30
# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
@@ -1511,6 +1511,8 @@ def compute_pantsd_invalidation_globs(
# macros should be adapted to allow this dependency to be automatically detected.
"requirements.txt",
"3rdparty/**/requirements.txt",
"pyproject.toml",
"3rdparty/**/pyproject.toml",
Copy link
Member

Choose a reason for hiding this comment

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

I doubt anyone will put a pyproject.toml under 3rdparty, but it doesn't hurt to have this.

@Eric-Arellano Eric-Arellano changed the title Add support for a Poetry-style pyproject.toml file Add poetry_requirements macro for Poetry support Jun 25, 2021
@Eric-Arellano Eric-Arellano merged commit 100e8e1 into pantsbuild:main Jun 25, 2021
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.

Add Poetry macros to generate Python requirements and constraints
3 participants