Making headway towards a runnable state

This commit is contained in:
Reid 'arrdem' McKenzie 2021-08-21 20:02:54 -06:00
commit 4243a9355c
6 changed files with 80 additions and 32 deletions
tools/python

View file

@ -8,6 +8,10 @@ load("@rules_python//python:defs.bzl",
_py_library = "py_library",
)
load("@rules_zapp//zapp:zapp.bzl",
"zapp_binary",
)
def py_requirement(*args, **kwargs):
"""A re-export of requirement()"""
@ -146,6 +150,7 @@ py_resources = rule(
)
def py_project(name=None,
main=None,
lib_srcs=None,
lib_deps=None,
lib_data=None,
@ -184,8 +189,10 @@ def py_project(name=None,
"**/*.pyc",
])
lib_name = name if not main else "lib"
py_library(
name=name,
name=lib_name,
srcs=lib_srcs,
deps=lib_deps,
data=lib_data,
@ -198,12 +205,43 @@ def py_project(name=None,
],
)
if main:
py_binary(
name=name,
main=main,
srcs=lib_srcs,
deps=lib_deps,
data=lib_data,
imports=[
"src/python",
"src/resources",
],
visibility = [
"//visibility:public",
],
)
zapp_binary(
name=name + ".zapp",
main=main,
srcs=lib_srcs,
deps=lib_deps,
data=lib_data,
imports=[
"src/python",
"src/resources",
],
visibility = [
"//visibility:public",
],
)
for src in test_srcs:
if "test_" in src:
py_pytest(
name=src.split("/")[-1],
srcs=[src] + [f for f in test_srcs if "test_" not in f],
deps=[name] + (test_deps or []),
deps=[lib_name] + (test_deps or []),
data=test_data,
imports=[
"test/python",