Hi

As a part of my semester project, I am supposed to do a Python based OS. The key idea is, simplest OS that lets you boot successfully and run some simple command line scripts, like how DOS works, but in Python and runs Python.


I am completely baffled as to how to go about it.


The first step is to make the initial boot sequence so that it shows up in the grub. But I can't find anything that would suggest me a way to make that boot sequence. Any help please?

I am not looking for a code. I just want a guideline/helpbook sort of thing that would tell me what all to do/make so that I can make the boot sequence.


Any help is much appreciated.

There once was a project to build an operating system in python (unununium) see http://unununium.org/. You could browse their source code as a first step. Also you can google for "writing an operating system". There are many links.

Actually, browsing the source code of unununium shows mainly asm files ...

you should determine minimum environment for running python interpreter and see what additional low level functions need to be implemented. I think that actual primitives of booting you can leave out. I can not imagine you writing FAT and EXT4 drivers, not to speak USB or Sata drivers in Python. Recheck the scope of your assignment with teacher. Spend much time and effort in defining the functions to be implemented and which not and why. Get the aproval of the teacher for plan.

imagine how slow that os would be.

imagine how slow that os would be.

I prefer to imagine how fast that os would if someone used cython.

The good news is that python underneath is C++ language, you could interface countless OS code with python through cython and experience zero speed lose. If you are clever enough you could make it even faster. But that will require deep knowledge of Python, of C++ and OS design.

I dont think you can completely avoid writing some C++ code or even assembler code. Cython afterall is designed to either wrap , extend or embed. Not to build standalone binaries. Especially for writing drivers. But I think you can write an OS using 90% python including cython.

Is your OS going to be build completely from scratch or based on another open source os like linux for example? Linux already wraps loads of its functionality with python, so partly Linux and especially Ubuntu is a python os, but of course the big majority of code is still C++.

I was thinking of starting from scratch. Like just the very basic model. It shows up in my grub. when i click enter it takes me to a python shell ( like dos) where I can execute some commands. I would be even happy if it shows up in my grub.


But I am baffled as to how to do that only. what do I require to make it show on my grub? And the dominant language has to be python. Any help on that? ( and i'm not asking it to avoid some research work. I have googled it for days and haven't come upon anything substantial.)

How about checking out OLPC software (mostly Python) and ubuntu basic components. I think you are talking as Python as shell. As Python should be dominant, I would say that take minimal linux distro https://help.ubuntu.com/community/Installation/MinimalCD, maybe PuppyLinux or DSL could be better, but not maybe so Python based and and python by decent package manager with dependencies to it. Install ipython or bpython package, program set of system commands in from bash+more+grep+wc... translated to python. Set up ipython as shell for default user with autologin. DOS -style says: you want to start text based. Continue by replacing the boot sequence with custom Python program.

Alternatively check out embedded systems or Meego as starting points.

I was thinking of starting from scratch. Like just the very basic model. It shows up in my grub. when i click enter it takes me to a python shell ( like dos) where I can execute some commands. I would be even happy if it shows up in my grub.


But I am baffled as to how to do that only. what do I require to make it show on my grub? And the dominant language has to be python. Any help on that? ( and i'm not asking it to avoid some research work. I have googled it for days and haven't come upon anything substantial.)

Python is made to run inside an OS not to be an OS. That means that you will have to do some heavy hacking. The only way to do it is to look into Python source code and Linux source code, both open source , I cant see how you can do it without writing a single line of C++. I am talking here about building a new distribution of python.

Bare in mind that both python and linux are written in c/c++ . Its should be theorotically possible to build a python inpreter that is also a light OS, but cant see how that cannot involve some amount of C++. But once you made the foundation in C++ , then you can implement the higher functionality in python.

In short study the linux and python source code, the answer should be inside there. But bare in mind, OS developemnt is one of the most toughest out there, you will have to build everything from scratch.

The alternative is to base your Python OS on a linux kernel, that means that your core will be C++ code copied from Linux source code, something you are allowed to do as long as your whole code is compliant with the linux licence, and then you could add python intepreter. You could either modify the python inpreter or keep it as it is, and then implement higher leve functionality with python. ITs totally up to you.

Obviously its completely up to you, if you decide to implement python intepreter make sure that the underlying libraries you will be using will be available to python and I mean the C++ libraries, if you want to detach python from C++ then you will have to make your own python distribution that will work hand in hand with your main kernel, it may even be part of it. IF you do that then you will have to build new libraries, however those libraries will have the advantage of that will be only needed to be written in python.

So in short my advice, take the linux kernel, study it , see what you need, use it as it or edit it to fit your demands, make it run python inpreter automatically, build the rest of the functionality in python but first make sure all the required C++ libraries are available with your linux distro. This is the easiest solution I can think of.

Thanks a lot. I'll look into everything you guys told and if I get more doubts, I will ask here only. Thanks a lot guys. Much appreciated.

What about writing BIOS to run with the python interpreter?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.