carlosperate / python-portable-macos

An attempt to make a portable version of Python for macOS to pack Python applications into self-contained executables
MIT License
8 stars 2 forks source link

Question about portable python #9

Open evaxliu opened 1 year ago

evaxliu commented 1 year ago

Hi Carlos! I am currently working on creating a portable python for all macos users to use a software I am creating at an academic lab I work at so they don't need to install python separately on their own. I successfully created a pkg file which downloads to the user's Downloads folder which works on my own device but there is a SSL module error when used on a different device. I was wondering if you encountered this issue before and could give some guidance about it. Thank you very much!

The error I get:

image

The script I run to use the portable python

ve() {
    local venv="virtual_env_ant"
    echo "running install virtual env"

    echo "Creating and activating virtual environment ${venv}"
    # virtualenv ~/[${venv}]
    sudo -u $USER /Users/my-device-username/Downloads/portable_python/bin/python3.9 -m venv $HOME/${venv} --system-site-package
    echo $'appdirs==1.4.4\ncertifi==2020.12.5\nchardet==4.0.0\ncolorama==0.4.4\ncolorlog==4.8.0 \neasydev==0.11.0\nidna==2.10\ngit+https://github.com/lark-parser/lark.git@5b8c04ca83b9#egg=lark_parser\nlibChEBIpy==1.0.10\npexpect==4.8.0\nptyprocess==0.7.0\npygls==0.9.1\nrequests==2.25.1\nrequests-cache==0.5.2\nsix==1.15.0\nurllib3==1.26.4\nantimony\nbioservices==1.8.3\n# ols_client==0.0.9\nAMAS-sb==0.0.1\norjson==3.8.0\nnumpy==1.24.2' > $HOME/${venv}/all-requirements.txt
    $HOME/${venv}/bin/python3 -m pip --disable-pip-version-check install -t $HOME/${venv}/lib/python3.9/site-packages --no-cache-dir --upgrade -r $HOME/${venv}/all-requirements.txt && success=1
}

ve "$@"

Steps I used to create the portable macos python: cd /Users/my-device-username/Downloads

git clone --branch v3.9.12 https://github.com/python/cpython.git

cd cpython

chmod -R 777 .

Create new folder in downloads called portable_python /configure LDFLAGS="-L/opt/homebrew/opt/xz/lib" CPPFLAGS="-I/opt/homebrew/opt/xz/include" --prefix=/Users/my-device-username/Downloads/portable_python

make

make install

cd .. (Back to Downloads folder)

pkgbuild --root ./portable_python --identifier com.example.package --version 0.2.13 --install-location "$HOME/Downloads/portable_python" portable_python.pkg

carlosperate commented 1 year ago

Hi @evaliu2002,

My best advice right now would be to use https://github.com/indygreg/python-build-standalone, unless you have some very specific requirements where you might need to build your own.

Hope that helps!