Skip to content

Installers for Python

I've decided to create two versions of the python software as a relatively Silent installer to be run on the Command Prompt. One version for the 3.9.x series and one for 3.10.x series as well as 3.11.x on github.

*Updated; I have branch out the python script to this one centralized location for both MAC and Windows users: https://github.com/freemanbach/PythonInstallerScripts

https://github.com/freemanbach/Python/tree/master/python3/installscript/3.9.12

https://github.com/freemanbach/Python/tree/master/python3/installscript/3.10.5

https://github.com/freemanbach/Python/tree/master/python3/installscript/3.11.0

Simply Choose the filename with the "cs".

Often time, I found myself needing to use a more sophisticated method in signing a document for sharing. It is this notion where we could use PGP developed by Phil Zimmermann or the Opensource version referred to as GPG. We will demonstrate how to create a simple GPG key and how to delete it in your keychain. Again, we will be using a Linux distro called Rocky to demonstrate this task. On a vanilla minimalistic version of rocky Linux. One would need to install one software before generating your GPG key.

sudo dnf install pinentry
Gen GPG key

The next part will be confirming that we've made such key locally.

GPG list-keys

Finally, removing your public/private keys arent difficult, there are two commands to execute before removing your public and private key from your local keyring.

gpg --delete-secret-key AA1A53D25DFAAE879DE28BFDBD4432D34D059D29
gpg --delete-key AA1A53D25DFAAE879DE28BFDBD4432D34D059D29

This is a simple tutorial to run through on how to generate a few of the ssh keys public/private key pair Authentication. When it comes to using DSA and RSA, they are been phased out due to the vulnerability of these two cryptographic algorithms. It is not recommended to use either algorithm on any production systems. We will demonstrate how to generate these keys using a Linux OS called Rocky inside a host environment via Vmware. The third algorithm is much more secure and can be used in any production environment. This is a new cryptographic algorithm called ed25519, which is highly recommended over RSA and DSA.

gen RSA key

so, the RSA key was created inside a VM. I initially had to create a new directory called .ssh in my home directory. My procedures are as follows.


mkdir .ssh
ssh-keygen -t rsa -b 4096 -C YourEMAILAddress@SOMETHING.com
# You can also specify the name of your cryptoGraphic Key file inside this command.
ssh-keygen -t rsa -b 4096 -f .ssh/myPrivateKey -C YourEMAILAddress@SOMETHING.com

Here is an example of how to generate DSA key pair.

Gen DSA

Finally, we will use ED25519 cryptographic algorithm to generate this key, which can be used on github, bitbucket, and gitlab.

Gen ed25519

As you can see, one can simply generate all these keys on linux and even on windows as well by using putty or inside powershell. My final image will be to show the keys generated by each of the above cryptographic algorithms.

Crypto keys

This is hopefully somewhat educational.

After all these years working on Linux in the server environment, I was finally able to configure the console resolution upon booting from an auto-size screen to a custom-size screen. It is simply by adding two lines of GRUB environment values to /etc/default/grub and altering a variable called GRUB_COMMAND_LINUX to include at the end vga=0x0342.

/etc/default/grub

As you can see, line 2 and line 3 were added as well as line 8 was altered to include vga=0x0342 or vga=ask. If you wish to have the system display the availability of screen size resolution upon reboot, you should say vga=ask, otherwise, vga=0x0342 will work upon reboot. So, our next phase will be to compile a new grub boot. on Vmware Workstation on windows v16.x.x and VMFusion on Mac, they both will take this configuration since I've tested on both systems.

As root:

sudo su -
grub2-mkconfig -o /boot/grub2/grub.cfg
reboot

now, Your linux boot loader Framebuffer should be larger. In a matter of fact, it should now be with a resolution of 1152 by 864 with 24 bit.

Continuing after we've compiled Python on Windows 11 from source code, we would then need to package this using the MSIX package manager tool to build and installer. Thankfully, the Python source code will include such tools for us to build our custom package by using the build script provided to us in the following location.

Python Package Build Location

We can then Follow some basic instructions to compile additional source code and find out how to build this installer package by executing the build.bat file.

Package builder Script

Now we have learned how to use this build.bat file, we can issue this command along with three parameters to build this deliverable package for the masses.

Building Documentations, where there might be some warnings or errors

Building Documentations.

Done building Package w/Warning

The Final Phrase will be to check whether we have 100% completed this package Building Phrase using this build.bat tool provided to us from Python.org.

the final Image will be the location for us to find this Python Installer package. It is not the Installer package from Python.org since their version is digitally signed and verified.

Our Custom version of Python v3.9.11-7750

Done.

I was extremely curious about how to build a version of Python 3.9.x {x64/x86} on a Windows 10/11 machine for the longest time. Finally, I've found an hour to learn how to pursue this system engineering topic (System build process aka Build Engineering) on compiling my unique version of Python 3.9.x on windows.

Thanks to All the Opensource Contributors on writing scripts to automate most of this process, I was able to follow instructions when building a version of Python 3.9.x.

First, one must install the following tools from Microsoft: Visual Studio 2019.

Visual Studio

We then would require the necessary packages in our VS 2019.

VS Packages

After installing Additional Packages for VS 2019, we would now need to use the CMD Prompt to generate some additional files after downloading the tgz compressed file python v.3.9.10 source code from Python.org. After decompressing this tarball file, we now have Python-3.9.10 Directory, where all the files have been extruded from this tarball.

compiling AMD x64 bit version

There are options when comes to compiling, I took the recommended approach. It is likely not to follow recommended instructions when compiling initially, but on generating a debug version first to test a custom compiled version of Python v3.9.10 is appropriate. The goal was to test whether SSL was included upon compiling.

build.bat -e -d -p x64
build.bat -e -d -p x86
build.bat -e -p x86
build.bat -e -p x64

As shown above, one can certainly build the debug version to test then build the actual non-debug version of Python.

Once the above process has been completed, we must then look for a file called pcbuild.sln to compile either the 32 or 64 bit version of our python software once we had executed the build.bat configuration file.

BInary python Debug

Once the final process has been completed, we can execute the python_d.exe file in our CMD prompt to see if it was compiled successfully. it is now working perfectly, we can then reconfigure the build.bat switch to remove the -d switch and recompiled a final product of python.exe.

This is a super automated CMD script to install python 3.98 on windows 8/9/10/11. If you have questions, you can contact me. flo <AT> radford <dot> edu

As I had encountered some minor issue, when running this code from below on Windows 11. Often times it will pause and display nothing. To solve this problem, simply press ENTER. You wont encounter such issue when running this code on Windows 10.

github link for the code from below

@echo OFF
:: ADMIN ONLY
:: https://superuser.com/questions/667607/check-if-current-command-prompt-was-launched-as-the-administrator
goto check_Permissions
:check_Permissions
    echo Administrative permissions required. Detecting permissions...
    net session >nul 2>&1
    if %errorLevel% == 0 (
        echo Admin Permissions confirmed.
    ) else (
        echo Admin Permissions not confirmed. 
        echo Right click on the DOS Prompt and RUN AS Administrator
        echo run this script to install Python v3.9.8 Silently.
        echo Exiting....
        goto end
    )
::    pause >nul
echo.
echo.
timeout /T 4 > nul
::
cls
:: Prompt for user to Really run this script
setlocal
set Value="n"
:PROMPT
SET /P Value=Are you sure installing Python-3.9.8 (y/[n])?
IF /I "%Value%" NEQ "y" GOTO END

:: This batch file will show details Windows 10, and install Python v3.9.8
TITLE Install Python Software on Windows 7/8/9/10/11
echo.Checking system information.
timeout /T 2 > nul

:: Switch to Downloads early on
cd C:\Users\%USERNAME%\Downloads

echo.
echo.
:: Section 1: Windows 10/11 information.
echo.============================
echo.WINDOWS INFO
echo.============================
echo.
systeminfo | findstr /c:"OS Name"
systeminfo | findstr /c:"OS Version"
systeminfo | findstr /c:"Hyper-V Requirements"

:: Quick Pause
echo.
timeout /T 2 > nul

echo.
echo.
:: Section 2: Hardware information.
echo.============================
echo.HARDWARE INFO
echo.============================
echo.
systeminfo | findstr /c:"Total Physical Memory"
systeminfo | findstr /c:"Virtual Memory: In Use"

:: Quick Pause
echo.
timeout /T 2 > nul

echo.
:: Section 3: Python Download.
echo.============================
echo.Checking Existing Python
echo.============================
echo.
::
echo. Checking for existing version of Python
::
::
:: https://www.python.org/ftp/python/3.9.8/python-3.9.8-amd64.exe

IF EXIST "python-3.10.0-*.<" (
  echo.Found existing version of Python 3.10.0
  del python-3.10.0-amd64.exe
  echo.Deleting existing version of Python
  echo.
  timeout /T 2 > nul
) ELSE (
  timeout /T 2 > nul
  echo.No existing version of python 3.10.0 Found.
  echo.
)
::
:: Quick Pause
timeout /T 2 > nul
::
IF EXIST "python-3.9.*.<" (
  echo.Found existing version of Python 3.9.*
  del python-3.9.*.*
  echo.Deleting existing version of Python
  echo.
  timeout /T 2 > nul
) ELSE (
  timeout /T 2 > nul
  echo.No existing version of python 3.9 Found.
  echo.
)
echo.
echo.you may need to press ENTER, 
echo.If the wait time is more than 10 seconds.
::
:: Quick Pause
timeout /T 2 > nul
::
IF EXIST "python-3.8.*.<" (
  echo.Found existing version of Python 3.8.*
  del python-3.8.*.*
  echo.Deleting existing version of Python
  echo.
  timeout /T 2 > nul
) ELSE (
  timeout /T 2 > nul
  echo.No existing version of python 3.8 Found.
  echo.
)
echo.
echo.you may need to press ENTER, 
echo.If the wait time is more than 10 seconds.
::
:: Quick Pause
echo.
timeout /T 2 > nul
::
:: Check to see if bitsadmin is located here
echo.
echo.
:: Section 3: Bitsadmin Download.
echo.============================
echo.Checking Bitsadmin
echo.============================
echo.
::
IF EXIST C:\Windows\SysWOW64\bitsadmin.exe (
  echo.Bitsadmin is installed on your Windows 7/8/9/10/11 system.
  echo.Will download Python 3 software.
  echo.
  timeout /T 2 > nul
) ELSE (
  timeout /T 2 > nul
  echo.Apparently, Bitsadmin.exe not found.
  echo.Raise your hand and ask Your Local IT Shop
  echo Can you feel the sorrow ?
  echo.
  goto end
)
::
:: Quick Pause
timeout /T 2 > nul
::
echo.
echo.
:: Section 3: Python Download.
echo.============================
echo.Downloading Python
echo.============================
echo.
::
timeout /T 2 > nul
echo.
echo.
C:\Windows\SysWOW64\bitsadmin.exe /transfer PythonDownload /download /priority normal https://www.python.org/ftp/python/3.9.8/python-3.9.8-amd64.exe C:\Users\%USERNAME%\Downloads\python-3.9.8-amd64.exe
::
echo.
echo.
timeout /T 2 > nul
timeout /T 4 > nul
echo.Checking to see if this python file has been downloaded.
timeout /T 2 > nul
timeout /T 4 > nul
::
IF EXIST python-3.9.8-amd64.exe (
  echo.Python file has been Found.
  echo.Will now Install this Software.
  echo.
  timeout /T 2 > nul
) ELSE (
  timeout /T 2 > nul
  echo.Software not found.
  echo.Perhaps, try to run this file again.
  echo.
  goto end
)

echo.
echo.======================================
echo.Finish downloading the Python Software
echo.======================================
echo.
::
echo.
echo.
:: Section 4: Python Installation.
echo.============================
echo.Installing Python
echo.============================
echo.
echo.Installing Python version 3.9.8
echo.This process will take as much as 15 mins if there is no SSD.
echo.
echo.Go grab Koffie or something before coming back to your Laptop.
:: Installing Python
::
C:\Users\%USERNAME%\Downloads\python-3.9.8-amd64.exe /quiet InstallAllUsers=0 TargetDir=C:\Python398 AssociateFiles=1 CompileAll=1 PrependPath=0 Shortcuts=0 Include_doc=1 Include_debug=0 Include_dev=1 Include_exe=1 Include_launcher=1 InstallLauncherAllUsers=1 Include_lib=1 Include_pip=1 Include_symbol=0 Include_tcltk=1 Include_test=1 Include_tools=1
::
echo.
echo.=======================================
echo.Compiling and Installing Python Modules
echo.=======================================
echo.
:: Quick Pause
timeout /T 2 > nul
echo.
set num=15
for /L %%I IN (1, 1, %num%) do (
  echo. | set /p="%%I " 
  timeout /T 1 > nul
)
echo.
echo.===================================
echo.Finished Installing Python Software
echo.===================================
echo.
::
echo.Be Patient, 60%% Completed
::
echo.
echo.
::
:: Checking the file to see if it was made
::
echo.
echo.
:check
if exist C:\Python398\Tools\pynche\Main.py (
    echo.Checking Files if Python has been installed.....
    timeout /T 3 > nul
    echo.
    echo. Python Software has been Installed.
) else (
    echo. Python has not been installed.
    timeout /T 1 > nul
    echo.
    timeout /T 1 > nul
    echo.Problem with installation. PRESS: CTRL-C to End Installation process only if after three printed messages.
    goto check
)
::
echo.
echo.========================
echo.Updating pip the modules
echo.========================
echo.
echo Starting....
::
:: Updating pip on Windows
C:\Python398\python.exe -m pip install --upgrade pip
::
:: Quick Pause
timeout /T 2 > nul
echo.
echo.======================
echo.Finished Updating pip
echo.======================
echo.
echo done
::
:: Waiting for the previous process to finish
::
echo.
echo.=============================
echo.Installing Additional Modules
echo.=============================
echo.
:: Quick Pause
timeout /T 1 > nul
C:\Python398\Scripts\pip.exe install --user wheel
timeout /T 1 > nul
echo done
::
echo.
echo.===========================
echo.Finished installing Modules
echo.===========================
echo.
echo. 85%% Completed.
echo done
::
echo.
echo.
:: Section 4: Execute runme.bat.
echo.============================
echo.Execute runme.bat
echo.============================
::
echo set PATH=C:\Python398;%PATH% > C:\Users\%USERNAME%\runme.bat
del /s C:\Users\%USERNAME%\Downloads\python-3.9.8-amd64.exe >nul 2>&1
call C:\Users\%USERNAME%\runme.bat
echo.
echo.
python -c "print(\"Welcome, Python installation Success.\")"
echo.
echo.
echo 100%% Completed !
:end

When updating homebrew with your new M1 Apple machine as a web dev machine by developing backend applications with PHP with Homebrew along with MongoDB, where there is an issue when you compile mongoDB driver using PHP from homebrew. We always run into this minor problem, which is somewhat irritating to an extend as we update via the brew command. The main issue we had encountered was that whenever we run

./brew update

the mongodb.so lib driver file will get deleted automatically in the PHP modules location. Since, we've decided to install mongoDB manually from source code, we knew there would be some type of problems we would encounter.

There were two issues:
1) missing pcre2.h file upon compilation
2) automatic deletion of mongodb.so inside a php module dir, after issuing a brew update command.

We will first remedy the missing pcre2.h file in the following section, so that we could compile mongoDB as a driver to be used with PHP@7.4. We will then copy over the mongodb module into the PHP module location.

Using PHP.net 's instructions on how to retrieve the source code for MongoDB. There is a process to get this done relatively with ease.

Compilation of PHP MongoDB Driver

$ git clone https://github.com/mongodb/mongo-php-driver.git
$ cd mongo-php-driver
$ git submodule update --init
$ phpize
$ ./configure

At this Point, pcre2.h is not available from the github repo for this php-mongodb driver package, you can now copy from the default location from your M1 to get this header file to be copied over to this mongo-php-driver directory.

This pcre2.h file should be in this area on your M1 machine, depending on your version of pcre2 from your brew update command. If you don't currently have the pcre2.h file, you then must install the pcre dev header package for pcre from homebrew first. This version i have installed is listed below.

/opt/homebrew/Cellar/pcre2/10.38_1/include/pcre2.h
$ cp /opt/homebrew/Cellar/pcre2/10.38_1/include/pcre2.h . 
$ ./configure 
$ make all

This should take care of the missing pcre2.h file after placing the pcre2.h unto the mongo-php-driver directory for compilation. Once it has finished compiling, you can cd to the modules directory and copy over the mongodb.so file to /opt/homebrew/Cellar/php@7.4/7.4.26/lib/php/20190902/ or whichever directory location it needs to be copied to that location.

If you do have PHP@7.4 in your PATH, you can enter in php -v to check

if that missing --mongodb.so-- lib error has gone away.

flo@hobbit: $ php -i | grep -i mongo

mongodb
MongoDB support => enabled
MongoDB extension version => 1.12.0-dev
MongoDB extension stability => devel
libmongoc bundled version => 1.11.1-20211103+gitb93e345178
libmongoc SSL => enabled
libmongoc SSL library => Secure Transport
libmongoc crypto => enabled
libmongoc crypto library => Common Crypto
libmongoc crypto system profile => disabled
libmongoc SASL => enabled
libmongoc ICU => disabled
libmongoc compression => enabled
libmongoc compression snappy => disabled
libmongoc compression zlib => enabled
libmongoc compression zstd => enabled
libmongocrypt bundled version => 1.2.1
libmongocrypt crypto => enabled
libmongocrypt crypto library => Common Crypto
mongodb.debug => no value => no value
mongodb.mock_service_id => Off => Off



The reason for compiling is that one can easily obtain the latest and greatest software.

How to install MongoDB unto Apple M1.

Go to mongoDB website and download their community version of their product. Download not just the Community Server but also their MongoDB Tools. There are Shell, Compass and Db Tools. I initially had installed Mongosh inside tools inside /opt/mongodb after installing the Mongo Db engine directly inside /opt/mongodb. The remaining items are Compass and a special software called RoboMongo. This is a GUI interface to the connect to the mongoDB engine.

Location of MongoDB and Mongosh.

After those two items were installed, I had to configure the MongoDB engine and would very much like to run it using a config file rather than supplying the mongod command with tons of parameters. So i then worked on the configuration file to make some changes.

MongoDB Configuration.

fork : true doesnt seem to work and had resorted to false instead. The only other items on this install where i had to work on was giving those paths an ownership of the user who needed to be used in order to run these items. My mongodb.conf file is hiding inside my /opt/homebrew/etc location


sudo mkdir -p /usr/local/var/log/mongodb
sudo touch /usr/local/var/log/mongodb/mongod.log
sudo chown -R username:group /usr/local/var/log/mongodb

sudo mkdir -p /usr/local/var/mongodb
sudo chown -R username:group /usr/local/var/mongodb


sudo mkdir -p /var/run/mongodb
sudo touch /var/run/mongod.pid
sudo chown -R username:group /var/run/mongodb

# to run the MangoDB
/opt/mongodb/bin/mongod -f /opt/homebrew/etc/mongod.conf