-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Use PyInstaller for freeze test env #1773
Conversation
cx_freeze doesn't seem to be very well supported in Python 3.5. Using pyinstaller instead and rename environment to "freeze" which is a more generic term for freezing python code into standalone executables. Fix pytest-dev#1769
As a note, opened pyinstaller/pyinstaller#2119 so the user doesn't even need to use the |
Hmm, seems like there are some warnings on AppVeyor:
But it seems to work just fine. PyInstaller bug? |
for x in pytest.freeze_includes(): | ||
hidden.extend(['--hidden-import', x]) | ||
args = ['pyinstaller'] + hidden + ['runtests_script.py'] | ||
subprocess.check_call(' '.join(args), shell=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not simply subprocess.check_call(args) without shell=True?
On Windows without shell=True
you have to add the .exe
extension:
>>> import subprocess
>>> subprocess.check_call('py.test --help')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "e:\ws\Souring\envs\steam_souring10\lib\subprocess.py", line 536, in check_call
retcode = call(*popenargs, **kwargs)
File "e:\ws\Souring\envs\steam_souring10\lib\subprocess.py", line 523, in call
return Popen(*popenargs, **kwargs).wait()
File "e:\ws\Souring\envs\steam_souring10\lib\subprocess.py", line 711, in __init__
errread, errwrite)
File "e:\ws\Souring\envs\steam_souring10\lib\subprocess.py", line 959, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
>>> subprocess.check_call('py.test.exe --help', shell=True)
... <output> ...
0
And I wanted to keep things simple here.
Also, it might be better to tell users what to add to their spec file ...
My intention in this topic is not actually be a complete help on how to use PyInstaller, only to briefly demonstrate how to use the pytest.freeze_includes()
function. Actually now that pyinstaller/pyinstaller#2119 is merged, I think this docs should be updated to just mention that pytest should work out of the box with the latest PyInstaller, while others using other tools can use the freeze_includes()
function to obtain the list of pytest internal modules.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Windows without
shell=True
you have to add the.exe
extension:
Oh wow. I guess passing a list (['py.test', '--help']
) doesn't help either?
Actually now that pyinstaller/pyinstaller#2119 is merged, I think this docs should be updated to just mention that pytest should work out of the box with the latest PyInstaller, while others using other tools can use the
freeze_includes()
function to obtain the list of pytest internal modules.
Sounds good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wow. I guess passing a list (['py.test', '--help']) doesn't help either?
No, the problem is there's no py.test
file, only py.test.exe
... shell=True
works because the shell let's you get away with typing the .exe
yourself. 😉
Sounds good to me!
Updated. 😁
Yep. It's fixed for the next release. (It's related to us switching the |
|
||
Fortunately recent ``PyInstaller`` releases already have a custom hook | ||
for pytest, but if you are using another tool to freeze executables | ||
such as ``cx_freeze`` or ``py2exe``, you can use the ``pytest.freeze_includes()`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no "the" here 😉
As discussed during the review, suggest in general to use PyInstaller and just mention pytest.freeze_includes() in less detail on how to actually use it, because it varies from tool to tool.
LGTM, will merge once the CI passes. |
Thanks! |
👍 😄 |
cx_freeze doesn't seem to be very well supported in Python 3.5.
Using PyInstaller instead and rename environment to "freeze" which
is a more generic term for freezing python code into standalone
executables. PyInstaller is also much simpler to use.
Also note that this did not change any functionality, only internal testing and docs, that's why I'm targeting
master
here.Fix #1769