schmir / bbfreeze Goto Github PK
View Code? Open in Web Editor NEWUNMAINTAINED
Home Page: http://pypi.python.org/pypi/bbfreeze/
UNMAINTAINED
Home Page: http://pypi.python.org/pypi/bbfreeze/
Ideally we should be able to distribute optimized code, a.k.a. PYO files instead of PYC files.
While freezing, a bunch of errors like these occur:
BFD: /dist/stPzWg8A: Not enough room for program headers, try linking with -N
strip:/dist/stPzWg8A: Bad value
However the generated binary seems to work anyway (at least for me).
This is not bbfreeze issue per se, but it's caused by NixOS/patchelf#10 -- I'm reporting it here just to let other people know.
Scripts named "prog.pyw" are supported by bdist_bbfreeze, but they currently wind up as an executable named "prog.pyw.exe". I've got a simple fix for this in my fork if you're interested (http://github.com/rfk/bbfreeze)
A recent upgrade to something (setuptools or distutils) means that setup.py is also creating a .exe.manifest with the script .exe file that bdist_bbfreeze then attempts to compile. The file is an xml file.
The following patch amends bdist_bbfreeze to only attempt compile of scripts ending in .py or .pyw.
--- bdist_bbfreeze.py.1 2009-12-18 10:17:12.339250000 +0000 +++ bdist_bbfreeze.py 2010-01-03 11:47:55.584832600 +0000 @@ -87,11 +87,13 @@ # freeze each of the scripts for args in get_script_args(dist, wininst=wininst): name = args[0] - if name.endswith('.exe'): - # skip .exes - continue - log.info('bbfreezing %s', os.path.join(self.script_dir, name)) - f.addScript(os.path.join(self.script_dir, name), - gui_only=name.endswith('.pyw')) + # only compile python scripts + # somewhere we have aquired a .exe.manifest + fullname = os.path.join(self.script_dir, name) + if os.path.splitext(name)[1] in ['.py', '.pyw']: + log.info('bbfreezing %s', fullname) + f.addScript(fullname, gui_only=name.endswith('.pyw')) + else: + log.info('bbfreezing skipping %s', fullname) # starts the freezing process f()
Running with python 2.7 from python.org on Mac OS 10.6 I get the following error packing a simple "Hello, world!" script.
$ cat test.py
print "Hello, world!"
$ bb-freeze test.py
*** applied <function recipe_doctest at 0x101218938>
*** applied <function recipe_time at 0x101218c80>
Traceback (most recent call last):
File "/usr/local/bin/bb-freeze", line 9, in <module>
load_entry_point('bbfreeze==0.97.3', 'console_scripts', 'bb-freeze')()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/bbfreeze-0.97.3-py2.7-macosx-10.6-intel.egg/bbfreeze/__init__.py", line 25, in main
f()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/bbfreeze-0.97.3-py2.7-macosx-10.6-intel.egg/bbfreeze/freezer.py", line 602, in __call__
self.finish_dist()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/bbfreeze-0.97.3-py2.7-macosx-10.6-intel.egg/bbfreeze/freezer.py", line 614, in finish_dist
m.run(contents="@executable_path/")
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/bbfreeze-0.97.3-py2.7-macosx-10.6-intel.egg/bbfreeze/macholib/MachOStandalone.py", line 101, in run
for fn in platfiles:
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/bbfreeze-0.97.3-py2.7-macosx-10.6-intel.egg/bbfreeze/macholib/util.py", line 227, in iter_platform_files
if is_platform_file(fn):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/bbfreeze-0.97.3-py2.7-macosx-10.6-intel.egg/bbfreeze/macholib/util.py", line 206, in is_platform_file
header = mach_o.fat_header.from_fileobj(fileobj, _endian_='>')
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/bbfreeze-0.97.3-py2.7-macosx-10.6-intel.egg/bbfreeze/macholib/ptypes.py", line 44, in from_fileobj
return cls.from_str(f.read(cls._size_), **kw)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/bbfreeze-0.97.3-py2.7-macosx-10.6-intel.egg/bbfreeze/macholib/ptypes.py", line 48, in from_str
return cls.from_tuple(struct.unpack(endian + cls._format_, s), **kw)
struct.error: unpack requires a string argument of length 8
When using bbfreeze in a buildout context, bbfreeze always favors the system32 dlls (python27.dll). If no python is installed, no dlls are found.
Proper fix would be to add the current python executable path as the first entry in the path list.
A lot of apps people make require resources (images/sounds/fonts/etc) which bbfreeze does not pick up automatically. There needs to be a way of specifying directories that will automatically be added to the library. Right now I have to open the zip after freezing and walk the folders manually adding files to the zip.
When I try to install bbfreeze on OS X, it fails:
cc -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -pipe -arch x86_64 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _bbfreeze_loader/console.c -o build/temp.macosx-10.9-intel-2.7/_bbfreeze_loader/console.o
clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
error: command 'cc' failed with exit status 1
As I understand, it happens only with a new version of XCode/clang:
> clang --version
Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix
It is still possible to install it using this command:
> ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future easy_install bbfreeze
But it will not be possible to do this in the future.
Is there any specific version that should work with bbfreeze? Cause the latest version (0.11) gives me error that compat
has been removed. Since this has been removed in 0.7.1 it's probably something else that's causing this but I'm not sure what (https://pypi.python.org/pypi/altgraph/0.7.1)
Traceback (most recent call last):
File "/Users/rick/envs/wifisd/bin/bbfreeze", line 7, in <module>
from bbfreeze import main
File "/Users/rick/envs/wifisd/lib/python2.7/site-packages/bbfreeze/__init__.py", line 8, in <module>
from bbfreeze.freezer import Freezer
File "/Users/rick/envs/wifisd/lib/python2.7/site-packages/bbfreeze/freezer.py", line 13, in <module>
from modulegraph import modulegraph
File "/Users/rick/envs/wifisd/lib/python2.7/site-packages/bbfreeze/modulegraph/modulegraph.py", line 24, in <module>
from altgraph.compat import *
ImportError: No module named compat
Versions:
On OS X
when i frozen a python test.py
import sys
print sys.exec_prefix
i have 2 answer for my way :
1 : python test.py :
/usr
2 : (after bbfreeze) dist/test
/
any one can help me
I've found this code to remove undistributable windows dlls on web2py setup file.
I believe they should be include on getdeps.py excludes set.
PS: I've managed to work around this manipulating getdeps.excludes before freezing
if remove_msft_dlls:
(...)
#then delete some other files belonging to Microsoft
other_ms_files = ['KERNELBASE.dll', 'MPR.dll', 'MSWSOCK.dll','POWRPROF.dll']
for f in other_ms_files:
try:
os.unlink(os.path.join('dist', f))
except:
(...)
source:
http://mdp.cti.depaul.edu/classwork/static/work/csc299/2013/web2py/extras/build_web2py/setup_exe.py
The following path fixes passing some necessary options to bbfreeze python interpreter py.py.
I had to modify also file load_console.py. Not sure if it is a proper fix but at least it works.
With this patch people can run the following command to run their pytest test suite with py.py interpreter:
py.test -d --tx popen//python=path_to_dist_folder/py
For more info see:
http://pytest.org/xdist.html?highlight=xdist#running-tests-in-a-python-subprocess
I am not sure if this is unique to PySide but when my PySide app gets frozen by bbfreeze the modulegraph pulls in the proper PySide.Qt_.so files but it fails to grab the deps of these files, libpyside_ and libshiboken*. I have to add something like the following to fix up my build:
def find_n_fix_missing(libs):
missing = []
for f in libs:
output = subprocess.Popen(['otool', '-XL', f], stdout=subprocess.PIPE).communicate()[0]
for line in output.splitlines():
libpath = line.strip().split(" ")[0]
if libpath != f and libpath[0] != "/" and libpath[0] != "@":
if not libpath in missing and not '.framework' in libpath:
missing.append(libpath)
shutil.copy(os.path.join('/usr/lib', libpath), libpath)
subprocess.Popen(['install_name_tool', '-change', libpath, "@executable_path/" + libpath, f])
if missing:
find_n_fix_missing(missing)
os.chdir(freezer.distdir)
find_n_fix_missing(glob.glob("*.so") + glob.glob("*.dylib"))
There is not docs on this topic, but it seems it's not supported.
When trying to use bbfreeze I get the following error:
File "/usr/local/lib/python2.7/dist-packages/bbfreeze-1.1.2-py2.7.egg/bbfreeze/freezer.py", line 590, in call
if not self._handleRecipes():
File "/usr/local/lib/python2.7/dist-packages/bbfreeze-1.1.2-py2.7.egg/bbfreeze/freezer.py", line 483, in _handleRecipes
if x(self.mf):
File "/usr/local/lib/python2.7/dist-packages/bbfreeze-1.1.2-py2.7.egg/bbfreeze/recipes.py", line 236, in recipe_matplotlib
mf.import_hook("matplotlib.numerix.random_array", m)
File "/usr/local/lib/python2.7/dist-packages/bbfreeze-1.1.2-py2.7.egg/bbfreeze/modulegraph/modulegraph.py", line 257, in import_hook
m = self.load_tail(q, tail)
File "/usr/local/lib/python2.7/dist-packages/bbfreeze-1.1.2-py2.7.egg/bbfreeze/modulegraph/modulegraph.py", line 341, in load_tail
raise ImportError, "No module named " + mname
ImportError: No module named matplotlib.numerix
It appears that there changes to matplotlib so that numerix can no longer be referenced in the way it currently is
I get the following error when running bbfreeze
on hello-world.py
file
bbfreeze hello-world.py
*** applied <function recipe_doctest at 0x10146c938>
*** applied <function recipe_time at 0x10146cc80>
*** applied <function recipe_urllib at 0x10146caa0>
Traceback (most recent call last):
File "/usr/local/bin/bbfreeze", line 9, in <module>
load_entry_point('bbfreeze==1.1.2', 'console_scripts', 'bbfreeze')()
File "/usr/local/lib/python2.7/site-packages/bbfreeze/__init__.py", line 24, in main
f()
File "/usr/local/lib/python2.7/site-packages/bbfreeze/freezer.py", line 640, in __call__
self.finish_dist()
File "/usr/local/lib/python2.7/site-packages/bbfreeze/freezer.py", line 649, in finish_dist
from macholib.MachOStandalone import MachOStandalone
File "/usr/local/lib/python2.7/site-packages/macholib/__init__.py", line 10, in <module>
__version__ = pkg_resources.require('macholib')[0].version
File "build/bdist.macosx-10.8-x86_64/egg/pkg_resources.py", line 673, in require
File "build/bdist.macosx-10.8-x86_64/egg/pkg_resources.py", line 580, in resolve
pkg_resources.VersionConflict: (altgraph 0.9 (/usr/local/lib/python2.7/site-packages), Requirement.parse('altgraph>=0.10'))
Running bbfreeze on Python 2.6.4 creates non-working distributions when using eggs.
Workaround:
manually include these modules in your includes arugment to Freezer:
distutils.dep_util
distutils.errors
distutils.log
distutils.spawn
distutils.sysconfig
distutils.text_file
distutils.util
Haven't been able to look, but i suspect this is related to the distutils StringType->str changes between 2.6.2 and python 2.6.4.
on linux , this seems to work:
from bbfreeze import Freezer
f = Freezer(includes=['PySide.QtGui',
'PySide.QtCore'])
f.addScript("mainwindow.pyw")
f()
but on windows, the following is required:
from bbfreeze import Freezer
f = Freezer(includes=['atexit',
'pkg_resources',
'PySide.QtGui',
'PySide.QtCore'])
f.addScript("mainwindow.pyw")
f()
I'm not familiar with recipes, but maybe this could be added as a recipe? Btw., I tested with bbfreeze 1.0.0 and pyside 1.1.0 on python 2.6
Like certifi
module has an extra .pem
file, and that file must be bundled along with the module.
It would be nice to redirect stdout/stderr to files (in the case of gui_only = True). This can be done in code, so it's not a high priority, but it would be a nice to have.
CONSOLE_LOG = "log/console.log"
if os.path.exists(CONSOLE_LOG) and os.path.isfile(CONSOLE_LOG):
utils.rolloverLog(CONSOLE_LOG)
stdoutfile = open(CONSOLE_LOG, "a")
sys.stdout = utils.Unbuffered(stdoutfile)
sys.stderr = sys.stdout
Hi,
I've been trying to get bbfreeze installed on Ubuntu 11.10 with little success. I have tried with various versions, including the latest version here on github.
When running the setup.py script I get the following output: http://pastebin.com/DzTj5SiC
I've seen this issue before and it was caused by the -lz flag for the linker. Hacking at setup.py to remove the -lz from the flags didn't seem to help though.
I use freeze script as folloing:
from bbfreeze import Freezer
f = Freezer("dist", includes=("cffi",), excludes=("_tkinter", "pyexpat"))
f.addScript("host_server.py")
f() # starts the freezing process
It generate dist files correctly, but file masks are like this:
-rwxr-xr-x. 1 q1 q1 37840 Feb 3 11:54 _struct.so
-rwxr-xr-x. 1 q1 q1 25160 Feb 3 11:54 termios.so
-rwxr-xr-x. 1 q1 q1 20328 Feb 3 11:54 time.so
On Linux, the privilege should set to 644, known as -rw-r--r--.
I have a python setup.py
# setup.py
from setuptools import setup, find_packages
setup(
name='print-workflow',
version='0.1.0',
author='Hogarth Worldwide',
author_email='[email protected]',
packages=find_packages('src', exclude=('tests',)),
package_dir={'': 'src'},
include_package_data=True,
install_requires=[
'celery',
'jinja2',
'setuptools',
],
license='PROPRIETARY',
entry_points={
'console_scripts': [
'print_workflow = print_workflow:main',
]
},
)
and run:
python setup.py bdist_bbfreeze
then I get:
$ ./print-workflow-0.1.0/print_workflow
Traceback (most recent call last):
File "<string>", line 6, in <module>
File "__main__.py", line 128, in <module>
File "__main__print_workflow__.py", line 9, in <module>
File "pkg_resources.py", line 356, in load_entry_point
File "pkg_resources.py", line 2438, in load_entry_point
ImportError: Entry point ('console_scripts', 'print_workflow') not found
Link to PyInstaller is broken on http://pypi.python.org/pypi/bbfreeze/ Others probably need a review too.
I'd like to have an option where bbfreeze creates py files instead of pyc. This simplifies many things.
Shipping pyc files makes sense in theory, but in practice there are many situations where you want the py files. For example today I wanted to run tests on a py2exe-packaged program. Py2exe packages only pyc file, and nose wouldn't agree to load tests from pyc files, so I couldn't run my tests.
I ended up monkeypatching nose to deal with pyc files, so that issue was resolved. But a few times it happened that I wanted to troubleshoot/debug a py2exe distribution, and it was impossible with the pyc files.
This is why I prefer py files.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.