dzeban / cpython

The Python programming language
https://www.python.org/
Other
0 stars 0 forks source link

Setup dev environment #1

Open dzeban opened 6 years ago

dzeban commented 6 years ago
dzeban commented 6 years ago

Git workflow

There are 2 remotes:

$ git remote -v
origin  git@github.com:dzeban/cpython.git (fetch)
origin  git@github.com:dzeban/cpython.git (push)
upstream        https://github.com/python/cpython.git (fetch)
upstream        https://github.com/python/cpython.git (push)

Update my fork from upstream

$ git fetch upstream master
$ git merge upstream/master 
$ git push  # because origin is my work it's safe
dzeban commented 6 years ago

Building

$ ./configure --with-pydebug
$ make -j

In case of build errors, first try to do a full rebuild with make distclean

Python will be in top dir (dev/cpython/python)

$ ./python 
Python 3.7.0a0 (heads/master:fc1bf87, Sep 12 2017, 09:19:35) 
[GCC 6.3.1 20161221 (Red Hat 6.3.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.

heads/master:fc1bf87 is the current HEAD

dzeban commented 6 years ago

GDB support

Put this to the .gdbinit file in the top dir (dev/cpython/.gdbinit)

add-auto-load-safe-path <path to cpython top dir>

This is how it works

$ gdb -q --args ./python Lib/test/test_with.py                                                                                                                                                                                                                                    
Reading symbols from ./python...done.
(gdb) r
Starting program: /home/avd/dev/cpython/python Lib/test/test_with.py
Missing separate debuginfos, use: dnf debuginfo-install glibc-2.23.1-12.fc24.x86_64
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
^C
Program received signal SIGINT, Interrupt.
_PyMem_DebugMalloc (ctx=0x87bb00 <_PyMem_Debug+96>, nbytes=80) at Objects/obmalloc.c:1526
1526    }
(gdb) py-bt
Traceback (most recent call first):
  File "/home/avd/dev/cpython/Lib/enum.py", line 856, in _decompose
    for v, m in list(flag._value2member_map_.items())
  File "/home/avd/dev/cpython/Lib/enum.py", line 771, in _create_pseudo_member_
    _, extra_flags = _decompose(cls, value)

<...>

  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "Lib/test/test_with.py", line 8, in <module>
    import unittest
(gdb) py-list
 851                    ]
 852        else:
 853            # check for named flags and powers-of-two flags
 854            flags_to_check = [
 855                    (m, v)
>856                    for v, m in list(flag._value2member_map_.items())
 857                    if m.name is not None or _power_of_two(v)
 858                    ]
 859        members = []
 860        for member, member_value in flags_to_check:
 861            if member_value and member_value & value == member_value:

More GDB things

There is a Misc/gdbinit file that adds even more GDB stuff for CPython

dzeban commented 6 years ago

Running tests

$ ./python -m test -j4

Tests are at Lib/test

Some tests are skipped because they platform dependent

test_winconsoleio skipped -- test only relevant on win32

But some tests were disabled because resource wasn't enabled

test_urllib2net skipped -- Use of the 'network' resource not enabled

Check how it can be enabled

dzeban commented 6 years ago

Test run configuration

test module has help: ./python -m test -h.

There we can enable special resource intensive tests to run via -u switch.