pythonpyproject.tomluv

How to manually set certain dependecies in local dev enviorment for UV Python dependency manager to ignore?


Currently I have the following pyproject.toml:

[project]
name = "sample_project"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"

dependencies = [
    "anytree",
    "pyvis",
    "pandas>=2",
    "numpy>=2",
    "statsmodels>=0",
    "matplotlib>=3",
    "seaborn>=0",
    "plotly>=5",
    "pyarrow>=18",
    "polars>=1",
    "scipy>=1",
    "xgboost>=2",
    "lightgbm>=4",
    "scikit-learn>=1",
    "numba>=0",
    "num2words>=0",
    "sqlalchemy>=2",
    "pygount",
]


[tool.uv]
dev-dependencies = ["ipykernel>=6", "pytest>=8", "ruff>=0", "maturin>=1"]

but I have a locally-built rust python PyO3 binding package named rusty_crates in my .venv/Lib/site-package folder that I depend on for this project.

How do I tell uv to ignore this "dependency" so that everytime I run uv sync the package is not uninstalled by uv


Solution

  • Two possibilities:

    1. Add the package as a path dependency (you should probably have it outside of your .venv folder for this, as uv will install it there for you). This is the proper way.
    2. Use uv sync --inexact, from the documentation:

    --inexact

    Do not remove extraneous packages present in the environment.

    When enabled, uv will make the minimum necessary changes to satisfy the requirements. By default, syncing will remove any extraneous packages from the environment