Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add Python package with UV using environment variable

Tags:

python

pip

uv

I want to install the streamlink Python package to my corporate environment. For licencing issue, it needs to be:

  • Built with --no-binary option for streamlink package.
  • Built using STREAMLINK_USE_PYCOUNTRY=1 environment variable so that it doesn't include GPL dependencies.

With our current workflow using pip, this is done the following: STREAMLINK_USE_PYCOUNTRY=1 pip install streamlink==1.3.1 --no-binary streamlink. Now we are migrating to uv and need to build an iso environment.

What I tried to do:

  • STREAMLINK_USE_PYCOUNTRY=1 uv add --group streamlink streamlink==1.3.1 --no-binary-package streamlink
  • STREAMLINK_USE_PYCOUNTRY=1 uv pip install streamlink==1.3.1 --no-binary streamlink

The --no-binary part is fine, but it just keeps ignoring the environment variable. It adds iso-639 and iso3166 dependencies that we can't ship, instead of pycountry as expected.

I checked UV documentation, and environment variables seem to be provided only to uv run command using --env-file, but I found nothing that I could use for adding a package.

like image 506
Zul Avatar asked Oct 24 '25 03:10

Zul


1 Answers

For this setting the extra-build-variable setting in the pyproject.toml should work.

[tool.uv]
extra-build-variables = { streamlink = { STREAMLINK_USE_PYCOUNTRY = "1" } }

This will ensure that the environment variable is injected into the isolated build environment used by uv for building Streamlink.

like image 186
Hericks Avatar answered Oct 27 '25 00:10

Hericks