1. Requirements
# apt update && sudo apt -y upgrade
# apt install -y build-essential libcurl4-openssl-dev liblzma-dev libssl-dev python3-dev git 
  1. Python3
$ python3 --version
Python 3.11.2

# apt install -y python3.11-venv
$ python3 -m venv ~/PYTHON-3.11.2
alexlai@n2Bookworm:~/build$  source ~/PYTHON-3.11.2/bin/activate
(PYTHON-3.11.2) alexlai@n2Bookworm:~/build$ 
(PYTHON-3.11.2) alexlai@n2Bookworm:~/build$ puthon3 --version
-bash: puthon3: command not found
(PYTHON-3.11.2) alexlai@n2Bookworm:~/build$ python3 --version
Python 3.11.2

(PYTHON-3.11.2) alexlai@n2Jammy:~$ pip3 cache purge
WARNING: No matching packages
Files removed: 0

以下, should run under source ~/PYTHON-3.10.2/bin/activate

  1. git clone mongo
(PYTHON-3.10.2) alexlai@n2Jammy:~$ mkdir build && cd $_
(PYTHON-3.10.2) alexlai@n2Jammy:~/build$ git clone https://github.com/mongodb/mongo.git && cd mongo

(PYTHON-3.10.2) alexlai@n2Jammy:~/build/mongo$ git checkout r7.0.5 -b test
Updating files: 100% (24531/24531), done.
Switched to a new branch 'test'
  1. pip requirements
$ pip3 install -r etc/pip/compile-requirements.txt
...
Successfully installed Cheetah3-3.2.6.post1 PyYAML-6.0 anyio-3.7.1 boto3-1.28.9 botocore-1.31.9 certifi-2023.5.7 
cffi-1.15.1 charset-normalizer-2.0.12 cryptography-36.0.2 distro-1.8.0 dnspython-2.4.0 gitdb-4.0.10 
gitpython-3.1.32 h11-0.14.0 httpcore-0.17.3 idna-3.4 jmespath-1.0.1 mongo-ninja-python-1.11.1.5 mongo-tooling-metrics-1.0.8 packaging-21.3 psutil-5.8.0 pycparser-2.21 pydantic-1.10.11 pymongo-4.3.3 pymongo-auth-aws-1.1.0 pyparsing-3.1.0 python-dateutil-2.8.2 
regex-2021.11.10 requests-2.26.0 requirements_parser-0.3.1 s3transfer-0.6.1 setuptools-58.5.3 six-1.16.0 
smmap-5.0.0 sniffio-1.3.0 types-PyYAML-6.0.12.11 types-setuptools-57.4.18 typing-extensions-4.7.1 urllib3-1.26.16

if pip install psutil errors then sudo apt install gcc python3-dev will fix it.

  1. make it
#!/bin/bash

# -j number of CPUS, no plus 2, odroid-n2 -j 6, odroid-hc4 -j4, orangePi5 -j 8
# execute form git clone https://github.com/mongodb/mongo.git && cd mongo
# under python3 eviromental control
# git checkout r7.0.0-rc8 -b test
# time python3 buildscripts/scons.py install-core -j6 --ssl --linker=gold CFLAGS="-march=armv8-a+crc -mtune=generic" --disable-warnings-as-errors >log 2>&1 &
time python3 buildscripts/scons.py install-core -j6 --ssl --linker=gold CFLAGS="-march=armv8-a+crc -mtune='cortex-a73.cortex-a53' " --disable-warnings-as-errors >log 2>&1 &

# CFLAGS="-march=armv8-a+crc -mtune='cortex-a73.cortex-a53' " 2023-07-25
#
#   install-mongod
#   install-mongos
#   install-core (includes only mongod and mongos)
#   install-servers (includes all server components)
#   install-devcore (includes mongod, mongos, and jstestshell (formerly mongo shell))
#   install-all (includes a complete end-user distribution and tests)
#    install-all-meta (absolutely everything that can be built and installed)
#
#!/bin/bash

# -j number of CPUS, no plus 2, odroid-n2 -j 6, odroid-hc4 -j4, orangePi5 -j 8
# execute form git clone https://github.com/mongodb/mongo.git && cd mongo
# under python3 eviromental control
# git checkout r7.0.0-rc8 -b test
# time python3 buildscripts/scons.py install-core -j6 --ssl --linker=gold CFLAGS="-march=armv8-a+crc -mtune=generic" --disable-warnings-as-errors >log 2>&1 &
time python3 buildscripts/scons.py install-core -j6 --ssl --linker=gold CFLAGS="-march=armv8-a+crc -mtune='cortex-a73.cortex-a53' " --disable-warnings-as-errors >log 2>&1 &

# CFLAGS="-march=armv8-a+crc -mtune='cortex-a73.cortex-a53' " 2023-07-25
#
#   install-mongod
#   install-mongos
#   install-core (includes only mongod and mongos)
#   install-servers (includes all server components)
#   install-devcore (includes mongod, mongos, and jstestshell (formerly mongo shell))
#   install-all (includes a complete end-user distribution and tests)
#    install-all-meta (absolutely everything that can be built and installed)
#


scons: building terminated because of errors.

scons: *** Found dependency cycle(s):
  Internal Error: no cycle found for node build/opt/mongo/db/startup_recovery.o (<SCons.Node.FS.File object at 0x299bec0>) in state pending

File "/home/alexlai/build/mongo/src/third_party/scons-3.1.2/scons-local-3.1.2/SCons/Taskmaster.py", line 1076, in cleanup
build/opt/mongo/db/repl/rollback_impl.o failed: Error 1

real	136m4.480s
user	59m0.044s
sys	    16m42.647s

§ 2024-01-25

(PYTHON-3.11.2) alexlai@n2Bookworm:~/build$ rm -rf mongo/
(PYTHON-3.11.2) alexlai@n2Bookworm:~/build$ git clone https://github.com/mongodb/mongo.git && cd mongo
(PYTHON-3.11.2) alexlai@n2Bookworm:~/build/mongo$ pip3 cache purge
WARNING: No matching packages
Files removed: 0

(PYTHON-3.11.2) alexlai@n2Bookworm:~/build/mongo$ git checkout r7.1.1-rc0 -b test
(PYTHON-3.11.2) alexlai@n2Bookworm:~/build/mongo$ pip3 install -r etc/pip/compile-requirements.txt

r7.2.0 以上、`pip3 install -r etc/pip/compile-requirements.txt` failed to work

In order to build MongoDB, Python 3.9+ is required, and several Python modules must be installed. Python 3 is included in macOS 10.15 and later. For earlier macOS versions, Python 3 can be installed using Homebrew or MacPorts or similar.

MongoDB manages our python dependencies with poetry. You can see other install instructions for poetry by reading this install guide.

Installing the requirements inside a python3 based virtualenv dedicated to building MongoDB is optional but recommended.

$ python3 -m venv <venv_path> --prompt mongo # Optional (venv_path can be a path of your choice) $ source <venv_path>/bin/activate # Optional (might be slightly different based on the your shell) $ python3 -m pip install 'poetry==1.5.1' $ python3 -m poetry install --no-root --sync

Note: In order to compile C-based Python modules, you'll also need the Python and OpenSSL C headers. Run:

Fedora/RHEL - dnf install python3-devel openssl-devel
Ubuntu (20.04 and newer)/Debian (Bullseye and newer) - apt install python-dev-is-python3 libssl-dev
Ubuntu (18.04 and older)/Debian (Buster and older) - apt install python3.7-dev libssl-dev

Note: If you are seeing errors involving "Prompt dismissed.." you might need to run the following command before poetry install.

$ export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring

(PYTHON-3.11.2) alexlai@n2Bookworm:~/build/mongo$ git checkout r7.3.0-rc0 -b test
Switched to a new branch 'test'

$ python3 -m pip install 'poetry==1.5.1'
$ python3 -m poetry install --no-root --sync
(PYTHON-3.10.2) alexlai@n2Jammy:~/build/mongo$ ~/scripts/buildMongo.sh
...
g++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
scons: *** [build/opt/mongo/db/s/set_allow_migrations_coordinator.o] Error 1
g++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
scons: *** [build/opt/mongo/db/exec/sbe/abt/abt_lower.o] Error 1
scons: building terminated because of errors.
build/opt/mongo/db/s/set_allow_migrations_coordinator.o failed: Error 1
build/opt/mongo/db/exec/sbe/abt/abt_lower.o failed: Error 1

real	232m12.700s
user	18m42.520s
sys	18m58.687s