TLDR: How many different ways can I run a Python program in Unity on an Android device?
This is for a Android app that stores a geolocation, which is to be queried later on other devices.
I know about IronPython but it is not updated for Python 3+, which is what I used to write the Python program I need to run.
More backstory: I am trying to use AWS dynamoDB which has an SDK for Unity as it's built on .net. However, specifically for query search, they have not implemented < or > or compound searches, whereas that implementation is available in Python.
The following Python script works.
import boto3
import json
import decimal
from boto3.dynamodb.conditions import Key, Attr
import sys
lat = sys.argv[1]
lon = sys.argv[2]
r = sys.argv[3]
# Helper class to convert a DynamoDB item to JSON.
class DecimalEncoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, decimal.Decimal):
if o % 1 > 0:
return float(o)
else:
return int(o)
return super(DecimalEncoder, self).default(o)
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('tree')
fe = Key('lon').between((decimal.Decimal(lat) - decimal.Decimal(r)), (decimal.Decimal(lat) + decimal.Decimal(r)))
#THIS IS THE BETWEEN SEARCH THAT IS NOT AVAILABLE IN UNITY
fe1 = Key('lat').between((decimal.Decimal(lon) - decimal.Decimal(r)), (decimal.Decimal(lon) + decimal.Decimal(r)))
pe = "#l, lon, treeStage"
# Expression Attribute Names for Projection Expression only.
ean = { "#l": "lat", }
esk = None
response = table.scan(
FilterExpression=fe,
ProjectionExpression=pe,
ExpressionAttributeNames=ean
)
for i in response['Items']:
print(json.dumps(i, cls=DecimalEncoder))
while 'LastEvaluatedKey' in response:
response = table.scan(
ProjectionExpression=pe,
FilterExpression=fe and fe1, #THIS IS THE COMPOUND SEARCH THAT DOESNT WORK IN UNITY
ExpressionAttributeNames= ean,
ExclusiveStartKey=response['LastEvaluatedKey']
)
for i in response['Items']:
print(json.dumps(i, cls=DecimalEncoder))
My question is: what available options do I have to build this Python program into a file type that could be run on an Android device through Unity's C#?
Currently I'm just printing the info received from dynamoDB, but I would be open to reading it directly or writing to a file to read in Unity if necessary.