Is there a pyproject standard for sources specification of packages?

It depends on what you want to accomplish exactly. Some of these are supported by standard dependency specifiers in declarative configuration; others are not (e.g. alternative indices). The specific example you provided might also be expressible as:

[project]
dependencies = [
  "httpx ; sys_platform != 'darwin'",
  "httpx @ git+https://github.com/encode/httpx@0.27.2 ; sys_platform == 'darwin'",
]

Or (not supported by pip yet):

[project]
dependencies = [
  "httpx",
]

[dependency-groups]
dev = [
  "httpx @ git+https://github.com/encode/httpx@0.27.2 ; sys_platform == 'darwin'",
]

Each will require you to make different sacrifices (in order: have users install uv; be unable to publish your package to PyPI; possibly needing to execute multiple commands).

1 Like