Skip to main content

Python bindings for the crate twmap

Project description

TwMap Python Module

Safely parse, edit and save Teeworlds and DDNet maps - in Python!

See the Rust library twmap for details on the wrapped library.

Installation

Simply do pip install twmap!

Usage

The help function is your friend! Once you imported twmap, do help(twmap.Map) to access the documentation of the Map struct. It also contains important general knowledge about the module.

To load your first map, do map = twmap.Map(path-to-map). To see the attributes and documentation about an object... help helps you!

For example, have a look into help(map.groups) and help(map.groups[0]). The first one will give you methods on the group collection and the second one attributes and methods on group objects. If you are confused about something in the module, the general information in help(twmap.Map) might help you.

Manual Building (on Linux)

You need Rust installed on your system. To compile twmap in release mode, execute the following command in the source root:

cargo build --release

Locate the file target/release/libtwmap.so. This file is only importable under twmap.so. Symlink or copy it to your desired location.

Publishing Steps

These steps are the ones I use to upload new versions of twmap-py to pypi.

Linux:

  1. docker pull ghcr.io/pyo3/maturin
  2. docker run --rm -itv $(pwd):/io --entrypoint /bin/bash ghcr.io/pyo3/maturin
  3. maturin list-python to list the available interpreter versions
  4. Enter pypi credentials into the environment variables MATURIN_USERNAME and MATURIN_PASSWORD
  5. maturin publish --interpreter <interpreter-version> for each interpreter version

Cross-compiling to Windows:

  1. Cargo.toml: switch the pyo3 dependency line
  2. Download the latest Python 3.7 "Windows x86-64 embeddable zip file" from https://www.python.org/downloads/windows/. Last used: https://www.python.org/ftp/python/3.7.9/python-3.7.9-embed-amd64.zip
  3. Unzip in project root
  4. RUSTFLAGS='-C target-feature=+crt-static' PYO3_CROSS_LIB_DIR='./python-3.7.9-embed-amd64' maturin publish --target x86_64-pc-windows-gnu (replace the dir path if another version is used)
  5. Enter pypi credentials interactively

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

twmap-0.4.2-cp37-abi3-win_amd64.whl (4.9 MB view details)

Uploaded CPython 3.7+Windows x86-64

File details

Details for the file twmap-0.4.2-cp37-abi3-win_amd64.whl.

File metadata

  • Download URL: twmap-0.4.2-cp37-abi3-win_amd64.whl
  • Upload date:
  • Size: 4.9 MB
  • Tags: CPython 3.7+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.13.6

File hashes

Hashes for twmap-0.4.2-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 45886f41c7c7ea8835f80dac85312e2f689dd79d986053fd29520dfbdf33af4e
MD5 a4b830bfef872452147702d2d9c516ab
BLAKE2b-256 3982ce61b037b7bce097ba67b66e1eb59cb6f4d629ccc99224b4c8e90d3cd6a4

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