Skip to content

Instantly share code, notes, and snippets.

@astagi
Created October 12, 2011 22:14
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save astagi/1282808 to your computer and use it in GitHub Desktop.
Save astagi/1282808 to your computer and use it in GitHub Desktop.
Just a simple experimental way to embed python in Vala
valac python.vapi pyembtest.vala -X -I. -X -I/usr/include/python2.6 -X -lpython2.6 -o pyembtest
using Python;
void main(string[] args) {
Python.Initialize();
Run.SimpleString("print 'hello from python!'"); //just an Hello World
Python.Main(args); //your args for Python
Python.Finalize();
}
/* python.vapi generated by me, modify it if you need ^^. */
[CCode (lower_case_cprefix = "Py_", cheader_filename = "Python.h")]
namespace Python
{
public void Initialize ();
public void Finalize ();
public void Main([CCode (array_length_pos = 0.1)] string[] args);
[CCode (lower_case_cprefix = "PyRun_")]
namespace Run
{
public void SimpleString (string @string);
}
}
@gavr123456789
Copy link

pyembtest.vala:6.5-6.26: error: Non-abstract, non-extern methods must have bodies
public void Initialize ();
^^^^^^^^^^^^^^^^^^^^^^
pyembtest.vala:13.9-13.32: error: Non-abstract, non-extern methods must have bodies
public void SimpleString (string @string);
^^^^^^^^^^^^^^^^^^^^^^^^
pyembtest.vala:8.5-8.20: error: Non-abstract, non-extern methods must have bodies
public void Main([CCode (array_length_pos = 0.1)] string[] args);
^^^^^^^^^^^^^^^^
pyembtest.vala:7.5-7.24: error: Non-abstract, non-extern methods must have bodies
public void Finalize ();
^^^^^^^^^^^^^^^^^^^^
Compilation failed: 4 error(s), 0 warning(s)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment