rules_python
                                
                                 rules_python copied to clipboard
                                
                                    rules_python copied to clipboard
                            
                            
                            
                        Potentially incorrect handling of platform_system constraint
🐞 bug report
Affected Rule
The issue is likely somewhere in these rules: pip_parse/install_deps/whl_library
Is this a regression?
Yes, the previous version in which this bug was not present was: 0.2.0
Description
We've used version 0.2.0 of rules_python for a while, and wanted to upgrade, but any version following that causes an exception in the analysis phase where extract_single_wheel is unable to find any .whl file.
This is the dependency generated by poetry export --output requirements_lock.txt --without-hashes:
tzdata==2022.1; platform_system == "Windows" and python_version >= "3.6" and (python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.6")
It seems like the dep is required by
- https://github.com/regebro/tzlocal/blob/master/setup.cfg
- https://github.com/pganssle/pytz-deprecation-shim/blob/master/setup.cfg
I'm not quite sure that poetry is doing the right thing as it seems like for pytz-deprecation-shim the tzdata dependency is needed for all platforms? So it could be that rules_python is correct but poetry has generated an incorrect requirements.txt, but I am not all that familiar with either so would like some confirmation on that.
🔬 Minimal Reproduction
I've set up a repo here: https://github.com/glindstedt/rules_python-issue-repro
Run bazel build //... on a Linux host with python 3.8
🔥 Exception or Error
ERROR: An error occurred during the fetch of repository 'py_deps_pypi__tzdata':
   Traceback (most recent call last):
        File "/home/glindstedt/.cache/bazel/_bazel_glindstedt/40fde5b447055e5bcaa0b42ce5b706b4/external/rules_python/python/pip_install/pip_repository.bzl", line 246, column 13, in _impl_whl_library
                fail("whl_library %s failed: %s (%s)" % (rctx.attr.name, result.stdout, result.stderr))
Error in fail: whl_library py_deps_pypi__tzdata failed: Ignoring tzdata: markers 'platform_system == "Windows" and python_version >= "3.6" and (python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.6")' don't match your environment
 (Traceback (most recent call last):
  File "/home/glindstedt/.pyenv/versions/3.8.13/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/glindstedt/.pyenv/versions/3.8.13/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/glindstedt/.cache/bazel/_bazel_glindstedt/40fde5b447055e5bcaa0b42ce5b706b4/external/rules_python/python/pip_install/parse_requirements_to_bzl/extract_single_wheel/__main__.py", line 4, in <module>
    main()
  File "/home/glindstedt/.cache/bazel/_bazel_glindstedt/40fde5b447055e5bcaa0b42ce5b706b4/external/rules_python/python/pip_install/parse_requirements_to_bzl/extract_single_wheel/__init__.py", line 50, in main
    whl = next(iter(glob.glob("*.whl")))
StopIteration
)
ERROR: /home/glindstedt/tmp_rules_python_test/WORKSPACE:35:13: fetching whl_library rule //external:py_deps_pypi__tzdata: Traceback (most recent call last):
        File "/home/glindstedt/.cache/bazel/_bazel_glindstedt/40fde5b447055e5bcaa0b42ce5b706b4/external/rules_python/python/pip_install/pip_repository.bzl", line 246, column 13, in _impl_whl_library
                fail("whl_library %s failed: %s (%s)" % (rctx.attr.name, result.stdout, result.stderr))
Error in fail: whl_library py_deps_pypi__tzdata failed: Ignoring tzdata: markers 'platform_system == "Windows" and python_version >= "3.6" and (python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.6")' don't match your environment
 (Traceback (most recent call last):
  File "/home/glindstedt/.pyenv/versions/3.8.13/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/glindstedt/.pyenv/versions/3.8.13/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/glindstedt/.cache/bazel/_bazel_glindstedt/40fde5b447055e5bcaa0b42ce5b706b4/external/rules_python/python/pip_install/parse_requirements_to_bzl/extract_single_wheel/__main__.py", line 4, in <module>
    main()
  File "/home/glindstedt/.cache/bazel/_bazel_glindstedt/40fde5b447055e5bcaa0b42ce5b706b4/external/rules_python/python/pip_install/parse_requirements_to_bzl/extract_single_wheel/__init__.py", line 50, in main
    whl = next(iter(glob.glob("*.whl")))
StopIteration
)
ERROR: /home/glindstedt/.cache/bazel/_bazel_glindstedt/40fde5b447055e5bcaa0b42ce5b706b4/external/py_deps_pypi__pytz_deprecation_shim/BUILD.bazel:11:11: @py_deps_pypi__pytz_deprecation_shim//:pkg depends on @py_deps_pypi__tzdata//:pkg in repository @py_deps_pypi__tzdata which failed to fetch. no such package '@py_deps_pypi__tzdata//': whl_library py_deps_pypi__tzdata failed: Ignoring tzdata: markers 'platform_system == "Windows" and python_version >= "3.6" and (python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.6")' don't match your environment
 (Traceback (most recent call last):
  File "/home/glindstedt/.pyenv/versions/3.8.13/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/glindstedt/.pyenv/versions/3.8.13/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/glindstedt/.cache/bazel/_bazel_glindstedt/40fde5b447055e5bcaa0b42ce5b706b4/external/rules_python/python/pip_install/parse_requirements_to_bzl/extract_single_wheel/__main__.py", line 4, in <module>
    main()
  File "/home/glindstedt/.cache/bazel/_bazel_glindstedt/40fde5b447055e5bcaa0b42ce5b706b4/external/rules_python/python/pip_install/parse_requirements_to_bzl/extract_single_wheel/__init__.py", line 50, in main
    whl = next(iter(glob.glob("*.whl")))
StopIteration
)
🌍 Your Environment
Operating System:
Pop_OS 22.04
Output of bazel version:
Bazelisk version: development
Build label: 5.1.1
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Fri Apr 8 15:49:48 2022 (1649432988)
Build timestamp: 1649432988
Build timestamp as int: 1649432988
Rules_python version:
>=0.3.0