473,406 Members | 2,894 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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:2623: warning: implicit declaration of function `ioctl'
Modules/posixmodule.c:2623: error: `I_PUSH' undeclared (first use in this function)
Modules/posixmodule.c:2623: error: (Each undeclared identifier is reported only once
Modules/posixmodule.c:2623: error: for each function it appears in.)
Modules/posixmodule.c: In function `posix_setgroups':
Modules/posixmodule.c:4527: 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 3787
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:2623: warning: implicit declaration of function `ioctl'
Modules/posixmodule.c:2623: error: `I_PUSH' undeclared (first use in this function)
Modules/posixmodule.c:2623: error: (Each undeclared identifier is reported only once
Modules/posixmodule.c:2623: error: for each function it appears in.)
Modules/posixmodule.c: In function `posix_setgroups':
Modules/posixmodule.c:4527: 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.python. It has definitely been done.

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

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

Similar topics

47
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...
36
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...
1
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...
1
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...
6
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...
0
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...
6
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...
0
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
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...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...

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.