473,666 Members | 2,299 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Embedding Python at the OS level - build problems

Greetings all. I'm attempting to embed a python interpreter at a very
low level in an OS I am writing. Currently I'm stuck with build issues.
Firstly, as there is no working C compiler in our OS, I must cross
compile Python. I encountered errors when building Parser/pgen; I got
around this by building it nativly and copying it. Hopefully this won't
get me later...

My current problem (and there are sure to be more ;) ) is when building
Modules/posixmodule.c. I've already done a great deal of hacking; I
manually commented the inclusion of stropts.h as it was getting it from
/usr/include which is not part of the target machine's include files.
That was probably not a good idea, but hey...

Now, I get:

/home/indigo/dev/uuu/uuu/lib/c/bin-i386/diet gcc -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I. -I./Include -DPy_BUILD_CORE -c ./Modules/posixmodule.c -o Modules/posixmodule.o
Modules/posixmodule.c: In function `posix_openpty' :
Modules/posixmodule.c:2 623: warning: implicit declaration of function `ioctl'
Modules/posixmodule.c:2 623: error: `I_PUSH' undeclared (first use in this function)
Modules/posixmodule.c:2 623: error: (Each undeclared identifier is reported only once
Modules/posixmodule.c:2 623: error: for each function it appears in.)
Modules/posixmodule.c: In function `posix_setgroup s':
Modules/posixmodule.c:4 527: error: `MAX_GROUPS' undeclared (first use in this function)

I really have a swarm of questions. Among them are:

- is there a better way to cross compile python?
- is there anything I can do about the above error?

But most importantly:

- is the posix module really required? At the moment, I'm interested in
only getting a minimal Python working, so anything that can be
disabled, should be. What things can I do to eliminate all features,
modules, and whatever that isn't required to build libpython2.3.a?

Jul 18 '05 #1
3 3811
On Tue, 25 May 2004 20:34:14 -0400, Phil Frost wrote:
Greetings all. I'm attempting to embed a python interpreter at a very
low level in an OS I am writing. Currently I'm stuck with build issues.
Firstly, as there is no working C compiler in our OS, I must cross
compile Python. I encountered errors when building Parser/pgen; I got
around this by building it nativly and copying it. Hopefully this won't
get me later...

My current problem (and there are sure to be more ;) ) is when building
Modules/posixmodule.c. I've already done a great deal of hacking; I
manually commented the inclusion of stropts.h as it was getting it from
/usr/include which is not part of the target machine's include files.
That was probably not a good idea, but hey...

Now, I get:

/home/indigo/dev/uuu/uuu/lib/c/bin-i386/diet gcc -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I. -I./Include -DPy_BUILD_CORE -c ./Modules/posixmodule.c -o Modules/posixmodule.o
Modules/posixmodule.c: In function `posix_openpty' :
Modules/posixmodule.c:2 623: warning: implicit declaration of function `ioctl'
Modules/posixmodule.c:2 623: error: `I_PUSH' undeclared (first use in this function)
Modules/posixmodule.c:2 623: error: (Each undeclared identifier is reported only once
Modules/posixmodule.c:2 623: error: for each function it appears in.)
Modules/posixmodule.c: In function `posix_setgroup s':
Modules/posixmodule.c:4 527: error: `MAX_GROUPS' undeclared (first use in this function)

I really have a swarm of questions. Among them are:

- is there a better way to cross compile python?
- is there anything I can do about the above error?

But most importantly:

- is the posix module really required? At the moment, I'm interested in
only getting a minimal Python working, so anything that can be
disabled, should be. What things can I do to eliminate all features,
modules, and whatever that isn't required to build libpython2.3.a?


interesting project. what are the benefits of integrating python into an
operating system? I could understand making kernel modules for services
that you would otherwise run as a daemon, but what is the motivation for
such low level integration of a high level interpreter?
Jul 18 '05 #2
On Wed, May 26, 2004 at 01:09:38AM +0000, Ryan Paul wrote:
On Tue, 25 May 2004 20:34:14 -0400, Phil Frost wrote:
Greetings all. I'm attempting to embed a python interpreter at a very
low level in an OS I am writing.

[snip lotts of problems]


interesting project. what are the benefits of integrating python into an
operating system? I could understand making kernel modules for services
that you would otherwise run as a daemon, but what is the motivation for
such low level integration of a high level interpreter?


Well, it's an interesting story...
The project started entirely in x86 assembly, and we got something like
modern MS-DOS done like that. We had fun playing with the hardware, and
breaking floppy drives by seeking them too far, and it was very fast,
but we looked back and realized we hadn't really written anything new,
so we started a rewrite.

We have produced tons of ideas now, and some of them we think are even
new. One side effect of this is that we are often rewriting code to fit
new ideas, which really becomes a pain in assembly, because slight
changes in function might require now eight registers, rather than the
usually availible 7, and well, now you have to rewrite the whole thing
to accommodate an additional parameter.

Of course the usual solution is "use C!", but I hate C. It's almost as
much of a pain as assembly, but it doesn't allow anything near the
freedom or the satisfaction of working directly with the hardware. It's
my belief that there are two enjoyable aspects to programming: the joy
of creation, and the satisfaction of solving a puzzle. C removes most of
the puzzle aspect because no longer must one allocate registers and
optimize. It also deemphisizes the creation aspect by requiring the
programer to manage all the tedious aspects of computing - memory
management, string manipulation, basic data structures, etc. Very little
time is spent creating something new in C.

Consequently, it was decided that a language should be assembly, and
failing that it should remain a joy to use. We considered many languages
that were not C, such as D, Ada, Ocaml, and Python, as well as dozens of
languages too academic to remain in my memory. D and Ada both fall short
of the goal of a joyful language. Ocaml was definately cool, especially
since it maintains extremely good performance. However, it's not as
accessible as Python.

Of course, I realize Python isn't exactly erm...fast. It is my belief
that this is a matter of the way python is run, and not a problem with
the language itself. Current projects such as Pyrex and Psyco
demonstrate that Python can be made faster, and I think this trend will
continue. Furthermore, in the worst case we can always write Python
modules in C, or assembly (wheee!) where speed is important, and take
comfort in knowing that the rest of our code is maintainble, allowing us
to focus on making an OS and not cursing at C.

If you are interested, our webpage is http://unununium.org/. I hear that
the page looks very professional all the time, but I must say at this
point it's mostly fluff. There really isn't much of an OS there, and
most of our ideas havn't been documented. Time and money have been in
very short supply recently, so the project has been nearly idle for
longer than I'd like to admit. However, some day...

--
Phil Frost

Jul 18 '05 #3
Quoth Phil Frost <in****@bitglue .com>:
....
| I really have a swarm of questions. Among them are:
|
| - is there a better way to cross compile python?
| - is there anything I can do about the above error?

I have never cross compiled anything, but I find it kind of
troubling to hear that the compiler was finding include files
in /usr/include. If they're missing in the target, it should
just fail to find them.

posixmodule is naturally one of the more difficult things to
build on a new platform. If your problems are no worse than
I_PUSH is missing, you are in fat city. socketmodule may also
be difficult, and if you have your own platform specific threading
API that will take some work.

| But most importantly:
|
| - is the posix module really required? At the moment, I'm interested in
| only getting a minimal Python working, so anything that can be
| disabled, should be. What things can I do to eliminate all features,
| modules, and whatever that isn't required to build libpython2.3.a?

I don't think posixmodule is strictly required, but that brings
up another can of worms. Python builds itself. You build it
with posixmodule (cf. Modules/Setup) so it can run setup.py.
This is, of course, to run on your build host. But of course
you need a to end up with different binary to run on your target
host. I shouldn't worry, I'm sure people do this all the time,
it just sounds kind of hairy to me.

I know I'm not much help, but you should be able to find some
good technical discussion of minimal Python builds in the Google
archives of comp.lang.pytho n. It has definitely been done.

Donn Cave, do**@drizzle.co m
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

47
3647
by: Michael Scarlett | last post by:
There is an amazing article by paul graham about python, and an even better discussion about it on slashdot. The reason I point this out, is the more I read both articles, the more I realised how we would be mutilating the language with that god forsaken @ decorator. I don't know about the rest of you, but I learned python and fell in love with its syntax and simplicity. Python - just works. So please GVR. Don't complicate it. Leave it as...
36
6368
by: Andrea Griffini | last post by:
I did it. I proposed python as the main language for our next CAD/CAM software because I think that it has all the potential needed for it. I'm not sure yet if the decision will get through, but something I'll need in this case is some experience-based set of rules about how to use python in this context. For example... is defining readonly attributes in classes worth the hassle ? Does duck-typing scale well in complex
1
3172
by: Craig Ringer | last post by:
Hi folks I'm a bit of a newbie here, though I've tried to appropriately research this issue before posting. I've found a lot of questions, a few answers that don't really answer quite what I'm looking for, but nothing that really solves or explains all this. I'll admit to being stumped, hence my question here. I'm also trying to make this post as clear and detailed as possible. Unfortunately, that means it's come out like a book. I...
1
2864
by: Charlie DeTar | last post by:
A pretty ugly one - embedding python in an external for a proprietary semi-legacy macintosh application, MaxMSP: I am trying to update Bill Orcutt's "nyptho" python interpreter external for MaxMSP (http://www.publicbeta.cx/max/) to actually work with the latest versions of OS X and python. Currently, the C calls made by nyptho are to the older PyMac methods, and thus they depend on the older MacPython distribution. After some simple...
6
2996
by: Qun Cao | last post by:
Hi Everyone, I am a beginner on cross language development. My problem at hand is to build a python interface for a C++ application built on top of a 3D game engine. The purpose of this python interface is providing a convenient scripting toolkit for the application. One example is that a user can write a python script like: player = Player() game.loadPlayer(player) player.moveTo(location)
0
2137
by: Kenneth McDonald | last post by:
Sorry for crossposting to several lists, but from what I can tell, what I want to do may involve several different areas of expertise. (None of which I have :-( ) I'd like to use Gecko as the UI for an application mostly implemented in Python. Ideally, I'd like to somehow come up with a Python module that wraps the Gecko, so that I can: 1) Create windows whose content is drawn by Gecko. 1) Dynamically manipulate what is shown by Gecko.
6
465
by: mistabean | last post by:
Hello, first of all, I am a programming newbie, especially in python... Onwards to the problem, I have been having difficulty embedding a python module into my C/C++ program. (just a test program before moving on into the real thing). I have been making test runs using the codes from http://docs.python.org/ext/pure-embedding.html as a basic, but modifiying it now as a function inside my C/C++ code.
0
1976
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 385 open (+21) / 3790 closed (+21) / 4175 total (+42) Bugs : 1029 open (+43) / 6744 closed (+43) / 7773 total (+86) RFE : 262 open ( +4) / 291 closed ( +4) / 553 total ( +8) New / Reopened Patches ______________________
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8866
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7385
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6192
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2769
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1772
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.