pythonpipuv

How to set index url for uv like pip configurations


When using pip to install Python packages, we can set the configurations so that it can refer to some private repository to install packages. The usecase is for example for big companies where for security issues, they would keep all packages in their own repo and will only trust those resources. In such cases, we can create pip.conf file in MacOS or Linux or a pip.ini file in Windows in which we can change the index url like this:

[global]
index-url=https://path/to/private/repo/simple1
extra-index-url=https://path/to/private/repo/simple2

I would need to do the same things while using uv as my package manager. How can I do that?


Solution

  • After checking the uv documentations I found out that I can use [[tool.uv.index]] section in my pyproject.toml file like this:

    [[tool.uv.index]] 
    url = "https://path/to/private/repo/simple1" 
    default = true
    

    If we need more urls we can just add more of that section:

    [[tool.uv.index]]
    url = "https://path/to/second/private/repo/simple"