Extracting out the python binaries so it can be reused

29 views Asked by At

I want to install python in an alpine based container. The requirements are that given a version, I have to install that specific version. Since there aren't prebuilt binaries(like node.js) where you can copy them and it just works, we should compile the source code everytime and it takes lots of time. How do I compile the source code once, then reuse those built files whenever I want. (I wont be changing the base image / os of the container)

I tried making a directory, running ../configure and then make and copied the folder and tried to reuse it but it gave me the following error.

Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = './python'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = '/hehe/dist/python'
  sys.base_prefix = '/usr/local'
  sys.base_exec_prefix = '/usr/local'
  sys.executable = '/hehe/dist/python'
  sys.prefix = '/usr/local'
  sys.exec_prefix = '/usr/local'
  sys.path = [
    '/usr/local/lib/python38.zip',
    '/usr/local/lib/python3.8',
    '/hehe/dist/build/lib.linux-x86_64-3.8',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
0

There are 0 answers