Fix cross platform download and installation for windows
This commit is contained in:
Родитель
e4a99adda1
Коммит
29e0b2f84f
|
@ -6,7 +6,7 @@ sqlmlutils is a python package to help execute Python code on a SQL Server machi
|
|||
|
||||
From a command prompt, run
|
||||
```
|
||||
python.exe -m pip install --upgrade --upgrade-strategy only-if-needed dist/sqlmlutils-0.6.0.zip
|
||||
python.exe -m pip install --upgrade --upgrade-strategy only-if-needed dist/sqlmlutils-0.6.1.zip
|
||||
```
|
||||
OR
|
||||
To build a new package file and install (windows), run
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
python.exe setup.py sdist --formats=zip
|
||||
python.exe -m pip install --upgrade --upgrade-strategy only-if-needed dist\sqlmlutils-0.6.0.zip
|
||||
python.exe -m pip install --upgrade --upgrade-strategy only-if-needed dist\sqlmlutils-0.6.1.zip
|
||||
|
|
Двоичный файл не отображается.
Двоичный файл не отображается.
|
@ -6,7 +6,7 @@ from distutils.core import setup
|
|||
setup(
|
||||
name='sqlmlutils',
|
||||
packages=['sqlmlutils', 'sqlmlutils/packagemanagement'],
|
||||
version='0.6.0',
|
||||
version='0.6.1',
|
||||
url='https://github.com/Microsoft/sqlmlutils',
|
||||
license='MIT License',
|
||||
description='A client side package for working with SQL Machine Learning Python Services. '
|
||||
|
|
|
@ -17,6 +17,8 @@ else:
|
|||
from pip import main as pipmain
|
||||
|
||||
# Monkey patch the pip version information with server information
|
||||
pep425tags.is_manylinux2010_compatible = lambda: True
|
||||
pep425tags.is_manylinux1_compatible = lambda: True
|
||||
pep425tags.get_impl_version_info = lambda: eval(sys.argv[1])
|
||||
pep425tags.get_abbr_impl = lambda: sys.argv[2]
|
||||
pep425tags.get_abi_tag = lambda: sys.argv[3]
|
||||
|
|
|
@ -30,12 +30,15 @@ class PipDownloader:
|
|||
commands.append("--no-dependencies")
|
||||
|
||||
output, error = self._run_in_new_process(commands)
|
||||
|
||||
|
||||
pkgreqs = self._get_reqs_from_output(output)
|
||||
|
||||
packagesdownloaded = [os.path.join(self._downloaddir, f) for f in os.listdir(self._downloaddir)
|
||||
if os.path.isfile(os.path.join(self._downloaddir, f))]
|
||||
|
||||
if len(packagesdownloaded) <= 0:
|
||||
raise RuntimeError("Failed to download any packages, pip returned error: " + error)
|
||||
|
||||
return pkgreqs, packagesdownloaded
|
||||
|
||||
def _run_in_new_process(self, commands):
|
||||
|
|
|
@ -30,7 +30,7 @@ class SQLPackageManager:
|
|||
upgrade: bool = False,
|
||||
version: str = None,
|
||||
install_dependencies: bool = True,
|
||||
scope: Scope = Scope.private_scope()):
|
||||
scope: Scope = None):
|
||||
"""Install Python package into a SQL Server Python Services environment using pip.
|
||||
|
||||
:param package: Package name to install on the SQL Server. Can also be a filename.
|
||||
|
@ -63,13 +63,16 @@ class SQLPackageManager:
|
|||
if not install_dependencies:
|
||||
raise ValueError("Dependencies will always be installed - "
|
||||
"single package install without dependencies not yet supported.")
|
||||
|
||||
|
||||
if scope is None:
|
||||
scope = self._get_default_scope()
|
||||
|
||||
if os.path.isfile(package):
|
||||
self._install_from_file(package, scope, upgrade)
|
||||
else:
|
||||
self._install_from_pypi(package, upgrade, version, install_dependencies, scope)
|
||||
|
||||
def uninstall(self, package_name: str, scope: Scope = Scope.private_scope()):
|
||||
def uninstall(self, package_name: str, scope: Scope = None):
|
||||
"""Remove Python package from a SQL Server Python environment.
|
||||
|
||||
:param package_name: Package name to remove on the SQL Server.
|
||||
|
@ -78,6 +81,10 @@ class SQLPackageManager:
|
|||
db_owner role, you can also specify scope as public. This will uninstall packages from a public path for all
|
||||
users. Note: if you connect as dbo, you can only uninstall packages from the public path.
|
||||
"""
|
||||
|
||||
if scope is None:
|
||||
scope = self._get_default_scope()
|
||||
|
||||
print("Uninstalling " + package_name + " only, not dependencies")
|
||||
self._drop_sql_package(package_name, scope)
|
||||
|
||||
|
@ -88,7 +95,12 @@ class SQLPackageManager:
|
|||
"""
|
||||
return self._pyexecutor.execute_function_in_sql(servermethods.show_installed_packages)
|
||||
|
||||
def get_packages_by_user(self, owner='', scope: Scope =Scope.private_scope()):
|
||||
def _get_default_scope(self):
|
||||
query = "SELECT IS_SRVROLEMEMBER ('sysadmin') as is_sysadmin"
|
||||
is_sysadmin = self._pyexecutor.execute_sql_query(query)["is_sysadmin"].iloc[0]
|
||||
return Scope.public_scope() if is_sysadmin == 1 else Scope.private_scope()
|
||||
|
||||
def _get_packages_by_user(self, owner='', scope: Scope=Scope.private_scope()):
|
||||
has_user = (owner != '')
|
||||
|
||||
query = "DECLARE @principalId INT; \
|
||||
|
|
Загрузка…
Ссылка в новой задаче