mssql-cli icon indicating copy to clipboard operation
mssql-cli copied to clipboard

Can't use master branch with pip installation

Open petobens opened this issue 6 years ago • 10 comments

Hi! This is a follow-up of the discussion in #229: basically if I install mssql-cli latest stable release with pip by doing

pip install --user mssql-cli

then I can connect to a db by running something like mssql-cli -S host -U user -P password without any problems. However when I install the latest (master) version by virtue of

pip install --user git+https://github.com/dbcli/mssql-clii

then the package is correctly installed but when attempting to connect to a database I get:

Traceback (most recent call last):
  File "/home/pedro/.local/bin/mssql-cli", line 10, in <module>
    sys.exit(main())
  File "/home/pedro/.local/lib/python3.7/site-packages/mssqlcli/main.py", line 93, in main
    run_cli_with(mssqlcli_options)
  File "/home/pedro/.local/lib/python3.7/site-packages/mssqlcli/main.py", line 51, in run_cli_with
    mssqlcli = MssqlCli(options)
  File "/home/pedro/.local/lib/python3.7/site-packages/mssqlcli/mssql_cli.py", line 191, in __init__
    self.sqltoolsclient = SqlToolsClient(enable_logging=options.enable_sqltoolsservice_logging)
  File "/home/pedro/.local/lib/python3.7/site-packages/mssqlcli/sqltoolsclient.py", line 34, in __init__
    sqltoolsservice_args = [mssqltoolsservice.get_executable_path()]
  File "/home/pedro/.local/lib/python3.7/site-packages/mssqlcli/mssqltoolsservice/__init__.py", line 31, in get_executable_path
    raise EnvironmentError(error_message)
OSError: /home/pedro/.local/lib/python3.7/site-packages/mssqlcli/mssqltoolsservice/bin/MicrosoftSqlToolsServiceLayer does not exist. Please re-install the mssql-cli package
Exception ignored in: <function MssqlCli.__del__ at 0x7f3f89fe5ae8>
Traceback (most recent call last):
  File "/home/pedro/.local/lib/python3.7/site-packages/mssqlcli/mssql_cli.py", line 196, in __del__
    if self.sqltoolsclient:
AttributeError: 'MssqlCli' object has no attribute 'sqltoolsclient'

petobens avatar Mar 11 '19 10:03 petobens

Hi. This is my workaround.

  1. Download Microsoft SQL Tools Service Layer from dbcli/mssql-cli/sqltoolsservice/manylinux1.

  2. Go to mssqltoolsservice directory, i.e. cd /<user_local>/lib/python3.7/site-packages/mssqlcli/mssqltoolsservice/.

  3. Create a bin directory and go into it, i.e. mkdir bin && cd bin.

  4. Move the downloaded file here and extract it, i.e. mv /<download_path>/Microsoft.SqlTools.ServiceLayer-linux-x64-netcoreapp2.1.tar.gz . ; tar -xf Microsoft.SqlTools.ServiceLayer-linux-x64-netcoreapp2.1.tar.gz

Try to run mssql-cli. It should be working.

I tried to find which edit caused this error, but I failed. Hope this info can help.

dianhenglau avatar Apr 25 '19 16:04 dianhenglau

This indeed works. It would be good if someone could create a PR with it. Thanks!

petobens avatar Jul 12 '19 20:07 petobens

Is there a specific reason to use pip+git to install?

The downside I see is package size. We ship a native dependency, so we actually upload 4 platform specific mssql-cli wheels to pypi. Depending on the platform running the pip command, the appropriate wheel is downloaded which only has the binaries specific to the platform. This keeps each wheel on pypi much smaller since pip+git includes native binaries for all platforms. We could make pip+git work, but I question the priority of this use case.

pensivebrian avatar Aug 18 '19 15:08 pensivebrian

I believe it's a natural/normal use case to use pip to install dev versions of a python library through pip. Is there a valid/better alternative?

petobens avatar Aug 18 '19 15:08 petobens

Running dev_setup.py will take care of unpacking the appropriate native binaries and installing dev dependencies.

Our current setup instructions: https://github.com/dbcli/mssql-cli/blob/master/doc/development_guide.md#development-setup

Does this look reasonable?

pensivebrian avatar Aug 18 '19 16:08 pensivebrian

Or, the following command will install the latest build from master:

pip install --pre --no-cache --extra-index-url https://mssqlcli.blob.core.windows.net/daily/whl mssql-cli

pensivebrian avatar Aug 18 '19 16:08 pensivebrian

Thanks for that. My question however was if we could somehow make the following (customary) incantation work:

pip install --user git+https://github.com/dbcli/mssql-cli

since this is how most libraries are installed using pip+git. I guess the is answer seem to be "no" or "not for the time being"?

petobens avatar Aug 18 '19 16:08 petobens

Not for the time being. If this is a common use case, I'd like to support it.

I'm going to have to look into this a bit more and see how this impacts our setup.py and how we resolve native dependencies at runtime. I'll leave this open and use upvotes to prioritize this work relative to other open issues.

To be honest, I wasn't aware that you could pip install from git like this until I saw this issue, so thanks for filing this this issue.

pensivebrian avatar Aug 18 '19 17:08 pensivebrian

Great. Thanks!

petobens avatar Aug 18 '19 17:08 petobens

sadly this is still broken :(

Darkcast avatar Sep 08 '22 16:09 Darkcast