opensearch-project / opensearch-py

Python Client for OpenSearch
https://opensearch.org/docs/latest/clients/python/
Apache License 2.0
350 stars 175 forks source link

[BUG] Poetry failing to recognize file directory #493

Closed roma2023 closed 1 year ago

roma2023 commented 1 year ago

What is the bug?

Running samples with Poetry fails on Windows 10 and Mac

How can one reproduce the bug?

  1. Install Poetry in the home directory using pipx install poetry.
  2. Navigate to the "opensearch-py/samples" directory. cd opensearch-py/samples
  3. Install the project dependencies with poetry install.
  4. Execute poetry run hello/hello.py.

What is the expected behavior?

Poetry should run the samples without any errors

What is your host/environment?

Windows 10, Docker 4.17.1 (101757) macOS 10.15

Do you have any screenshots?

The result on Windows machine:

$ poetry run hello/hello.py
"hello" is not an internal or external
command, executable program, or batch file.
(base)

The result on the Mac machine: image

saimedhi commented 1 year ago

I tested this on my mac and didn't face any error. Will try it again on some other machine

  1. Installed Poetry in the home directory using pipx install poetry.
  2. Navigated to the "opensearch-py/samples" directory. cd opensearch-py/samples
  3. Installed the project dependencies with poetry install.
  4. Executed poetry run hello/hello.py.
saimedhi commented 1 year ago

If anyone else is experiencing this issue, please feel free to leave a comment here. Thank you!

dblock commented 1 year ago

I think this may be broken (wrongly documented) on Windows. Does poetry run python hello/hello.py work?

It works on *nix because hello.py has a BOM of #!/usr/bin/env python and automatically invokes python.

@roma2023 if you can confirm, let's insert python everywhere we say poetry run ... in the docs? Will you please help?

roma2023 commented 1 year ago

@dblock Yes, running poetry run python hello/hello.py works on Windows machine: image

I can take up this issue and open a new PR or fix this at #486. Thank you!

ReinGrad commented 1 year ago

In summary, it's a documentation issue on Windows due to lack of a proper shebang line in the scripts, and the recommendation is to call python explicitly when using Poetry on Windows.