§2023-10-30

# emerge dev-db/mongodb --autounamsk-write --autounmask

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

  1. Requirements
$ sudo apt update && sudo apt -y upgrade
$ sudo apt install -y build-essential libcurl4-openssl-dev liblzma-dev libssl-dev python3-dev git ?openssl-devel?

  1. Python3 requirement
alexlai@orgpi516G /opt/xfs/build/mongo $ python3 --version
alexlai@orgpi516G /opt/xfs/build/mongo $ python3 -m venv ~/PYTHON-3.11.6
alexlai@orgpi516G /opt/xfs/build/mongo $ source ~/PYTHON-3.11.6/bin/activate
(PYTHON-3.11.6) alexlai@orgpi516G /opt/xfs/build/mongo $ which python3
/home/alexlai/PYTHON-3.11.6/bin/python3
(PYTHON-3.11.6) alexlai@orgpi516G /opt/xfs/build/mongo $ which pip
/home/alexlai/PYTHON-3.11.6/bin/pip
(PYTHON-3.11.6) alexlai@orgpi516G /opt/xfs/build/mongo $ python3 -m pip install 'poetry==1.5.1'
(PYTHON-3.11.6) alexlai@orgpi516G /opt/xfs/build/mongo $ pip install --upgrade pip
(PYTHON-3.11.6) alexlai@orgpi516G /opt/xfs/build/mongo $ python3 -m poetry install --no-root --sync

Poetry could not find a pyproject.toml file in /opt/xfs/build/mongo or its parents

skip to 4

  1. git clone mongo
 $ git clone https://github.com/mongodb/mongo.git && cd mongo
 $ git checkout r7.0.2 -b test
Updating files: 100% (10380/10380), done.
Switched to a new branch 'test'
  1. poetry init
(PYTHON-3.11.6) alexlai@orgpi516G /opt/xfs/build/mongo $ poetry install --no-root --sync

Poetry could not find a pyproject.toml file in /opt/xfs/build/mongo or its parents
(PYTHON-3.11.6) alexlai@orgpi516G /opt/xfs/build/mongo $ poetry init

This command will guide you through creating your pyproject.toml config.

Package name [mongo]:  
Version [0.1.0]:  
Description []:  Build mongo from Source
Author [None, n to skip]:  Alex Lai(alexlai@munetaka.me)    
Invalid author string. Must be in the format: John Smith <john@example.com>
Author [None, n to skip]:  Alex Lai <alexlai@munetaka.me>
License []:  
Compatible Python versions [^3.11]:  

Would you like to define your main dependencies interactively? (yes/no) [yes] 
You can specify a package in the following forms:
  - A single name (requests): this will search for matches on PyPI
  - A name and a constraint (requests@^2.23.0)
  - A git url (git+https://github.com/python-poetry/poetry.git)
  - A git url with a revision (git+https://github.com/python-poetry/poetry.git#develop)
  - A file path (../my-package/my-package.whl)
  - A directory (../my-package/)
  - A url (https://example.com/packages/my-package-0.1.0.tar.gz)

Package to add or search for (leave blank to skip): 

Would you like to define your development dependencies interactively? (yes/no) [yes] 
Package to add or search for (leave blank to skip): 

Generated file

[tool.poetry]
name = "mongo"
version = "0.1.0"
description = "Build mongo from Source"
authors = ["Alex Lai <alexlai@munetaka.me>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.11"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"


Do you confirm generation? (yes/no) [yes]

PYTHON-3.11.6) alexlai@orgpi516G /opt/xfs/build/mongo $ poetry install --no-root --sync
Updating dependencies
Resolving dependencies... (0.1s)

Package operations: 0 installs, 0 updates, 48 removals

  • Removing attrs (23.1.0)
  • Removing build (0.10.0)
  • Removing cachecontrol (0.12.14)
  • Removing certifi (2023.7.22)
  • Removing cffi (1.16.0)
  • Removing charset-normalizer (3.3.1)
  • Removing cleo (2.1.0)
  • Removing crashtest (0.4.1)
  • Removing cryptography (41.0.5)
  • Removing distlib (0.3.7)
  • Removing dulwich (0.21.6)
  • Removing filelock (3.13.1)
  • Removing html5lib (1.1)
  • Removing idna (3.4)
  • Removing importlib-metadata (6.8.0)
  • Removing installer (0.7.0)
  • Removing jaraco-classes (3.3.0)
  • Removing jeepney (0.8.0)
  • Removing jsonschema (4.19.2)
  • Removing jsonschema-specifications (2023.7.1)
  • Removing keyring (23.13.1)
  • Removing lockfile (0.12.2)
  • Removing more-itertools (10.1.0)
  • Removing msgpack (1.0.7)
  • Removing packaging (23.2)
  • Removing pexpect (4.8.0)
  • Removing pkginfo (1.9.6)
  • Removing platformdirs (3.11.0)
  • Removing poetry (1.5.1)
  • Removing poetry-core (1.6.1)
  • Removing poetry-plugin-export (1.5.0)
  • Removing ptyprocess (0.7.0)
  • Removing pycparser (2.21)
  • Removing pyproject-hooks (1.0.0)
  • Removing rapidfuzz (3.4.0)
  • Removing referencing (0.30.2)
  • Removing requests (2.31.0)
  • Removing requests-toolbelt (1.0.0)
  • Removing rpds-py (0.10.6)
  • Removing secretstorage (3.3.3)
  • Removing shellingham (1.5.4)
  • Removing six (1.16.0)
  • Removing tomlkit (0.12.1)
  • Removing trove-classifiers (2023.10.18)
  • Removing urllib3 (1.26.18)
  • Removing virtualenv (20.24.6)
  • Removing webencodings (0.5.1)
  • Removing zi
  1. pip requirements
(PYTHON-3.11.6) alexlai@orgpi516G /opt/xfs/build/mongo $ pip3 install -r etc/pip/compile-requirements.txt
...
Using cached botocore-1.31.74-py3-none-any.whl (11.3 MB)
Using cached s3transfer-0.7.0-py3-none-any.whl (79 kB)
Installing collected packages: types-setuptools, types-PyYAML, regex, urllib3, typing-extensions, smmap, six, setuptools, requirements_parser, PyYAML, pyparsing, pycparser, psutil, jmespath, idna, dnspython, distro, Cheetah3, charset-normalizer, certifi, requests, python-dateutil, pymongo, pydantic, packaging, gitdb, cffi, gitpython, cryptography, botocore, s3transfer, boto3, pymongo-auth-aws, mongo-tooling-metrics, mongo-ninja-python
  Attempting uninstall: setuptools
    Found existing installation: setuptools 68.2.2
    Uninstalling setuptools-68.2.2:
      Successfully uninstalled setuptools-68.2.2
Successfully installed Cheetah3-3.2.6.post1 PyYAML-5.3.1 boto3-1.28.74 botocore-1.31.74 certifi-2023.7.22 cffi-1.16.0 charset-normalizer-2.0.12 cryptography-36.0.2 distro-1.8.0 dnspython-2.4.2 gitdb-4.0.11 gitpython-3.1.40 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.13 pymongo-4.3.3 pymongo-auth-aws-1.1.0 pyparsing-3.1.1 python-dateutil-2.8.2 regex-2021.11.10 requests-2.26.0 requirements_parser-0.3.1 s3transfer-0.7.0 setuptools-58.5.3 six-1.16.0 smmap-5.0.1 types-PyYAML-6.0.12.12 types-setuptools-57.4.18 typing-extensions-4.8.0 urllib3-1.26.18

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

  1. make it
$ cat ~/scripts/buildMongo.sh 
#!/bin/bash

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

#   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)
#