Skip to content

Commit

Permalink
chore: Fix build for ra2yrproto submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
shmocz committed Dec 22, 2023
1 parent d2f8452 commit e05b2c3
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 90 deletions.
13 changes: 2 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,8 @@ services:
- .:/home/user/project
command: |
sh -c '
if [ ! -d .venv ]; then
python3 -m venv .venv
. .venv/bin/activate
python3 -m pip install -r requirements.txt -e .
else
set -e
. .venv/bin/activate
set +e
python3 -m pip install -r requirements.txt -e .
fi
${COMMAND_PYRA2YR}'
poetry install --only main,dev
poetry run ${COMMAND_PYRA2YR}'
stop_signal: SIGKILL
working_dir: /home/user/project/pyra2yr
tty: true
Expand Down
1 change: 1 addition & 0 deletions docker/pyra2yr.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ RUN apt-get update && \
python3 \
python3-pip \
python3-venv \
python3-poetry \
&& apt-get clean -y && \
rm -rf /var/lib/apt/lists/*
6 changes: 2 additions & 4 deletions pyra2yr/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# pyra2yr

Python interface for ra2yrcpp. Includes a websocket proxy and client capable of communicating with ra2yrcpp using the main protobuf specification. This package is directly bundled to ra2yrcpp with the intention to use exact same protobuf definitions generated during ra2yrcpp build.
Python interface for ra2yrcpp. Includes a websocket proxy and client capable of communicating with ra2yrcpp using the main protobuf specification.

## Setup

In a suitable Python environment, invoke:

```bash
$ python3 -m pip install -r requirements.txt .
poetry install
```

## Usage
Expand Down
23 changes: 23 additions & 0 deletions pyra2yr/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[tool.poetry]
name = "pyra2yr"
version = "0.1.0"
description = "Python interface for ra2yrproto"
authors = ["shmocz <[email protected]>"]
license = "GPL3"
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.11"
numpy = "^1.26.2"
aiohttp = "^3.9.1"
protobuf = "^4.25.1"

[tool.poetry.group.release.dependencies]
ra2yrproto = { url = "https://github.com/shmocz/ra2yrproto/releases/download/latest/ra2yrproto-1-py3-none-any.whl" }

[tool.poetry.group.dev.dependencies]
ra2yrproto = { path = "../src/protocol/ra2yrproto/dist/ra2yrproto-1-py3-none-any.whl" }

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
6 changes: 0 additions & 6 deletions pyra2yr/ra2yrproto/__init__.py

This file was deleted.

10 changes: 0 additions & 10 deletions pyra2yr/requirements.txt

This file was deleted.

50 changes: 0 additions & 50 deletions pyra2yr/setup.py

This file was deleted.

21 changes: 12 additions & 9 deletions src/protocol/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
set(PROTO_FILES
ra2yrproto/core.proto ra2yrproto/ra2yr.proto
ra2yrproto/commands_builtin.proto ra2yrproto/commands_game.proto
ra2yrproto/commands_yr.proto ra2yrproto/game.proto)
set(BDIR "${CMAKE_CURRENT_BINARY_DIR}")
set(SDIR "${CMAKE_CURRENT_SOURCE_DIR}")
file(
GLOB PROTO_FILES
RELATIVE "${SDIR}/ra2yrproto"
"${SDIR}/ra2yrproto/ra2yrproto/*.proto")

# set protobuf file paths
set(PROTO_HDRS "")
set(PROTO_SRCS "")
set(PROTO_DEPS "")
foreach(X IN LISTS PROTO_FILES)
string(REPLACE ".proto" ".pb.h" FN_H ${X})
string(REPLACE ".proto" ".pb.cc" FN_S ${X})
list(APPEND PROTO_HDRS ${FN_H})
list(APPEND PROTO_SRCS ${FN_S})
list(APPEND PROTO_DEPS "ra2yrproto/${X}")
unset(FN_H)
unset(FN_S)
endforeach()

set(BDIR "${CMAKE_CURRENT_BINARY_DIR}")
set(SDIR "${CMAKE_CURRENT_SOURCE_DIR}")
if(NOT protobuf_SOURCE_DIR)
set(protobuf_SOURCE_DIR "${CMAKE_SOURCE_DIR}/3rdparty/protobuf")
endif()
Expand All @@ -25,10 +27,11 @@ set(PROTOBUF_SOURCES "${protobuf_SOURCE_DIR}/src")
add_custom_target(compile-protobuf ALL DEPENDS ${PROTO_SRCS} ${PROTO_HDRS})
add_custom_command(
OUTPUT ${PROTO_SRCS} ${PROTO_HDRS}
WORKING_DIRECTORY "${SDIR}/ra2yrproto"
COMMAND
${PROTOC_PATH} -I=. -I="${SDIR}" -I="${PROTOBUF_SOURCES}" --pyi_out=${BDIR}
--python_out=${BDIR} --cpp_out=${BDIR} ${PROTO_FILES}
DEPENDS ${PROTO_FILES})
${PROTOC_PATH} -I=. -I="${SDIR}/ra2yrproto" -I="${PROTOBUF_SOURCES}"
--pyi_out=${BDIR} --python_out=${BDIR} --cpp_out=${BDIR} ${PROTO_FILES}
DEPENDS ${PROTO_DEPS})

add_library(protocol_o OBJECT helpers.cpp protocol.cpp ${PROTO_SRCS}
../util_string.cpp ../errors.cpp)
Expand Down

0 comments on commit e05b2c3

Please sign in to comment.