日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

Linux下CPython源码的编译

發布時間:2024/3/24 linux 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linux下CPython源码的编译 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

最近在看一本python的書CPython Internals,打算研究一下CPython的代碼,然后就在Linux(ubuntu)下編譯了CPython源碼,在此記錄一下。

1. 使用git下載cpython源碼

git clone --branch 3.9 https://github.com/python/cpython cd cpython

2. 使用weget下載cpython3.9.7版本,使用這種是適用于沒安裝git或者訪問github網絡比較差的小伙伴

wget https://github.com/python/cpython/archive/refs/tags/v3.9.7.tar.gztar zxf v3.9.7.tar.gzcd cpython-3.9.7

3. 下載完成之后,需要對cpython進行編譯

# 編譯工具安裝 sudo apt install build-essential # 依賴庫安裝 sudo apt install libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev libffi-dev

4. 運行配置腳本,配置的時候選擇一個debug模式,也可以不選擇,這個看個人選擇。?

./configure --with-pydebug

5. 生成Makefile,j2表示啟動兩個job來加速編譯,-s 表示silent,即不打印output

make -j2 -s

注:在linux執行make --help可參考具體的參數選項

mark123@ubuntu-vm:~/cpythonCode/cpython$ make --help Usage: make [options] [target] ... Options:-b, -m Ignored for compatibility.-B, --always-make Unconditionally make all targets.-C DIRECTORY, --directory=DIRECTORYChange to DIRECTORY before doing anything.-d Print lots of debugging information.--debug[=FLAGS] Print various types of debugging information.-e, --environment-overridesEnvironment variables override makefiles.--eval=STRING Evaluate STRING as a makefile statement.-f FILE, --file=FILE, --makefile=FILERead FILE as a makefile.-h, --help Print this message and exit.-i, --ignore-errors Ignore errors from recipes.-I DIRECTORY, --include-dir=DIRECTORYSearch DIRECTORY for included makefiles.-j [N], --jobs[=N] Allow N jobs at once; infinite jobs with no arg.-k, --keep-going Keep going when some targets can't be made.-l [N], --load-average[=N], --max-load[=N]Don't start multiple jobs unless load is below N.-L, --check-symlink-times Use the latest mtime between symlinks and target.-n, --just-print, --dry-run, --reconDon't actually run any recipe; just print them.-o FILE, --old-file=FILE, --assume-old=FILEConsider FILE to be very old and don't remake it.-O[TYPE], --output-sync[=TYPE]Synchronize output of parallel jobs by TYPE.-p, --print-data-base Print make's internal database.-q, --question Run no recipe; exit status says if up to date.-r, --no-builtin-rules Disable the built-in implicit rules.-R, --no-builtin-variables Disable the built-in variable settings.-s, --silent, --quiet Don't echo recipes.-S, --no-keep-going, --stopTurns off -k.-t, --touch Touch targets instead of remaking them.--trace Print tracing information.-v, --version Print the version number of make and exit.-w, --print-directory Print the current directory.--no-print-directory Turn off -w, even if it was turned on implicitly.-W FILE, --what-if=FILE, --new-file=FILE, --assume-new=FILEConsider FILE to be infinitely new.--warn-undefined-variables Warn when an undefined variable is referenced.This program built for x86_64-pc-linux-gnu Report bugs to <bug-make@gnu.org> mark123@ubuntu-vm:~/cpythonCode/cpython$

6. 執行./python 進入python交互式環境

mark123@ubuntu-vm:~/cpythonCode/cpython$ ./python Python 3.9.7 (default, Sep 11 2021, 15:23:18) [GCC 9.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> >>>

至此,CPython源碼已經編譯完成。

總結

以上是生活随笔為你收集整理的Linux下CPython源码的编译的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。