Managing Python Dependencies

作者 gemini-cli-extensions2df10e25bbf7Apache-2.0215 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫今天更新

Ensures proper Python dependency management, avoiding global `pip install` and adhering to project-specific tooling. Use this skill if any of the following are true: 1. Attempting to run `pip install {package_name}`. 2. Python packages or dependencies need to be added or modified. 3. Initiating a new Python project. 4. Creating a new notebook, even if just using BigQuery cells. 5. Generating Python code that includes `import` statements for third-party libraries. 6. Before executing Python scripts via the terminal to ensure the correct virtual environment is active.

AI 產生的概覽

指導代理偵測 Python 專案的相依性管理器並正確安裝套件,而不是使用全域 pip。

功能
此技能提供管理 Python 相依性的規則。它要求代理檢查工作區中的鎖定檔與設定檔,選擇相符的工具(uv、Poetry、Pipenv、Conda 或 venv 加 pip),並使用該工具的安裝與初始化指令。它也定義了預設的 venv 加 pip 工作流程,並列出禁止的操作,例如全域 pip 安裝。
適用情境
在新增或修改 Python 套件、啟動新的 Python 專案、建立筆記本、產生含第三方匯入的 Python 程式碼,或從終端機執行 Python 指令碼時使用。其目的是讓安裝方式與專案現有工具保持一致。
執行需求
不隨附指令碼,僅為說明性指示。它假定有具備 Python 的 shell 環境,以及專案所用的相依性管理器,安裝套件時可能需要網路存取。

Python Dependency Management Rule

[!CAUTION]

BEFORE any pip install: You MUST first detect the project's existing dependency manager and use it correctly. Do NOT override the project's established tooling.

[!NOTE]

Pre-Flight Environment Check Bundling: You MUST NOT run multiple sequential 1-line shell check commands (e.g. separate commands for python version, pyspark version, auth check, pip list). Combine all pre-flight environment and package availability probes into a single composite python one-liner or shell check step.

Example composite probe:

bash
python3 -c "import sys, importlib.util; print(f'Python {sys.version.split()[0]}'); [(print(f'{pkg}: {__import__(pkg).__version__}') if importlib.util.find_spec(pkg) else print(f'{pkg}: not found')) for pkg in ['pyspark', 'google.cloud.bigquery']]"

This bundling also applies to dependency manager detection; use a single ls or find command to check for all potential dependency manager configuration and lock files at once (e.g. ls uv.lock poetry.lock Pipfile.lock requirements.txt pyproject.toml).

Dependency Manager Detection

Before installing ANY Python package, check the workspace for these files in priority order:

  1. Signal: uv.lock or pyproject.toml with [tool.uv]
    • Tool: uv
    • Install: uv add <package>
    • Setup: uv sync
  2. Signal: pyproject.toml with [tool.poetry]
    • Tool: Poetry
    • Install: poetry add <package>
    • Setup: poetry install
  3. Signal: Pipfile
    • Tool: Pipenv
    • Install: pipenv install <package>
    • Setup: pipenv install
  4. Signal: environment.yml
    • Tool: Conda
    • Install: conda install <package>
    • Setup: conda env create -f environment.yml
  5. Signal: requirements.txt only
    • Tool: venv + pip
    • Install: .venv/bin/pip install <package>
    • Setup: .venv/bin/pip install -r requirements.txt
  6. Signal: None of the above
    • Tool: venv + pip (default)
    • Install: .venv/bin/pip install <package>
    • Setup: .venv/bin/pip install -r requirements.txt

Default: venv + pip

If no dependency manager is detected, use venv + pip + requirements.txt as the default:

bash
# Initialize environmentpython3 -m venv .venv
# Add dependencies.venv/bin/pip install <package>
# Preserve state.venv/bin/pip freeze > requirements.txt

Rules for venv + pip workflow:

  • Always use .venv/bin/pip or .venv/bin/python (explicit path).
  • After installing, run: .venv/bin/pip freeze > requirements.txt.
  • When setting up: .venv/bin/pip install -r requirements.txt.

Prohibited

  • NEVER run pip install globally
  • NEVER override an existing dependency manager with a different one

來源與署名

來源:gemini-cli-extensions/data-agent-kit-starter-pack位於skills/managing-python-dependencies提交2df10e2

授權條款: Apache-2.0

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架

更多來自 gemini-cli-extensions/data-agent-kit-starter-pack 的技能

Schema Mapping

gemini-cli-extensions

為 ETL、ELT 或資料整合任務規劃來源到目標的結構描述對應,產出文件化的對應宣言。

Data & Analytics215今天更新

Resolving Mcp Region Configs

gemini-cli-extensions

修復區域性 Google Cloud MCP 伺服器設定中未取代的區域佔位符,讓缺少的 MCP 工具得以註冊。

DevOps & Cloud215今天更新

Notebook Guidance

gemini-cli-extensions

This skill guides the use of Jupyter notebooks for data analysis, exploration, and visualization, particularly with BigQuery. It outlines best practices for notebook execution and validation (supporting both cell-by-cell execution and full notebook generation depending on tool availability), library installation, and structuring notebooks for clarity. It also covers specific rules for data cleaning, plotting, and integrating with BigQuery SQL and machine learning workflows. Relevant when any of the following conditions are true: 1. The user request involves a data analysis, data exploration, data visualization, or data insights task that requires multiple steps, queries, or visualizations to answer. 2. The user explicitly requests a notebook (.ipynb). 3. You are creating, editing, or executing cells in a Jupyter notebook. 4. You need to query BigQuery from within a notebook. DO NOT use the Python BigQuery client library; instead, you MUST use the `%%bqsql` magics explained in this skill.

待分類215今天更新

Ml Best Practices

gemini-cli-extensions

為機器學習筆記本提供逐步方案,涵蓋分群、預測、分類、迴歸與模型比較。

Data & Analytics215今天更新

Google Cloud Storage Fuse

gemini-cli-extensions

Mounts Cloud Storage buckets as a POSIX file system with Cloud Storage FUSE (gcsfuse). Use when you need to interact with gcsfuse — decide whether FUSE, native gs:// reads, or Filestore/Managed Lustre fits a workload, deploy tuned mounts on GKE, Compute Engine, or Cloud Run, enable and size the file, stat, and list caches, tune mount flags or config-file settings, apply workload profiles, keep ML checkpointing safe (rename atomicity, hierarchical namespace, close-time finalization, concurrent writers), or diagnose slow training, low throughput, or GCS bill spikes on existing mounts with gcsfuse metrics. Covers mount semantics, the gcsfuse CLI and config file, the GKE gcsfuse CSI driver (Workload Identity principal:// bindings, profile StorageClasses, sidecar sizing), and Cloud Run volume mounts. Don't use for bucket administration or data management without a mount (google-cloud-storage-basics) or for fully POSIX-compliant shared file systems (Filestore, Managed Lustre).

待分類215今天更新

Google Cloud Auth Verification

gemini-cli-extensions

Mandatory Step 0 pre-flight execution order and authentication verification for Google Cloud Platform (GCP), Application Default Credentials (ADC), gcloud CLI, Spark, Dataproc, BigQuery, GCS, and notebook runtimes. Use whenever interacting with GCP resources, running Spark/PySpark pipelines, BigQuery queries, GCS paths (gs://), or creating/running notebooks.

待分類215今天更新