Skip to main content

Make your mods immortal.

Project description

grug for Python

This repository provides Python bindings, a frontend, and a backend for grug.

Install this package using pip install grug-lang, and run python -c "import grug" to check it.

A minimal example program is provided in the example/ directory on GitHub:

import grug
import time

state = grug.init()

@state.game_fn
def print_string(string: str):
    print(string)

file = state.compile_grug_file("animals/labrador-Dog.grug")
dog1 = file.create_entity()
dog2 = file.create_entity()

while True:
    state.update()
    dog1.on_bark("woof")
    dog2.on_bark("arf")
    time.sleep(1)
on_bark(sound: string) {
    print_string(sound)

    # Print "arf" a second time
    if sound == "arf" {
        print_string(sound)
    }
}

Run it by cloning the repository, cd-ing into it, running cd example, and finally running python example.py.

Dependencies

This project requires Python version 3.7 or newer. You can manage your Python versions using pyenv.

If you want to run the tests, you'll need to install pytest:

pip install pytest
pip install -e .

If you are on a Python version older than 3.11, you will additionally need to install these:

pip install tomli importlib-metadata

Running the tests

You will need to clone the grug-tests repository next to this repository, and then run git checkout development in it, followed by ./tests.sh.

In this grug-for-python repository, you can then run all tests using this command:

pytest --grug-tests-path=../grug-tests -s

You can additionally pass --whitelisted-test=f32_too_big if you only want to run the test called f32_too_big.

Alternatively, you can walk through the tests and set breakpoints by installing the Python Debugger VS Code extension. Hit F5 to run all tests. You can edit .vscode/launch.json if you want to pass --whitelisted-test=f32_too_big.

Type checking

Run pyright in the terminal to type check the Python code. Pyright can be installed using sudo npm install -g pyright.

Updating the pypi package

python -m pip install --upgrade pip
python -m pip install --upgrade build
python -m build
python -m pip install --upgrade twine
python -m twine upload dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

grug_lang-1.0.4.tar.gz (25.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

grug_lang-1.0.4-py3-none-any.whl (24.3 kB view details)

Uploaded Python 3

File details

Details for the file grug_lang-1.0.4.tar.gz.

File metadata

  • Download URL: grug_lang-1.0.4.tar.gz
  • Upload date:
  • Size: 25.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for grug_lang-1.0.4.tar.gz
Algorithm Hash digest
SHA256 81b77ef66a24e140ad8537f5b579f31ff5aa68eebfb5f81d8ffa8de4d1c55b02
MD5 2f80be1724d569445c6f7c4c13050450
BLAKE2b-256 d36c40d61bc14260358678d6a4026c7076e98c1f21b3167474b5a3c238bd6cbb

See more details on using hashes here.

File details

Details for the file grug_lang-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: grug_lang-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 24.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for grug_lang-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 39e59d837518ce23fd0bf4084ae0ca1c3935313a441d52a90bfad72e301bab60
MD5 0d9eb5323700c3e6828389d32bfb6987
BLAKE2b-256 d3c0b4cccfaf86c72b9e1b7bc59322f6706d1377da51d9cf90be722b672e101a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page