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

PEP-517 support #1356

Merged
merged 6 commits into from
Mar 22, 2021
Merged

PEP-517 support #1356

merged 6 commits into from
Mar 22, 2021

Conversation

orsinium
Copy link
Contributor

@orsinium orsinium commented Mar 18, 2021

Changelog-friendly one-liner: Support for pyproject.toml as input dependency file (PEP-517).

If pyproject.toml is explicitly specified as input file, pip-compile will use it. Example:

pip-compile --output-file requirements.txt pyproject.toml

Included a simple test for flit

Closes #1047

Contributor checklist
  • Provided the tests for the changes.
  • Gave a clear one-line description in the PR (that the maintainers can add to CHANGELOG.md on release).
  • Assign the PR to an existing or new milestone for the target version (following Semantic Versioning).

@codecov
Copy link

codecov bot commented Mar 18, 2021

Codecov Report

Merging #1356 (6207ed9) into master (37946f2) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 6207ed9 differs from pull request most recent head e0a3b3d. Consider uploading reports for the commit e0a3b3d to get more accurate results
Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1356   +/-   ##
=======================================
  Coverage   99.65%   99.65%           
=======================================
  Files          33       33           
  Lines        2915     2940   +25     
  Branches      308      308           
=======================================
+ Hits         2905     2930   +25     
  Misses          5        5           
  Partials        5        5           
Impacted Files Coverage Δ
piptools/scripts/compile.py 100.00% <100.00%> (ø)
tests/test_cli_compile.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 37946f2...e0a3b3d. Read the comment docs.

@atugushev atugushev added enhancement Improvements to functionality setuptools Related to compiling requirements with `setuptools` build backend pep-517 Related to PEP-517 standard API labels Mar 19, 2021
Copy link
Member

@atugushev atugushev left a comment

Choose a reason for hiding this comment

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

Thanks for addressing the suggestion and adding a test 🙏🏻 A few comments below.

tests/test_cli_compile.py Outdated Show resolved Hide resolved
tests/test_cli_compile.py Outdated Show resolved Hide resolved
Copy link
Member

@atugushev atugushev left a comment

Choose a reason for hiding this comment

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

Nice! One last thing. Could dedent be used alongside triple-quote strings? That helps to reduce extra indentations.

tests/test_cli_compile.py Show resolved Hide resolved
@pytest.mark.parametrize(
("fname", "content"),
(
# setuptools
Copy link
Member

@atugushev atugushev Mar 21, 2021

Choose a reason for hiding this comment

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

Could we use pytest.param(..., id='..') instead of comments? That improves pytest -v output.

Before:

tests/test_cli_compile.py::test_input_formats[setup.cfg-\n                [metadata]\n                name = sample_lib\n                author = Vincent Driessen\n                author_email = [email protected]\n\n                [options]\n                packages = find:\n                install_requires =\n                    small-fake-a==0.1\n                    small-fake-b==0.2\n\n                [options.extras_require]\n                dev =\n                    small-fake-c==0.3\n                    small-fake-d==0.4\n                test =\n                    small-fake-e==0.5\n                    small-fake-f==0.6\n            ] PASSED [ 25%]
tests/test_cli_compile.py::test_input_formats[setup.py-\n                from setuptools import setup\n\n                setup(\n                    name="sample_lib",\n                    version=0.1,\n                    install_requires=["small-fake-a==0.1", "small-fake-b==0.2"],\n                    extras_require={\n                        "dev": ["small-fake-c==0.3", "small-fake-d==0.4"],\n                        "test": ["small-fake-e==0.5", "small-fake-f==0.6"],\n                    },\n                )\n            ] PASSED [ 50%]
tests/test_cli_compile.py::test_input_formats[pyproject.toml-\n                [build-system]\n                requires = ["flit_core >=2,<4"]\n                build-backend = "flit_core.buildapi"\n\n                [tool.flit.metadata]\n                module = "sample_lib"\n                author = "Vincent Driessen"\n                author-email = "[email protected]"\n\n                requires = ["small-fake-a==0.1", "small-fake-b==0.2"]\n\n                [tool.flit.metadata.requires-extra]\n                dev  = ["small-fake-c==0.3", "small-fake-d==0.4"]\n                test = ["small-fake-e==0.5", "small-fake-f==0.6"]\n            ] PASSED [ 75%]
tests/test_cli_compile.py::test_input_formats[pyproject.toml-\n                [build-system]\n                requires = ["poetry_core>=1.0.0"]\n                build-backend = "poetry.core.masonry.api"\n\n                [tool.poetry]\n                name = "sample_lib"\n                version = "0.1.0"\n                description = ""\n                authors = ["Vincent Driessen <[email protected]>"]\n\n                [tool.poetry.dependencies]\n                python = "*"\n                small-fake-a = "0.1"\n                small-fake-b = "0.2"\n\n                small-fake-c = "0.3"\n                small-fake-d = "0.4"\n                small-fake-e = "0.5"\n                small-fake-f = "0.6"\n\n                [tool.poetry.extras]\n                dev  = ["small-fake-c", "small-fake-d"]\n                test = ["small-fake-e", "small-fake-f"]\n            ] PASSED [100%]

After:

tests/test_cli_compile.py::test_input_formats[setup.cfg] PASSED                                                                                                                                      [ 25%]
tests/test_cli_compile.py::test_input_formats[setup.py] PASSED
tests/test_cli_compile.py::test_input_formats[flit] PASSED
tests/test_cli_compile.py::test_input_formats[poetry] PASSED

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, great idea. Fixed 👍🏿

Copy link
Member

Choose a reason for hiding this comment

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

FYI another nice way to do this would be to add ids=('setup.cfg', 'setup.py'). Sometimes it's easier than embedding the ids into each param. But of course, it depends on the situation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good to know, thank you 👍🏿 I think in this situation it looks nice to have it per case.

),
),
)
def test_input_formats(runner, tmpdir, fname, content):
Copy link
Member

Choose a reason for hiding this comment

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

tmpdir is sorta deprecated (well, at least there's a mention of it being replaced). It's always better to use tmp_path which does the same except it injects pathlib.Path objects instead of py.path which are nicer to work with.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, I know. But all other tests in this file use tmpdir. I think it's better to keep it consistent and migrate all at once.

@orsinium

This comment has been minimized.

@orsinium

This comment has been minimized.

Copy link
Member

@atugushev atugushev left a comment

Choose a reason for hiding this comment

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

LGTM 👍🏻

@atugushev atugushev added this to the 6.1.0 milestone Mar 22, 2021
@atugushev atugushev merged commit bd9eab1 into jazzband:master Mar 22, 2021
@atugushev
Copy link
Member

@orsinium thanks for the contribution! Awesome job! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvements to functionality pep-517 Related to PEP-517 standard API setuptools Related to compiling requirements with `setuptools` build backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support setup.py-less setups
3 participants