Installing Ansible-Lint On Macos With Uv

I had a weird issue trying to move from Poetry to UV as my package manager for one of my repos. I’ve got ansible-lint in the required packages, running on MacOS, so it shouldn’t complain about will-not-work-on-windows-try-from-wsl-instead because the package isn’t required for MacOS. But uv tries to resolve for everything, so blep.

The errors:

❯ uv run ansible-lint servers.yml
  × No solution found when resolving dependencies for split (python_full_version == '3.11.*'):
  ╰─▶ Because will-not-work-on-windows-try-from-wsl-instead{platform_system == 'Windows'}==0.1.0 was yanked (reason: This package should not have anything
      published) and only will-not-work-on-windows-try-from-wsl-instead{platform_system == 'Windows'}==0.1.0 is available, we can conclude that all versions
      of will-not-work-on-windows-try-from-wsl-instead{platform_system == 'Windows'} are incompatible.
      And because ansible-lint{platform_system != 'Windows'}>=24.2.0 depends on will-not-work-on-windows-try-from-wsl-instead{platform_system == 'Windows'}
      and only the following versions of ansible-lint{platform_system != 'Windows'} are available:
          ansible-lint{platform_system != 'Windows'}<24.0.0
          ansible-lint{platform_system != 'Windows'}==24.2.0
          ansible-lint{platform_system != 'Windows'}==24.2.1
          ansible-lint{platform_system != 'Windows'}==24.2.2
          ansible-lint{platform_system != 'Windows'}==24.2.3
          ansible-lint{platform_system != 'Windows'}==24.5.0
          ansible-lint{platform_system != 'Windows'}==24.6.0
          ansible-lint{platform_system != 'Windows'}==24.6.1
          ansible-lint{platform_system != 'Windows'}==24.7.0
          ansible-lint{platform_system != 'Windows'}==24.9.0
      we can conclude that all of:
          ansible-lint{platform_system != 'Windows'}>=24.0.0,<24.2.1
          ansible-lint{platform_system != 'Windows'}>24.2.1,<24.2.2
          ansible-lint{platform_system != 'Windows'}>24.2.2,<24.2.3
          ansible-lint{platform_system != 'Windows'}>24.2.3,<24.5.0
          ansible-lint{platform_system != 'Windows'}>24.5.0,<24.6.0
          ansible-lint{platform_system != 'Windows'}>24.6.0,<24.6.1
          ansible-lint{platform_system != 'Windows'}>24.6.1,<24.7.0
          ansible-lint{platform_system != 'Windows'}>24.7.0,<24.9.0
          ansible-lint{platform_system != 'Windows'}>24.9.0
       are incompatible. (1)

I found a comment on the github issue in astral-sh/uv#6127 where someone added an “environments” specifier to let uv split across its lockfile generation.

By default, uv will resolve for all possible environments during a uv lock operation. However, you can restrict the set of supported environments to improve performance and avoid unsatisfiable branches in the solution space.

So adding this to my pyproject.toml file fixed it (because it’s not going to run in Windows):


[tool.uv]
environments = ["platform_system != 'Windows'"]


#python #uv #ansible #ansible-lint