aboutsummaryrefslogtreecommitdiff
path: root/_build/backend.py
blob: f25546b8c25020225a29c90ae644db49c4759d71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""PEP517 build backend."""

from .grpc import build as build_pandora_grpc

from flit_core.wheel import WheelBuilder
# Use all build hooks from flit
from flit_core.buildapi import *


# Build grpc interfaces when this build backend is invoked
build_pandora_grpc()

# flit only supports copying one module, but we need to copy two of them
# because protobuf forces the use of absolute imports.
# So Monkey patches WheelBuilder#copy_module to copy pandora folder too.
# To avoid breaking this, the version of flit_core is pinned in pyproject.toml.
old_copy_module = WheelBuilder.copy_module


def copy_module(self):
    from flit_core.common import Module

    old_copy_module(self)

    module = self.module

    self.module = Module('pandora', self.directory)
    old_copy_module(self)

    self.module = module


WheelBuilder.copy_module = copy_module