Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Use Portage in programming
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
Ephracis
n00b
n00b


Joined: 11 Aug 2005
Posts: 18
Location: Sweden

PostPosted: Sun Sep 10, 2006 11:32 am    Post subject: Use Portage in programming Reply with quote

Is there a way I can access portage from either C/C++ or Ruby? Call a sync, install a package or anything like that?
_________________
"There is more than one way to do it"
Back to top
View user's profile Send private message
Sohail
Tux's lil' helper
Tux's lil' helper


Joined: 14 May 2005
Posts: 118
Location: Pakistan.

PostPosted: Sun Sep 10, 2006 11:53 am    Post subject: Reply with quote

Hey, yes in C/C++ you have system() , its prototype is in stdlib.h. Do man system to find out more about it.
Back to top
View user's profile Send private message
Ephracis
n00b
n00b


Joined: 11 Aug 2005
Posts: 18
Location: Sweden

PostPosted: Sun Sep 10, 2006 11:59 am    Post subject: Reply with quote

Sohail wrote:
Hey, yes in C/C++ you have system() , its prototype is in stdlib.h. Do man system to find out more about it.


Yeah but system() isn't a very nice interface. I was looking for an API or something.
_________________
"There is more than one way to do it"
Back to top
View user's profile Send private message
Maedhros
Bodhisattva
Bodhisattva


Joined: 14 Apr 2004
Posts: 5511
Location: Durham, UK

PostPosted: Sun Sep 10, 2006 12:02 pm    Post subject: Reply with quote

You could probably do it by embedding a python interpreter in your program - e.g. http://docs.python.org/ext/embedding.html.
_________________
No-one's more important than the earthworm.
Back to top
View user's profile Send private message
Ephracis
n00b
n00b


Joined: 11 Aug 2005
Posts: 18
Location: Sweden

PostPosted: Sun Sep 10, 2006 1:00 pm    Post subject: Reply with quote

Ok, so embedding seems to be the right way to go. But is there any documentation on how to work with portage from within python?
_________________
"There is more than one way to do it"
Back to top
View user's profile Send private message
mark_alec
Bodhisattva
Bodhisattva


Joined: 11 Sep 2004
Posts: 6066
Location: Melbourne, Australia

PostPosted: Sun Sep 10, 2006 1:09 pm    Post subject: Reply with quote

Ephracis wrote:
But is there any documentation on how to work with portage from within python?
Code:
$ python
>>> import portage
>>> help(portage)

_________________
www.gentoo.org.au || #gentoo-au
Back to top
View user's profile Send private message
Ephracis
n00b
n00b


Joined: 11 Aug 2005
Posts: 18
Location: Sweden

PostPosted: Sun Sep 10, 2006 1:21 pm    Post subject: Reply with quote

mark_alec wrote:
Ephracis wrote:
But is there any documentation on how to work with portage from within python?
Code:
$ python
>>> import portage
>>> help(portage)

Thank you! :D
_________________
"There is more than one way to do it"
Back to top
View user's profile Send private message
Ephracis
n00b
n00b


Joined: 11 Aug 2005
Posts: 18
Location: Sweden

PostPosted: Sun Sep 10, 2006 2:06 pm    Post subject: Reply with quote

Hm, it seems that embedding python in ruby was a bit more difficult than I expected.
I have installed the ruby-python library by Masaki Fukushima. It was made for python 1.5 but I tried to change the search-paths to 2.4 instead and it compiled fine.

Next I wrote a small ruby script with the lines:
require 'python'
require 'python/portage' but I get this:
Code:

/usr/lib/ruby/site_ruby/1.8/i686-linux/python.so: [BUG] pytm_add_module: try to add already exist module
ruby 1.8.4 (2005-12-24) [i686-linux]

but if I remove the require I can't access any python at all. Anyone knows what I'm missing and can push me in the right direction? Thanks.
_________________
"There is more than one way to do it"
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum