| 1 | # This is the distutils setup script for pynxt. |
|---|
| 2 | |
|---|
| 3 | DESCRIPTION = """ |
|---|
| 4 | PyNXT is a Python module that enables developers to communicate with |
|---|
| 5 | Lego Mindstorms NXT bricks at a low level. It currently facilitates |
|---|
| 6 | scanning the USB chain for a NXT brick and implements the SAM-BA |
|---|
| 7 | bootloader communication protocol. It comes with two utilities, fwflash |
|---|
| 8 | and fwexec, which can be used to write a firmware to either flash memory |
|---|
| 9 | or RAM, and execute it from there.""".strip() |
|---|
| 10 | |
|---|
| 11 | METADATA = { |
|---|
| 12 | "name": "pynxt", |
|---|
| 13 | "version": "0.0.1", |
|---|
| 14 | "license": "GPL", |
|---|
| 15 | "url": "http://nxos.natulte.net", |
|---|
| 16 | "author": "David Anderson", |
|---|
| 17 | "author_email": "dave@natulte.net", |
|---|
| 18 | "description": "Lego Mindstorms NXT interface", |
|---|
| 19 | "long_description": DESCRIPTION, |
|---|
| 20 | } |
|---|
| 21 | |
|---|
| 22 | from os.path import isfile |
|---|
| 23 | from distutils.core import setup |
|---|
| 24 | from distutils.command.install_data import install_data |
|---|
| 25 | from distutils.command.sdist import sdist |
|---|
| 26 | |
|---|
| 27 | # Data installer that installs data in the package directory. Inspired |
|---|
| 28 | # by pygame's setup.py. |
|---|
| 29 | class package_data_installer(install_data): |
|---|
| 30 | def run(self): |
|---|
| 31 | install_cmd = self.get_finalized_command('install') |
|---|
| 32 | self.install_dir = getattr(install_cmd, 'install_lib') |
|---|
| 33 | return install_data.run(self) |
|---|
| 34 | |
|---|
| 35 | class file_checking_sdist(sdist): |
|---|
| 36 | def run(self): |
|---|
| 37 | if not isfile('flash_driver.bin'): |
|---|
| 38 | raise SystemExit("FATAL: Please build flash_driver.bin first!") |
|---|
| 39 | sdist.run(self) |
|---|
| 40 | |
|---|
| 41 | cmdclass = { |
|---|
| 42 | 'install_data': package_data_installer, |
|---|
| 43 | 'sdist': file_checking_sdist, |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | PACKAGEDATA = { |
|---|
| 47 | "cmdclass": cmdclass, |
|---|
| 48 | "packages": ["nxt", "nxt.bin"], |
|---|
| 49 | "data_files": [["nxt", ["flash_driver.bin"]]], |
|---|
| 50 | "scripts": ['fwflash', 'fwexec'], |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | PACKAGEDATA.update(METADATA) |
|---|
| 54 | setup(**PACKAGEDATA) |
|---|