1818load ("//python/private:normalize_name.bzl" , "normalize_name" )
1919load (":parse_whl_name.bzl" , "parse_whl_name" )
2020
21- def whl_repo_name (filename , sha256 ):
21+ def whl_repo_name (filename , sha256 , extras ):
2222 """Return a valid whl_library repo name given a distribution filename.
2323
2424 Args:
2525 filename: {type}`str` the filename of the distribution.
2626 sha256: {type}`str` the sha256 of the distribution.
27+ extras: {type}`list[str]` the extras for the requirement. TODO(hartikainen): Note sure if this is the right place for extras.
2728
2829 Returns:
2930 a string that can be used in {obj}`whl_library`.
@@ -34,6 +35,7 @@ def whl_repo_name(filename, sha256):
3435 # Then the filename is basically foo-3.2.1.<ext>
3536 name , _ , tail = filename .rpartition ("-" )
3637 parts .append (normalize_name (name ))
38+ parts .extend (sorted (extras ))
3739 if sha256 :
3840 parts .append ("sdist" )
3941 version = ""
@@ -53,6 +55,7 @@ def whl_repo_name(filename, sha256):
5355 parts .append (python_tag )
5456 parts .append (abi_tag )
5557 parts .append (platform_tag )
58+ parts .extend (sorted (extras ))
5659
5760 if sha256 :
5861 parts .append (sha256 [:8 ])
@@ -61,19 +64,24 @@ def whl_repo_name(filename, sha256):
6164
6265 return "_" .join (parts )
6366
64- def pypi_repo_name (whl_name , * target_platforms ):
67+ def pypi_repo_name (whl_name , extras , * target_platforms ):
6568 """Return a valid whl_library given a requirement line.
6669
70+ TODO(hartikainen): Note sure if this is the right place for extras.
71+
6772 Args:
6873 whl_name: {type}`str` the whl_name to use.
74+ extras: {type}`list[str]` the extras for the requirement. TODO(hartikainen): Note sure if this is the right place for extras.
6975 *target_platforms: {type}`list[str]` the target platforms to use in the name.
7076
77+
7178 Returns:
7279 {type}`str` that can be used in {obj}`whl_library`.
7380 """
7481 parts = [
7582 normalize_name (whl_name ),
7683 ]
84+ parts .extend (sorted (extras ))
7785 parts .extend ([p .partition ("_" )[- 1 ] for p in target_platforms ])
7886
7987 return "_" .join (parts )
0 commit comments