root/pynxt/setup.py

Revision 154:54bdd956720c, 1.8 kB (checked in by David Anderson <dave@…>, 16 months ago)

Add a script rule to pynxt's setup.py, to deploy the script stubs.

Line 
1# This is the distutils setup script for pynxt.
2
3DESCRIPTION = """
4PyNXT is a Python module that enables developers to communicate with
5Lego Mindstorms NXT bricks at a low level. It currently facilitates
6scanning the USB chain for a NXT brick and implements the SAM-BA
7bootloader communication protocol. It comes with two utilities, fwflash
8and fwexec, which can be used to write a firmware to either flash memory
9or RAM, and execute it from there.""".strip()
10
11METADATA = {
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
22from os.path import isfile
23from distutils.core import setup
24from distutils.command.install_data import install_data
25from distutils.command.sdist import sdist
26
27# Data installer that installs data in the package directory. Inspired
28# by pygame's setup.py.
29class 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
35class 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
41cmdclass = {
42    'install_data': package_data_installer,
43    'sdist': file_checking_sdist,
44    }
45
46PACKAGEDATA = {
47    "cmdclass": cmdclass,
48    "packages": ["nxt", "nxt.bin"],
49    "data_files": [["nxt", ["flash_driver.bin"]]],
50    "scripts": ['fwflash', 'fwexec'],
51    }
52
53PACKAGEDATA.update(METADATA)
54setup(**PACKAGEDATA)
Note: See TracBrowser for help on using the browser.