diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8237fba..0b31858 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,19 +17,17 @@ jobs: include: # TODO: windows-latest - os: ubuntu-latest cache: ~/.cache/bazel - python: '3.8' - os: macos-latest cache: /private/var/tmp/_bazel_runner - python: '3.12' steps: - - name: Checkout Code + - name: Checkout code uses: actions/checkout@v3 - name: Setup Python uses: actions/setup-python@v5 with: - python-version: ${{ matrix.python }} + python-version: "3.8" - name: Setup bazelisk uses: bazelbuild/setup-bazelisk@v2 @@ -38,7 +36,6 @@ jobs: id: info run: | uname -a - python3 -V bazel info shell: bash diff --git a/python/private/poetry_parse.bzl b/python/private/poetry_parse.bzl index c4bdbc8..242cfb4 100644 --- a/python/private/poetry_parse.bzl +++ b/python/private/poetry_parse.bzl @@ -26,7 +26,7 @@ def dfs_cycles(graph): def normalize_dep_name(dep_name): return dep_name.strip().strip('"').strip("'").replace("_", "-").replace(".", "-").lower() -def parse_lock_file(data, platforms = None, generate_extras = True, system_platform_tags = None): +def parse_lock_file(data, platforms = None, generate_extras = True): _MARKERS = "markers = " _SOURCE_URL = "url = " _SOURCE_TYPE = "type = " @@ -114,7 +114,7 @@ package( name = "{name}", constraint = "{name}=={version}",{description} files = {{{files} - }},{deps}{markers}{source_urls}{extra_index_urls}{platforms}{system_platform_tags} + }},{deps}{markers}{source_urls}{extra_index_urls}{platforms} visibility = [{visibility}], ) """.format( @@ -127,7 +127,6 @@ package( source_urls = "\n source_urls = [\n{}\n ],".format("\n".join([" " + url + "," for url in source_urls])) if source_urls else "", extra_index_urls = "\n extra_index_urls = [{}],".format(", ".join(extra_index_urls)) if extra_index_urls else "", platforms = "\n platforms = {},".format(platforms) if platforms else "", - system_platform_tags = "\n system_platform = {},".format(system_platform_tags) if system_platform_tags else "", visibility = ", ".join(['"{}"'.format(vis) for vis in visibility]), ) @@ -146,37 +145,6 @@ package( return result -def get_system_platform_tags(rctx): - # DEPRECATED: the sytem interpreter must not be used - # Return a JSON string with a dict values as described in - # https://peps.python.org/pep-0508/#environment-markers and - # https://packaging.python.org/en/latest/specifications/platform-compatibility-tags/#platform-tag - result = rctx.execute(["python3", "-c", """ -import json -import os -import platform -import sys -import sysconfig -print(json.dumps(json.dumps(dict( - os_name=os.name, - sys_platform=sys.platform, - platform_machine=platform.machine(), - platform_python_implementation=platform.python_implementation(), - platform_release=platform.release(), - platform_system=platform.system(), - platform_version=platform.version(), - python_version='.'.join(platform.python_version_tuple()[:2]), - python_full_version=platform.python_version(), - implementation_name=sys.implementation.name, - platform_tags=[sysconfig.get_platform()] - ))))"""]) - - if result.return_code == 0: - return result.stdout - - print(result.stderr) - return "{}" - def _poetry_parse_impl(rctx): interpreter = rctx.path(rctx.attr._python_host) command = "import tomllib; print('{0}', 1); print('ok'); print(tomllib.load(open('{0}', 'rb')))".format(rctx.path(rctx.attr.lock)) @@ -188,11 +156,9 @@ def _poetry_parse_impl(rctx): header = "# Autogenerated file by _poetry_parse_impl in {}".format(self) rules_repository = self.split("/", 1)[0] rules_repository = ("@@" if "~" in rules_repository else "@") + rules_repository - system_platform_tags_variable = "system_platform_tags" prefix = '''{header}\n\nload("{name}//python:poetry_deps.bzl", "package")'''.format(header = header, name = rules_repository) - system_platform_tags = """{k} = {v}""".format(k = system_platform_tags_variable, v = get_system_platform_tags(rctx)) - lock_file_content = parse_lock_file(rctx.read(rctx.attr.lock), rctx.attr.platforms, rctx.attr.generate_extras, system_platform_tags_variable) - rctx.file("BUILD", "{}\n\n{}\n\n{}".format(prefix, system_platform_tags, lock_file_content)) + lock_file_content = parse_lock_file(rctx.read(rctx.attr.lock), rctx.attr.platforms, rctx.attr.generate_extras) + rctx.file("BUILD", "{}\n\n{}".format(prefix, lock_file_content)) rctx.file("WORKSPACE") poetry_parse = repository_rule( diff --git a/python/repositories.bzl b/python/repositories.bzl index 292093c..6230ef2 100644 --- a/python/repositories.bzl +++ b/python/repositories.bzl @@ -105,6 +105,7 @@ def install_dependencies(toolchain_prefix, python_version, auth_patterns = {}, n srcs = glob(include=["**/*.py"]), data = glob(include=["**/*"], exclude=[ "bin/**/*", + "**/__pycache__/**", "**/*.py", "**/*.pyc", "**/* *",