-
Notifications
You must be signed in to change notification settings - Fork 13
Core updates #318
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
Core updates #318
Changes from all commits
eb5905b
7bdf178
03faf2b
02a857a
8d08caf
88a6078
065cdd2
5fbd268
ddb34ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -588,7 +588,14 @@ def install_library(self, library, force=False, pre_release=False): | |
| """ | ||
| name, name_with_version, _ = self.install_agent_or_lib_source(library, force, pre_release) | ||
| return name_with_version | ||
|
|
||
|
|
||
| def remove_library(self, library): | ||
| """ | ||
| Removes the library from current pyproject toml project, which in turn uninstalls the library from current | ||
| venv | ||
| """ | ||
| cmd = ["poetry", "--directory", self._server_opts.poetry_project_path.as_posix(), "remove", library] | ||
| execute_command(cmd) | ||
|
|
||
| def _raise_error_if_identity_exists_without_force(self, vip_identity: str, force: bool): | ||
| """ | ||
|
|
@@ -764,7 +771,14 @@ def _construct_package_name_from_wheel(agent_wheel): | |
| agent_name = agent_wheel | ||
| if agent_wheel.endswith(".whl"): | ||
| wheel = agent_wheel.split("/")[-1] | ||
| agent_name_with_version = wheel.replace("-py3-none-any.whl", "").replace("_", "-") | ||
| # handle both py3 and python2&3 compatible wheels | ||
| stripped = re.sub(r'-(py2\.py3|py3)-[^-]+-[^-]+\.whl$', '', wheel) | ||
| if stripped == wheel: | ||
| raise RuntimeError( | ||
| f"Unable to parse package name from wheel filename '{wheel}'. " | ||
| f"Expected format: {{name}}-{{version}}-(py3|py2.py3)-{{abi}}-{{platform}}.whl" | ||
| ) | ||
| agent_name_with_version = stripped.replace("_", "-") | ||
|
Comment on lines
+774
to
+781
|
||
| agent_name = agent_name_with_version[:agent_name_with_version.rfind("-")] | ||
| return agent_name | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,15 +45,25 @@ | |
| try: | ||
| # We should be in a develop environment therefore | ||
| # we can get the version from the toml pyproject.toml | ||
| root = Path(__file__).parent.parent.parent | ||
| tomle_file = root.joinpath("pyproject.toml") | ||
| if not tomle_file.exists(): | ||
| root = Path(__file__).parent.parent.parent.parent | ||
| toml_file = root.joinpath("pyproject.toml") | ||
| if not toml_file.exists(): | ||
| raise ValueError( | ||
| f"Couldn't find pyproject.toml file for finding version. ({str(tomle_file)})") | ||
| import toml | ||
| f"Couldn't find pyproject.toml file for finding version. ({str(toml_file)})") | ||
|
|
||
| pyproject = toml.load(tomle_file) | ||
| # Prefer stdlib tomllib when available (Python 3.11+), fall back to tomli if installed. | ||
| try: | ||
|
Comment on lines
+48
to
+55
|
||
| # works if python3.11+ | ||
| import tomllib as toml_loader # type: ignore[attr-defined] | ||
| except ModuleNotFoundError: | ||
| try: | ||
| import tomli as toml_loader # type: ignore[import] | ||
| except ModuleNotFoundError: | ||
| # Neither tomllib nor tomli is available; fall back to pip list mechanism. | ||
| raise ValueError("No TOML parser available") | ||
|
|
||
| with open(toml_file, "rb") as f: | ||
| pyproject = toml_loader.load(f) | ||
| __version__ = pyproject["tool"]["poetry"]["version"] | ||
| except ValueError: | ||
| cmd = [sys.executable, "-m", "pip", "list"] | ||
|
|
||
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.
The wheel filename parser only accepts python tags
py3orpy2.py3and will raise for valid wheels likepkg-1.0.0-cp310-cp310-manylinux_2_17_x86_64.whl(and also doesn’t account for the optional PEP 427 build tag). Sinceinstall_agent_or_lib_sourcecan receive arbitrary wheels, consider parsing per PEP 427 more generally (e.g., accept any python/abi/platform tags and handle an optional build tag) so compiled/tagged wheels don’t get rejected.