vmware / vsphere-automation-sdk-python

Python samples, language bindings, and API reference documentation for vSphere, VMC, and NSX-T using the VMware REST API
MIT License
753 stars 311 forks source link

Fail to install by `poetry`. #326

Closed aragorn1025 closed 2 years ago

aragorn1025 commented 2 years ago

Describe the bug

I have tried to add and install vsphere-automation-sdk-python by using poetry.

poetry add "git+https://github.com/vmware/vsphere-automation-sdk-python.git"

However, the following error was raised:

Creating virtualenv mavis in /Users/user/Documents/project/.venv

Updating dependencies
Resolving dependencies... (37.0s)

  RuntimeError

  Unable to retrieve the package version for None

  at ~/.poetry/lib/poetry/inspection/info.py:143 in to_package
      139│         name = name or self.name
      140│
      141│         if not self.version:
      142│             # The version could not be determined, so we raise an error since it is mandatory.
    → 143│             raise RuntimeError(
      144│                 "Unable to retrieve the package version for {}".format(name)
      145│             )
      146│
      147│         package = Package(

As a result, I checked the requirements.txt and find out that if I add vapi-client-bindings==3.9.0, I get the same error message.

  ValueError

  Could not find a matching version of package vapi-client-bindings

  at ~/.poetry/lib/poetry/console/commands/init.py:367 in _find_best_version_for_package
      363│         )
      364│
      365│         if not package:
      366│             # TODO: find similar
    → 367│             raise ValueError(
      368│                 "Could not find a matching version of package {}".format(name)
      369│             )
      370│
      371│         return package.pretty_name, selector.find_recommended_require_version(package)

Reproduction steps

- Run poetry add.

  poetry add "git+https://github.com/vmware/vsphere-automation-sdk-python.git"

Expected behavior

Expected to install successful without error raised.

Additional context

No response

aagrawal3 commented 2 years ago

Installation using Poetry is currently not tested/supported.

ttanigaki commented 2 years ago

@aragorn1025

I hit the same issue. I can avoid it by the following command

poetry run pip install -U pip setuptools
poetry run pip install --upgrade git+https://github.com/vmware/vsphere-automation-sdk-python.git
wonderphil commented 2 years ago

Any chance of getting this to be supported??

jobingeo commented 2 years ago

Any chance of getting this to be supported??

Sorry! Not in immediate future. I'm closing this issue as not planned.

Can you please try the workaround mentioned by @ttanigaki and see if it helps?

jobingeo commented 2 years ago

Closing this, as there is no near term plan to fix this issue.

aragorn1025 commented 2 years ago

@ttanigaki Thank you for the solution.

@jobingeo There's another question about requirements.txt. I saw there's a dependent module that can't be downloaded. (I guess this cause error for poetry add.)

vapi-client-bindings == 3.9.0

I search this module and found out that I can only get the newer one. (link here)

vapi-client-bindings == 7.0.0

Will this have any effect?

jobingeo commented 2 years ago

I search this module and found out that I can only get the newer one. (link here)

vapi-client-bindings == 7.0.0

Will this have any effect?

The vapi-client-bindings lib you see in pypi repo is a dummy one. We just reserved it in PyPi for the future onboarding of SDK libs. For now, please don't rely on these libs from PyPi. Please use these libs locally following the SDK installation instruction here. From above error stack/comments, It seems this could have a potential impact here.

arthurzenika commented 1 year ago

Maybe this can be useful for other poetry users.

For me, with poetry 1.3 I can do poetry add https://github.com/vmware/vsphere-automation-sdk-python/archive/refs/tags/v8.0.0.1.tar.gz which works.

For poetry 1.1 I have to do add all the dependencies using poetry add https://github.com/vmware/vsphere-automation-sdk-python/archive/refs/tags/v8.0.0.1.tar.gz https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/nsx-policy-python-sdk/nsx_policy_python_sdk-4.0.1.0.0-py2.py3-none-any.whl https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/nsx-python-sdk/nsx_python_sdk-4.0.1.0.0-py2.py3-none-any.whl https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/nsx-vmc-aws-integration-python-sdk/nsx_vmc_aws_integration_python_sdk-4.0.1.0.0-py2.py3-none-any.whl https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/nsx-vmc-policy-python-sdk/nsx_vmc_policy_python_sdk-4.0.1.0.0-py2.py3-none-any.whl https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/vapi-client-bindings/vapi_client_bindings-4.0.0-py2.py3-none-any.whl https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/vapi-common-client/vapi_common_client-2.37.0-py2.py3-none-any.whl https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/vapi-runtime/vapi_runtime-2.37.0-py2.py3-none-any.whl https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/vmc-client-bindings/vmc_client_bindings-1.61.0-py2.py3-none-any.whl https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/vmc-draas-client-bindings/vmc_draas_client_bindings-1.20.0-py2.py3-none-any.whl

In my pyproject.toml I get :

[tool.poetry.dependencies]
# vsphere-automation-sdk work around
vsphere-automation-sdk = {url = "https://github.com/vmware/vsphere-automation-sdk-python/archive/refs/tags/v8.0.0.1.tar.gz"}
vmc-draas-client-bindings = {url = "https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/vmc-draas-client-bindings/vmc_draas_client_bindings-1.20.0-py2.py3-none-any.whl"}
vapi-runtime = {url = "https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/vapi-runtime/vapi_runtime-2.37.0-py2.py3-none-any.whl"}
vapi-common-client = {url = "https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/vapi-common-client/vapi_common_client-2.37.0-py2.py3-none-any.whl"}
nsx-policy-python-sdk = {url = "https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/nsx-policy-python-sdk/nsx_policy_python_sdk-4.0.1.0.0-py2.py3-none-any.whl"}
nsx-python-sdk = {url = "https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/nsx-python-sdk/nsx_python_sdk-4.0.1.0.0-py2.py3-none-any.whl"}
nsx-vmc-aws-integration-python-sdk = {url = "https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/nsx-vmc-aws-integration-python-sdk/nsx_vmc_aws_integration_python_sdk-4.0.1.0.0-py2.py3-none-any.whl"}
nsx-vmc-policy-python-sdk = {url = "https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/nsx-vmc-policy-python-sdk/nsx_vmc_policy_python_sdk-4.0.1.0.0-py2.py3-none-any.whl"}
vapi-client-bindings = {url = "https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/vapi-client-bindings/vapi_client_bindings-4.0.0-py2.py3-none-any.whl"}
vmc-client-bindings = {url = "https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/vmc-client-bindings/vmc_client_bindings-1.61.0-py2.py3-none-any.whl"}
AnatomicJC commented 11 months ago

For those interested, I added a script in this related issue to generate this dependency list.