You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need to create a section in our documentation about "freezing" Python-Redmine using cxFreeze, PyInstaller, py2exe etc. Thanks to @vlegoff we already have a nice explanation about how to do this for cxFreeze:
There are two obstacles to using python-redmine with cxFreeze. Both can be fixed.
The redmine.resources module isn't automatically exported by cxFreeze when freezing the program, for some reason.
The requests package used by python-redmine needs an additional file with permissions.
The first problem will raise a ResourceError when trying to load any manager, due to the dynamic import in managers.py. This fails, because redmine.resources isn't placed in the library.zip created by cxFreeze. It's just a matter of telling it to do so:
setup(
name = "...",
version = "0.1",
description = "...",
options = {'build_exe': {
"packages": ["redmine.resources"],
}},
executables = [...],
)
That's it.
The second problem is a bit more annoying. The 'requests' package needs the 'cacert.pem' file, but if I understood correctly, it tries to load it from a location that is no longer valid when cxFreeze freezes the program. The solution is to include 'cacert.pem' in the setup.py script (I personally copied it right into my repository, though I don't share it, the original cacert.pem was in C:\PythonXX\Lib\site-packages\requests on Windows). When the file is copied, you need to include it as a static file in your setup.py script.
But that's not enough, because requests still looks for the file in an invalid location. Next thing is to tell it where to look for the file (the current directory in our case). It must be done in the code, somewhere, a place where you know requests will be called is a good idea.
import os
os.environ["REQUESTS_CA_BUNDLE"] = "cacert.pem"
All in all, it's not too complicated, but that's a list of steps to keep in mind.
The text was updated successfully, but these errors were encountered:
We need to create a section in our documentation about "freezing" Python-Redmine using cxFreeze, PyInstaller, py2exe etc. Thanks to @vlegoff we already have a nice explanation about how to do this for cxFreeze:
There are two obstacles to using python-redmine with cxFreeze. Both can be fixed.
The redmine.resources module isn't automatically exported by cxFreeze when freezing the program, for some reason.
The requests package used by python-redmine needs an additional file with permissions.
The first problem will raise a ResourceError when trying to load any manager, due to the dynamic import in managers.py. This fails, because redmine.resources isn't placed in the library.zip created by cxFreeze. It's just a matter of telling it to do so:
setup(
name = "...",
version = "0.1",
description = "...",
options = {'build_exe': {
"packages": ["redmine.resources"],
}},
executables = [...],
)
That's it.
The second problem is a bit more annoying. The 'requests' package needs the 'cacert.pem' file, but if I understood correctly, it tries to load it from a location that is no longer valid when cxFreeze freezes the program. The solution is to include 'cacert.pem' in the setup.py script (I personally copied it right into my repository, though I don't share it, the original cacert.pem was in C:\PythonXX\Lib\site-packages\requests on Windows). When the file is copied, you need to include it as a static file in your setup.py script.
setup(
name = "...",
version = "0.1",
description = "...",
options = {'build_exe': {
"include_files": ["cacert.pem"],
"packages": ["redmine.resources"],
}},
executables = [...],
)
But that's not enough, because requests still looks for the file in an invalid location. Next thing is to tell it where to look for the file (the current directory in our case). It must be done in the code, somewhere, a place where you know requests will be called is a good idea.
import os
os.environ["REQUESTS_CA_BUNDLE"] = "cacert.pem"
All in all, it's not too complicated, but that's a list of steps to keep in mind.
The text was updated successfully, but these errors were encountered: