-
Notifications
You must be signed in to change notification settings - Fork 54
[build] declare kvcm_ops wheel runtime dependency #304
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
Open
wangxiyu191
wants to merge
1
commit into
main
Choose a base branch
from
harness/5174c093
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| requests==2.32.5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| import os | ||
| import subprocess | ||
| import sys | ||
| import tempfile | ||
| import unittest | ||
| import venv | ||
| from pathlib import Path | ||
|
|
||
|
|
||
| class WheelInstallTest(unittest.TestCase): | ||
| def setUp(self): | ||
| self.wheel_path = Path(sys.argv[1]).resolve() | ||
| self.temp_dir = tempfile.TemporaryDirectory() | ||
| self.addCleanup(self.temp_dir.cleanup) | ||
|
|
||
| self.temp_path = Path(self.temp_dir.name) | ||
| self.venv_path = self.temp_path / "venv" | ||
| venv.EnvBuilder(with_pip=True).create(self.venv_path) | ||
| self.python = self.venv_path / "bin" / "python" | ||
|
|
||
| self.env = os.environ.copy() | ||
| for variable in ("PYTHONHOME", "PYTHONPATH", "PYTHONUSERBASE"): | ||
| self.env.pop(variable, None) | ||
| self.env["PIP_DISABLE_PIP_VERSION_CHECK"] = "1" | ||
| self.env["PYTHONNOUSERSITE"] = "1" | ||
|
|
||
| def run_command(self, *args): | ||
| result = subprocess.run( | ||
| args, | ||
| cwd=self.temp_path, | ||
| env=self.env, | ||
| stdout=subprocess.PIPE, | ||
| stderr=subprocess.STDOUT, | ||
| text=True, | ||
| ) | ||
| self.assertEqual(0, result.returncode, msg=result.stdout) | ||
| return result.stdout | ||
|
|
||
| def test_install_resolves_requests_and_starts_http_command(self): | ||
| self.run_command( | ||
| self.python, | ||
| "-I", | ||
| "-c", | ||
| "import importlib.util; " | ||
| "assert importlib.util.find_spec('requests') is None", | ||
| ) | ||
|
|
||
| self.run_command( | ||
| self.python, | ||
| "-m", | ||
| "pip", | ||
| "install", | ||
| "--no-input", | ||
| self.wheel_path, | ||
| ) | ||
| self.run_command(self.python, "-m", "pip", "check") | ||
| self.run_command( | ||
| self.python, | ||
| "-I", | ||
| "-c", | ||
| "from importlib.metadata import version; " | ||
| "assert version('requests') == '2.32.5'; " | ||
| "import certifi, charset_normalizer, idna, requests, urllib3", | ||
| ) | ||
|
|
||
| top_level_help = self.run_command( | ||
| self.python, "-I", "-m", "kvcm_ops", "--help" | ||
| ) | ||
| self.assertIn("KVCM script entry", top_level_help) | ||
|
|
||
| http_command_help = self.run_command( | ||
| self.python, | ||
| "-I", | ||
| "-m", | ||
| "kvcm_ops", | ||
| "list_instance", | ||
| "--help", | ||
| ) | ||
| self.assertIn("kvcm: list_intance.", http_command_help) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main(argv=[sys.argv[0]]) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import email | ||
| import sys | ||
| import unittest | ||
| import zipfile | ||
| from pathlib import Path | ||
|
|
||
|
|
||
| class WheelMetadataTest(unittest.TestCase): | ||
| @classmethod | ||
| def setUpClass(cls): | ||
| wheel_path = Path(sys.argv[1]) | ||
| requirements_path = Path(sys.argv[2]) | ||
| cls.expected_requirements = [ | ||
| line.strip() | ||
| for line in requirements_path.read_text(encoding="utf-8").splitlines() | ||
| if line.strip() and not line.lstrip().startswith("#") | ||
| ] | ||
|
|
||
| with zipfile.ZipFile(wheel_path) as archive: | ||
| metadata_names = [ | ||
| name | ||
| for name in archive.namelist() | ||
| if name.endswith(".dist-info/METADATA") | ||
| ] | ||
| if len(metadata_names) != 1: | ||
| raise AssertionError( | ||
| f"expected exactly one METADATA file, found {metadata_names}" | ||
| ) | ||
| cls.metadata = email.message_from_bytes(archive.read(metadata_names[0])) | ||
|
|
||
| def test_declares_shared_runtime_requirements(self): | ||
| self.assertEqual(["requests==2.32.5"], self.expected_requirements) | ||
| self.assertEqual( | ||
| self.expected_requirements, | ||
| self.metadata.get_all("Requires-Dist", []), | ||
| ) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main(argv=[sys.argv[0]]) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 is a useful regression test, but be aware it depends on the CI runner having outbound PyPI access and a base Python with
ensurepip. If either is unavailable, thenormal_testshard will fail. Consider documenting this requirement or addingtags = ["manual"]if network access is not guaranteed.🤖 Generated by Qoder