-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pjob/poc/pyapp binary with plugins #2035
base: pjob/SNOW-1747473-enable-disable-plugin-commands
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pip install -U hatch | ||
hatch clean | ||
hatch build | ||
pip install git+https://github.com/hobbsd/[email protected] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
build-binary |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -188,3 +188,6 @@ markers = [ | |
|
||
[tool.codespell] | ||
skip = 'tests/*,snow.spec' | ||
|
||
[tool.hatch.build.targets.binary] | ||
python-version = "3.11" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I use python 3.11 but we had issues with pyinstaller binaries when using python 3.11 - we should check it. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,4 @@ | |
|
||
from __future__ import annotations | ||
|
||
VERSION = "3.4.0.dev0" | ||
VERSION = "3.4.0.dev8" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have issues with caching of my builds, that's why I bump version in my PoC. This should be resolved. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,10 +12,13 @@ | |
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import sys | ||
from dataclasses import dataclass | ||
|
||
from snowflake.cli.api.plugins.command import CommandSpec | ||
|
||
sys.path.append("/tmp/cli_plugins/lib/python3.11/site-packages") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should consider if we can do it better. For sure we need to load plugins from configurable directory. |
||
|
||
|
||
@dataclass | ||
class LoadedCommandPlugin: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,8 @@ | |
from __future__ import annotations | ||
|
||
import logging | ||
import subprocess | ||
import sys | ||
|
||
import typer | ||
from snowflake.cli.api.commands.snow_typer import SnowTyperFactory | ||
|
@@ -26,10 +28,35 @@ | |
app = SnowTyperFactory( | ||
name="plugin", | ||
help="Plugin management commands.", | ||
is_hidden=lambda: True, | ||
) | ||
|
||
|
||
@app.command(name="install", requires_connection=False) | ||
def install( | ||
package: str = typer.Argument( | ||
None, help="Pip compatible package (PyPI name / URL / local path)" | ||
), | ||
**options, | ||
) -> CommandResult: | ||
"""Installs a plugin from a package""" | ||
target_dir: str = ( | ||
"/tmp/cli_plugins" # TODO make it configurable in config.toml with some default | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be configurable. |
||
) | ||
subprocess.check_call( | ||
[ | ||
sys.executable, | ||
"-m", | ||
"pip", | ||
"install", | ||
"--prefix", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
target_dir, | ||
"--upgrade", | ||
package, | ||
] | ||
) | ||
return MessageResult(f"Plugin successfully installed.") | ||
|
||
|
||
@app.command(name="enable", requires_connection=False) | ||
def enable( | ||
plugin_name: str = typer.Argument(None, help="Plugin name"), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scripts
directory.