New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Building Fails #5018
Comments
@phirst We need some more background information than this.
|
Command used to Build: Here's the .spec file:
I've also rolled back to PyInstaller |
Hmm, something has as moved. Can you run the following and paste the output back here? from PyInstaller.utils.hooks import base_prefix
print(base_prefix)
import sys
print(sys.prefix)
from PyInstaller import __file__ as pyi_root
print(pyi_root) |
|
Could you inject a print statement into your source code. |
|
The plot thickens... I switched to a different virtual environment and tried rebuilding. I also added the print statement. The different environment (created pre-OS upgrade) worked just fine. Here's the output of the print statement:
|
Ok well I'll start with the environment that doesn't work. When PyInstaller tries to work out where to put
relative to either of
But neither of them are strict base paths, so the list of possible candidates |
For the pre OS upgrade env could you rerun those print tests from above? |
|
Hmm that appears to contradict what originally thought a couple of messages up. Could you also run in the env that works: from PyInstaller.utils.hooks import _find_prefix
print(_find_prefix("/Users/my.user.name/.pyenv/versions/3.7.6/include/python3.7m/pyconfig.h")) |
|
I notice in #1545 that the |
Another question: Where does |
Working : |
What about |
|
@phirst We have an open PR which may fix this. Could you give it a go? |
Having a similar issue but the bugfix does not seem to resolve it. With the bugfix, my trace is (removed some of the hook warnings):
I'm running I tested this with Python 3.7.6 and 3.8.3 installed via pyenv with the --enable-framework flag. Funnily enough I built the same project/script a couple of days ago on my other Mac, also after installing pyenv with the --enable-framework flag like I just did on this machine where the error occurs. |
Aaaactually. I just went to the other machine to compile and checked if something is still different between the two and it turns out on the other machine it works to be running pyinstaller from a pyenv version (3.8.3) but what does not work on this machine is running it from a pyenv virtualenv using python 3.8.3 — however, also on this machine where I originally got the error above when I do not use pyenv virtualenv but just a pyenv python 3.8.3 it does compile without error. Does this help in any way? I presume you'd have to be quite familiar with the inner workings of |
OK, thanks @kontur. I think this confirms that this is a separate issue to the one the PR addresses.
That's a thing too? How many @kontur Could you clarify for me - do the virtual environments share the |
Ikr :D pyenv & pyenv-virtualenv is really quite neat, from a user point of view. Easy python version switching and venvs associated with those. As to your question I cannot say. pyenv generally works by shimming the binaries to redirect calls, so my guess would be that the pyenv-virtualenvs use the python version of the pyenv they were created with and only isolate the "site-packages" to that pyenv-virtualvenv. |
That's what I used to think venv does, But it turned out to mess with quite a bit more. Could you run the following inside a virtual environmemt? from distutils.sysconfig import get_python_inc
print(get_python_inc())
import sys
print(sys.prefix)
print(sys.base_prefix)
print(sys.exec_prefix) |
From the "failing" environment:
Vs. just python 3.8.3 where it works:
|
Ok so it looks like Can I also have |
Ohh, I see there has been some changes in that area since that would mask this issue. 4d66c7d would cause the exception to go away but would mislead you into thinking it is fixed because it would put the file in the wrong place. |
I've made some small changes. Could you test them? pip install https://github.com/bwoodsend/pyinstaller/archive/fix-sysconfig.zip You should be able to test it just by running: import os
from distutils.sysconfig import get_python_inc
from PyInstaller.utils.hooks import _find_prefix
print(_find_prefix(os.path.join(get_python_inc(), "pyconfig.h")))
print(_find_prefix(os.path.join(get_python_inc(True), "pyconfig.h"))) I've chucked in some extra logging calls so could you copy/paste everything it says... |
With the fix sysconfig install it works 👏
Running the test as
Thanks so much for your effort! Let me know if I can test anything else 👍 |
Ooh no. What I said about above changes that would mask this error has happened. This isn't actually fixed. It's now defaulting to something inappropriate so that your What I though would happen inside PyInstaller was this output:
But it turns out But I do have a better idea. Hang on... |
I can compile binaries outside the pyenv-virtualenv, so no rush on this from my side. Appreciate your tenaciousness 👍 |
OK. I've prodded it somewhere else. Let's see what happens. Could you: Try the There's no need to run those print statements from above again - I'm not touching the |
Hey, it does build the binary, but executing it fails:
&
|
Well the build log is doing what I wanted it to do. Does |
@bwoodsend - I wanted to let you know that I had a very similar issue and installing the fix you deployed on this branch: |
Thanks @yehuda-elementryx. I guess the next thing to test now that PyInstaller seemingly builds ok is that import os
import sysconfig
print("Expecting config.h at:", sysconfig.get_config_h_filename())
if os.path.exists(sysconfig.get_config_h_filename()):
print("Hah Hah Seh Lah! Found config.h!")
print(sysconfig.get_config_vars()["py_version"])
else:
print("config.h not found :(") |
@bwoodsend - I added the above script at the start of the app that I'm freezing. I then ran pyinstaller to generate a single file executable. Running the single file executable renders:
Is that what you'd had in mind? |
Yep. That's what I wanted to hear. I'll turn this into a pull request then... |
Locating `pyconfig.h` and the `makefile` gets into a mess when using certain environment managers (pyenv-virtualenv) because PyInstaller, whilst trying to find an appropriate `dest` path to put the files in, gets confused by `sys.prefix` (or its varients) not being a parent dir of the config and makefiles. As a (seemingly more rubust) alternative, this commit uses `sysconfig.get_python_inc(prefix=".")` to choose a dest dir instead. See pyinstaller#5018.
Locating `pyconfig.h` and the `makefile` gets into a mess when using certain environment managers (pyenv-virtualenv) because PyInstaller, whilst trying to find an appropriate `dest` path to put the files in, gets confused by `sys.prefix` (or its varients) not being a parent dir of the config and makefiles. As a (seemingly more rubust) alternative, this commit uses `sysconfig.get_python_inc(prefix=".")` to choose a dest dir instead. See pyinstaller#5018.
I've made some more changes. It looks like these files aren't actually needed in the first place so the fix is just to remove the breaking code. But I'd like a final confirmation that it still works before it gets merged. Anyone on here willing to test for me? You'd |
Locating `pyconfig.h` and the `makefile` gets into a mess when using certain environment managers (pyenv-virtualenv) because PyInstaller, whilst trying to find an appropriate `dest` path to put the files in, gets confused by `sys.prefix` (or its varients) not being a parent dir of the config and makefiles. As a (seemingly more rubust) alternative, this commit uses `sysconfig.get_python_inc(prefix=".")` to choose a dest dir instead. See pyinstaller#5018.
Locating `pyconfig.h` and the `makefile` gets into a mess when using certain environment managers (pyenv-virtualenv) because PyInstaller, whilst trying to find an appropriate `dest` path to put the files in, gets confused by `sys.prefix` (or its varients) not being a parent dir of the config and makefiles. As a (seemingly more rubust) alternative, this commit uses `sysconfig.get_python_inc(prefix=".")` to choose a dest dir instead. See pyinstaller#5018.
Locating `pyconfig.h` and the `makefile` gets into a mess when using certain environment managers (pyenv-virtualenv) because PyInstaller, whilst trying to find an appropriate `dest` path to put the files in, gets confused by `sys.prefix` (or its varients) not being a parent dir of the config and makefiles. As a (seemingly more rubust) alternative, this commit uses `sysconfig.get_python_inc(prefix=".")` to choose a dest dir instead. See pyinstaller#5018.
Thank you for all the investigating. For me a new build works 👍 |
Description of the issue
Building fails.
Context information (for bug reports)
pyinstaller --version
:4.0.dev0
vanilla 3.7.6
Catalina 10.15.6
--noupx
or setupx=False
in your .spec-file--debug
topyi-makespec
orpyinstaller
or useEXE(..., debug=1, ...)
in your .spec file.A minimal example program which shows the error
Stacktrace / full error message
The text was updated successfully, but these errors were encountered: