Can't use master branch with pip installation
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'
Hi. This is my workaround.
-
Download Microsoft SQL Tools Service Layer from
dbcli/mssql-cli/sqltoolsservice/manylinux1. -
Go to
mssqltoolsservicedirectory, i.e.cd /<user_local>/lib/python3.7/site-packages/mssqlcli/mssqltoolsservice/. -
Create a
bindirectory and go into it, i.e.mkdir bin && cd bin. -
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.
This indeed works. It would be good if someone could create a PR with it. Thanks!
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.
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?
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?
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
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"?
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.
Great. Thanks!
sadly this is still broken :(