browserengineering / book

Web browser engineering (a book)

Home Page:https://browser.engineering/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Instructions to run the code (browser)

pranavmodx opened this issue · comments

Firstly, a big thank you to the authors for writing this amazing book!

I understand that this book is a work in progress, but I am really curious to get the code for the browser up and running to see how the current version looked and behaved. I tried running the files in src with relevant dependencies installed and providing a URL as an argument. I got it to work somewhat (beside the SSL error and other internal errors) but its not obvious how to get a web page to be rendered, which is understandable since I haven't read the book so far into the version that I'm running.

But, it could be great if there were some instructions on setup and usage on README.md. Also, the dependencies could be listed in a requirements.txt file.

Hi @pranavmodx, I'm not exactly sure what issues you are running into, but here's how I run it.

First, installation steps:

  1. You'll need a recent Python 3; I run 3.9.10 on my machine, but older versions will probably work. Usually this means you need to use the python3 command.
  2. You'll also need support for the tkinter package, which is part of the Python standard library but often isn't included in the Python pre-installed on macOS and Linux. You can check by running python3 -m tkinter, which should open a test window.
  3. If you want to run Chapter 9+, you'll also need the dukpy package. Consult that chapter for installation instructions.
  4. If you want to run Chapter 11+, you'll also need the skia and pysdl2 packages. Consult that chapter for installation instructions.

Once you have the above, please run:

cd src/
PYTHONBREAKPOINT=0 python3 lab3.py <url>

The lab3.py file is the browser at the end of Chapter 3, without any exercises implemented. You can try a different chapter with lab5.py or lab10.py or whatever.

There's also a server for the later chapters, which you can run with:

cd src/
PYTHONBREAKPOINT=0 python3 server8.py

Finally, you can run the unit tests with:

make test

Let me know if this works. Once we get this debugged, I'll add it to the README.