ariovistus / pyd

Interoperability between Python and D
MIT License
157 stars 32 forks source link

which python the pyd is using during app build? or how to specify the python path for the built app to run? #155

Open mw66 opened 3 years ago

mw66 commented 3 years ago

Hi,

I'm on Ubuntu 21.04, the default python version is Python 3.9.4.

$ ls -l /usr/bin/python*
lrwxrwxrwx 1 root root      18 May 22 13:14 /usr/bin/python -> /usr/bin/python3.9
lrwxrwxrwx 1 root root       9 Aug  4  2020 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 3613080 Mar  9 03:09 /usr/bin/python2.7
lrwxrwxrwx 1 root root      33 Mar  9 03:09 /usr/bin/python2.7-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx 1 root root      16 Aug  4  2020 /usr/bin/python2-config -> python2.7-config
lrwxrwxrwx 1 root root       9 May 21 18:07 /usr/bin/python3 -> python3.9
-rwxr-xr-x 1 root root 5520856 Apr  4 12:38 /usr/bin/python3.9
lrwxrwxrwx 1 root root      33 Apr  4 12:38 /usr/bin/python3.9-config -> x86_64-linux-gnu-python3.9-config
lrwxrwxrwx 1 root root      16 Apr  6 10:28 /usr/bin/python3-config -> python3.9-config

(please note: it's python3.9, not python3.9m)

I build an app with

        "subConfigurations": {                                                                                                                             
                "pyd": "python36"                                                                                                                          
        },    

and the python36 env I'm using is:

$ ls -l ~/anaconda3.6/bin/python*
lrwxrwxrwx 1 x x       9 Aug 10  2019 /home/x/anaconda3.6/bin/python -> python3.6
lrwxrwxrwx 1 x x       9 Aug 10  2019 /home/x/anaconda3.6/bin/python3 -> python3.6
-rwxrwxr-x 1 x x 3752088 Aug 10  2019 /home/x/anaconda3.6/bin/python3.6
lrwxrwxrwx 1 x x      17 Aug 10  2019 /home/x/anaconda3.6/bin/python3.6-config -> python3.6m-config
lrwxrwxrwx 1 x x       9 Aug 10  2019 /home/x/anaconda3.6/bin/python3.6m -> python3.6
-rwxrwxr-x 1 x x    3425 Aug 10  2019 /home/x/anaconda3.6/bin/python3.6m-config
lrwxrwxrwx 1 x x      17 Aug 10  2019 /home/x/anaconda3.6/bin/python3-config -> python3.6m-config

(please note: python3.6m symlnk to python3.6)

After I build my app with pyd, and run it under the virtual env (from anaconda3.6), it errors out:

  File "/home/x/anaconda3.6/lib/python3.6/sysconfig.py", line 557, in get_config_vars
    _init_posix(_CONFIG_VARS)
  File "/home/x/anaconda3.6/lib/python3.6/sysconfig.py", line 428, in _init_posix
    _temp = __import__(name, globals(), locals(), ['build_time_vars'], 0)
ModuleNotFoundError: No module named '_sysconfigdata__linux_x86_64-linux-gnu'

Note: it's ... __linux ..., but not _m_linux ...

I find the module here:

$ find ~/anaconda3.6/ -name '_sysconfigdata*' | grep 'linux_x86_64-linux-gnu.py'
/home/x/anaconda3.6/lib/python3.6/_sysconfigdata_m_linux_x86_64-linux-gnu.py

Notice, the actual file is: ... _m_linux ...

So I'm guessing that it somehow mess up the system /usr/bin/python (3.9, without m), and the venv ~/anaconda3.6/bin/python (3.6, with m).

I also tried to use

$ source ~/.dub/packages/pyd-0.14.0/pyd/setup/pyd_set_env_vars.sh  ~/anaconda3.6/bin/python

to setup the python I want to use before I do dub build, but no success.

I'm just wondering, how to specify exactly which python (path) that I intended to use during

  1. dub build?
  2. run the app after build?
  3. and can I use a venv python instead of the system python?

Thanks.