Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 16th, 2012, 09:26 PM
pythonNewb57 pythonNewb57 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 1 pythonNewb57 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 26 sec
Reputation Power: 0
Learning to compile a C extension (linux/newb)

I want to learn how to play with this code package because I ultimately want to compile it for Python 3.x

GIT: github.com/engla/keybinder
tarball: kaizer.se/publicfiles/keybinder/keybinder-3.0-0.3.0.tar.gz
homepage: kaizer.se/wiki/keybinder/

But I am super confused as to how the Python part of the compilation works. I've been trying for about 2 straight days now (minus sleep) attempting to figure it out. But so many files get generated by various tools like autoconfig. The Python specific files seems to be located here hgithub.com/engla/keybinder/tree/master/python-keybinder but some of those files don't even look like C or Python. It seems like when you run the configure script for the entire package there is a file named _keybinder.c which gets generated, and I think that is the file that ultimately gets compiled, and I have tried creating my own setup.py file for it but I must be missing certain library links.

I wish I knew how to take the data which is there, create my own keybinder.c file and my own setup.py script so that I can modify and re-compile specifically the Python/C extension. But at this point, I have no idea how what is in this package becomes a .so file in /usr/local/lib/python2.7/dist-packages/ that I can and have successfully experimented with.

The closest I have gotten I think think is this C file: pastebin.com/raw.php?i=CuqhsSHK
and this setup.py file: pastebin.com/raw.php?i=hNtAEy8q

There is a lot here, and I don't expect that anyone will do this work for me, besides, I want to learn how anyway after all this effort, but I'd highly appreciate some direction. I feel like what I'm trying to accomplish would take some one in the know 2 minutes not two days but I'm sitting here randomly trying stuff hoping that it will work.

Thank You.

Reply With Quote
  #2  
Old December 17th, 2012, 09:34 AM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,393 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 15 h 37 m 10 sec
Reputation Power: 383
I tried to build the package following the README instruction and found an error in the examples Makefile. The order of files presented to the loader matters, and the Makefile put main after all the libraries instead of before them. Below is corrected Makefile and use of the new program main. Please report the change back to the project. Thanks, Dave.
Code:
$ ./configure
$ make
$ sudo make install
$ cd examples/
$ make main   # this works on my system with repaired Makefile
$ LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH ./main
I then tried to run the example python program which didn't work, and I didn't investigate. Otherwise, I ignored your message.
Code:
GTKPKG = gtk+-3.0
KEYBPKG = keybinder-3.0
GTK_CFLAGS = $(shell pkg-config --cflags $(GTKPKG))
GTK_LDFLAGS = $(shell pkg-config --libs $(GTKPKG))

LUA_CFLAGS = $(shell pkg-config --cflags lua5.1)
LUA_LDFLAGS = $(shell pkg-config --libs lua5.1)

KEYB_FLAGS = $(shell pkg-config --cflags --libs $(KEYBPKG))

CFLAGS ?= -g -O2

VALAC = valac

all: main lua vala

lua: minigtk.so keybinder.so

# Example C program with libkeybinder
# Following shell command rearranged by b49p23tivg
main: main.c
	$(CC) $(CFLAGS) $< $(KEYB_FLAGS) -o $@

# Lua "minigtk" library
keybinder.so: lkeybinder.c
	$(CC) $(KEYB_FLAGS) $(CFLAGS) \
		$(LUA_CFLAGS) $(LUA_LDFLAGS) $< -shared -o $@

minigtk.so: lminigtk.c
	$(CC) $(GTK_CFLAGS) $(GTK_LDFLAGS) \
		$(LUA_CFLAGS) $(LUA_LDFLAGS) $< -shared -o $@

vala: vexample

vexample: vexample.vala keybinder.vapi
	$(VALAC) --pkg $(GTKPKG) --pkg keybinder --vapidir=. $<

clean:
	rm -f *.so *.lo main vexample

.PHONY: clean all lua vala
__________________
[code]Code tags[/code] are essential for python code!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Learning to compile a C extension (linux/newb)

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap