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

feat: python plugin file listing #943

Merged

Conversation

mattculler
Copy link
Contributor

  • Have you signed the CLA?
  • Have you added an entry to the changelog (docs/reference/changelog.rst)?

Implement origin package -> file mapping for the python plugin, to be used in xattr tagging.

(CRAFT-3758)

@mattculler mattculler self-assigned this Dec 17, 2024
@mattculler mattculler marked this pull request as ready for review December 18, 2024 06:34
@mattculler mattculler requested review from lengau and tigarmo December 18, 2024 06:38
craft_parts/plugins/base.py Outdated Show resolved Hide resolved
@@ -73,3 +77,38 @@ def _get_package_install_commands(self) -> list[str]:
)

return commands

@override
def get_files(self) -> PackageFiles:
Copy link
Contributor

Choose a reason for hiding this comment

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

I'll bet we can put this in the base Python plugin. In all three cases they generate PEP 405 compatible virtual environments in self._get_venv_directory(). (I'm fine if you don't do so in this PR, but when we get to the point of implementing it for poetry and uv it probably comes roughly for free)

craft_parts/plugins/python_plugin.py Outdated Show resolved Hide resolved
tests/integration/plugins/test_python.py Outdated Show resolved Hide resolved
tests/integration/plugins/test_python.py Show resolved Hide resolved
Copy link
Contributor

@tigarmo tigarmo left a comment

Choose a reason for hiding this comment

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

thanks!

craft_parts/plugins/base.py Outdated Show resolved Hide resolved
craft_parts/plugins/python_plugin.py Outdated Show resolved Hide resolved
# over time. And we can't assert the number of keys because py3.10 installs
# setuptools as a separate package.
print(actual_file_list.keys())
for expected_pkg in {
Copy link
Contributor

Choose a reason for hiding this comment

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

won't this fail as soon as a new version of any of these packages comes out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tests/unit/plugins/test_python_plugin.py Outdated Show resolved Hide resolved
@tigarmo
Copy link
Contributor

tigarmo commented Dec 18, 2024

sheesh @mattculler sorry for the noise, I guess Alex and I were reviewing this at the same time and ended up pointing out the same things

@mattculler
Copy link
Contributor Author

sheesh @mattculler sorry for the noise, I guess Alex and I were reviewing this at the same time and ended up pointing out the same things

No worries, it's actually really impressive how similar your reviews were.

craft_parts/plugins/python_plugin.py Outdated Show resolved Hide resolved
pkgs_install_dir.mkdir(parents=True)
bins_dir.mkdir()

(bins_dir / "doit").touch()
Copy link
Contributor

Choose a reason for hiding this comment

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

This is better but I was thinking you could add the actual file tree, with fakeee directory and fakeee/a_file.py file and so on, to a git-committed dir
like the integration tests do, but there's nothing restricting that to integration tests: https://github.com/canonical/craft-parts/tree/main/tests/integration/plugins/test_python

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok will do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mattculler mattculler requested review from tigarmo and lengau December 19, 2024 15:17
@mattculler mattculler requested a review from lengau December 19, 2024 17:07
for found_pkg in actual_file_list:
# Check a few specifics to make sure we got package contents correctly
if found_pkg.name == "Jinja2":
assert len(actual_file_list[found_pkg]) == 57
Copy link
Contributor

Choose a reason for hiding this comment

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

We can't know this for anything where we're not asserting a specific package. We can probably presume it to be a nonzero number, but the only one we can have any real confidence in is flask.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dammit, good point.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mattculler mattculler requested a review from lengau December 19, 2024 22:57
Copy link
Contributor

@lengau lengau left a comment

Choose a reason for hiding this comment

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

LGTM! Adding @mr-cal for final review as the project owner

@lengau lengau requested a review from mr-cal December 20, 2024 00:04
@mr-cal mr-cal merged commit 34a6bbf into feature/origin-tagging Dec 20, 2024
13 checks passed
@mr-cal mr-cal deleted the work/CRAFT-3758-origin-tagging-for-python-plugin branch December 20, 2024 15:42
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.

4 participants