Skip to content

Commit 9d7c5e6

Browse files
author
Thomas Preston
committed
added setup file
1 parent 2e5d8a8 commit 9d7c5e6

2 files changed

Lines changed: 35 additions & 19 deletions

File tree

‎README.md‎

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,21 @@ You'll need to have lirc configured. There are some [decent instructions here](h
1717

1818
Building & Installing
1919
=====================
20-
Generate the C code:
20+
Generate the C code and then install using setup.py:
2121

2222
$ cython -3 -a lirc.pyx
23+
$ sudo python3 setup.py install
2324

24-
Compile and link:
25-
26-
$ gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -I/usr/include/lirc/ -fPIC -I/usr/include/python3.2 -c lirc.c -o lirc.o
27-
$ gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -L/usr/lib/ -L/usr/lib/ -I/usr/include/lirc/ lirc.o -llirc_client -o lirc.so
28-
29-
lirc.so is the extension. I'll get a Makefile up soon.
30-
31-
32-
Examples
33-
========
25+
Configuration
26+
=============
3427
You need a configuration file in the lirc format. I've included an example one.
3528

3629
$ cat example_config
3730
begin
3831
remote = *
3932
button = 1 # what button is pressed on the remote
4033
prog = python-lirc # program tag to handle this command
41-
config = one # string given
34+
config = one, horse # string given
4235
end
4336

4437
begin
@@ -55,16 +48,16 @@ You need a configuration file in the lirc format. I've included an example one.
5548
config = three
5649
end
5750

58-
Here is how you set it up:
51+
Example
52+
=======
53+
Setup:
5954

6055
$ python3
6156
>>> import lirc
62-
>>> lirc.init("python-lirc") # this is the program tag (returns socket #)
63-
3
57+
>>> sockid = lirc.init("python-lirc") # arg is program tag
6458
>>> lirc.load_config_file("./example_config")
6559

66-
`lirc.nextcode()` will block and return a list of the strings given in the config.
60+
Getting the codes:
6761

68-
>>> lirc.nextcode()
69-
# press 1 on remote
70-
['one']
62+
>>> lirc.nextcode() # press 1 on remote after this
63+
['one', 'horse']

‎setup.py‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
from distutils.core import setup, Extension
5+
6+
DISTUTILS_DEBUG=True
7+
8+
lirc_ext = Extension('lirc',
9+
include_dirs = ['/usr/include/lirc/'],
10+
libraries = ['lirc_client'],
11+
library_dirs = ['/usr/lib'],
12+
sources = ['lirc.c']
13+
)
14+
15+
setup(name='python-lirc',
16+
version='1.0',
17+
description='Python bindings for LIRC.',
18+
author='Thomas Preston',
19+
author_email='thomasmarkpreston@gmail.com',
20+
license='GPLv3+',
21+
url='https://github.com/tompreston/python-lirc',
22+
ext_modules=[lirc_ext],
23+
)

0 commit comments

Comments
 (0)