| [ Web Proxy ] |
| Viewing: https://wiki.python.org/moin/../python/platforms/../../jython/../python/guides/HowTo/FileMagic.html | [Back] [Original] |
Legacy Wiki Page
This page was migrated from the old MoinMoin-based wiki. Information may be outdated or no longer applicable. For current documentation, see python.org.
Today == Saturday, October 25, 2008
With special thanks for many of The Keys to frank and his blog. Also, an IBM article on setuptools had the info that helped me (at least) install setuptools without easy_install. (Necessary Today for Py v2.6; see below.)
I tried with Python v2.6, but could not get it to work; Im still not familiar with the magic of eggs, distutils, setuptools, etc. If anyone has the fix(es), let me know and Ill retest, revise, and update this info! (FYI: The problem is its acting as if it cant find magic1.dll; if v2.6 is uninstalled, v2.5[.2] is [re-]installed, all works A-OK.)
This is my NON-PRISTINE copy of SWIG-able python-magic, unless/until Mr. Hupp re-posts it to his site (see below): LARZ-python-magic-v0.1-c112ac064b7f.zip
NOTE: Mr. Hupp is working on a newer version; thus, all of this may become depreciated
This is what I did. It works on (32-bit) Windows XP Pro, SP3, on an old Athlon system with <=512MB.
As they say: Your Mileage May Vary
-Larry Hale (pythonlarry ta gmail)
version 2.573.2.3
May setup with all default settings, except MUST ADD
Devel (group)
gcc (3.4.4-3)
gcc-core (3.4.4-3) (should auto-select)
gcc-g++ (3.4.4-3) (should auto-select)
gcc-mingw (20040810-1)
gcc-mingw-core (20050522-1) (should auto-select)
gcc-mingw-g++ (20080522-1) (should auto-select)
make (3.81-2)
SWIG (1.3.36-1)
version 4.26 (more recent than what was available via CygWin Today)
http://gnuwin32.sourceforge.net/packages/file.htm
http://downloads.sourceforge.net/gnuwin32/file-4.26-setup.exe
May setup with defaults, except (I recommend) change install directory from
GnuWin32\File
to simply
File
NOTE: Its already set to install below Program Files
version 2.5.2
http://python.org/ftp/python/2.5.2/python-2.5.2.msi
Installed with all default settings EXCEPT install-to path
C:\Program Files\Python25
version 0.6c9
http://pypi.python.org/pypi/setuptools
As of Today there wasnt a pre-built .EXE installer for Python 2.6 (which Id TRIED to test with first, to no avail), SO had to hack a bit - see IBM article link, above, for some info simply grab
and run
python ez_setup.py
Otherwise, if an installer is avail for your ver of Py, use it!
version 0.1 (c112ac064b7f) with/for SWIG
http://hupp.org/adam/hg/python-magic
NOTE: Adam (Hupp) doesnt have the SWIG version posted any longer; my copy isnt pristine; anybody have one lying around to send me?
must have thiw file, with at least
{{{[build] compiler = mingw32}}}
Due to newer CygWin, change line 100 from
{{{version_re = re.compile(r^(\d+) . (\d+) (. (\d+))? ([ab](\d+))?$,
}}} to
{{{version_re = re.compile(r^(\d+) . (\d+) (. (\d+))? (. (\d+))?$,
}}}
Go to where youve put the python-magic source files, then:
{{{path=%PATH%;C:\Program Files\Python25;C:\cygwin\bin;C:\Program Files\File\bin
python setup.py install}}}
{{{Traceback (most recent call last):
File setup.py, line 1, in <module>
from setuptools import setup, Extension
ImportError: No module named setuptools}}}
{{{running install running bdist_egg running egg_info creating magic.egg-info writing magic.egg-info\PKG-INFO writing top-level names to magic.egg-info\top_level.txt writing dependency_links to magic.egg-info\dependency_links.txt writing manifest file magic.egg-info\SOURCES.txt reading manifest file magic.egg-info\SOURCES.txt writing manifest file magic.egg-info\SOURCES.txt installing library code to build\bdist.win32\egg running install_lib running build_py copying magic.py -> build\lib.win32-2.5 copying cmagic.py -> build\lib.win32-2.5 running build_ext error: Python was built with Visual Studio 2003; extensions must be built with a compiler than can generate compatible binaries. Visual Studio 2003 was not found on this system. If you have Cygwin installed, you can try compiling with MingW32, by passing -c mingw32 to setup.py.}}}
{{{running install running bdist_egg running egg_info writing magic.egg-info\PKG-INFO writing top-level names to magic.egg-info\top_level.txt writing dependency_links to magic.egg-info\dependency_links.txt reading manifest file magic.egg-info\SOURCES.txt writing manifest file magic.egg-info\SOURCES.txt installing library code to build\bdist.win32\egg running install_lib running build_py running build_ext Traceback (most recent call last):
File setup.py, line 12, in <module>
libraries=[magic])],
File C:\Program Files\Python25\lib\distutils\core.py, line 151, in setup
dist.run_commands()
File C:\Program Files\Python25\lib\distutils\dist.py, line 974, in run_commands
self.run_command(cmd)
File C:\Program Files\Python25\lib\distutils\dist.py, line 994, in run_command
cmd_obj.run()
File C:\Program Files\Python25\lib\site-packages\setuptools-0.6c9-py2.5.egg\setuptools\command\install.py, line 76, in run File C:\Program Files\Python25\lib\site-packages\setuptools-0.6c9-py2.5.egg\setuptools\command\install.py, line 96, in do_egg_install
etc., etc., etc.
File C:\Program Files\Python25\lib\distutils\version.py, line 107, in parse
raise ValueError, invalid version number %s % vstring
ValueError: invalid version number 2.18.50.20080625}}}
{{{running install running bdist_egg running egg_info writing magic.egg-info\PKG-INFO writing top-level names to magic.egg-info\top_level.txt writing dependency_links to magic.egg-info\dependency_links.txt reading manifest file magic.egg-info\SOURCES.txt writing manifest file magic.egg-info\SOURCES.txt installing library code to build\bdist.win32\egg running install_lib running build_py running build_ext creating build\bdist.win32 creating build\bdist.win32\egg copying build\lib.win32-2.5\cmagic.py -> build\bdist.win32\egg copying build\lib.win32-2.5\magic.py -> build\bdist.win32\egg copying build\lib.win32-2.5\_cmagic.pyd -> build\bdist.win32\egg byte-compiling build\bdist.win32\egg\cmagic.py to cmagic.pyc byte-compiling build\bdist.win32\egg\magic.py to magic.pyc creating stub loader for _cmagic.pyd byte-compiling build\bdist.win32\egg\_cmagic.py to _cmagic.pyc creating build\bdist.win32\egg\EGG-INFO copying magic.egg-info\PKG-INFO -> build\bdist.win32\egg\EGG-INFO copying magic.egg-info\SOURCES.txt -> build\bdist.win32\egg\EGG-INFO copying magic.egg-info\dependency_links.txt -> build\bdist.win32\egg\EGG-INFO copying magic.egg-info\top_level.txt -> build\bdist.win32\egg\EGG-INFO writing build\bdist.win32\egg\EGG-INFO\native_libs.txt zip_safe flag not set; analyzing archive contents creating dist creating dist\magic-0.1-py2.5-win32.egg and adding build\bdist.win32\egg to it removing build\bdist.win32\egg (and everything under it) Processing magic-0.1-py2.5-win32.egg Removing c:\program files\python25\lib\site-packages\magic-0.1-py2.5-win32.egg Copying magic-0.1-py2.5-win32.egg to c:\program files\python25\lib\site-packages magic 0.1 is already the active version in easy-install.pth
Installed c:\program files\python25\lib\site-packages\magic-0.1-py2.5-win32.egg Processing dependencies for magic==0.1 Finished processing dependencies for magic==0.1}}}
NOTE: Actually, this is what youll see if youve successfully RE-compiled but I digress
{{{Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. >>> import magic}}}
FIRST: Windows msgbox with red-X icon and [OK] button:
TITLE: python.exe - Unable To Locate Component
TEXT: This application has failed to start because magic1.dll was not found. Re-installing the application may fix this problem.
THEN (back in interpreter): {{{Traceback (most recent call last):
File <stdin>, line 1, in <module> File build\bdist.win32\egg\magic.py, line 2, in <module> File build\bdist.win32\egg\cmagic.py, line 5, in <module> File build\bdist.win32\egg\_cmagic.py, line 7, in <module> File build\bdist.win32\egg\_cmagic.py, line 6, in [bootstrap]
ImportError: DLL load failed: The specified module could not be found.}}}
NOTE: This is the same exact message (inside interpreter, NOT a Windows msgbox) that shows when I tried to use Py v2.6.
{{{>>> import magic >>> test = magic.Magic() >>> test.from_file( \cygwin\bin\which.exe ) PE32 executable for MS Windows (console) Intel 80386 32-bit}}}
{{{>>> import magic >>> test = magic.Magic( magic_file = C:\magic ) # NOTE: This is the full path+filename of the magic db file >>> test.from_file( \startrek.exe ) MS-DOS executable, MZ for MS-DOS}}}
DEFAULT/ASSUMED LOCATION FOR MAGIC DATABASE FILES IS C:\ProgramFiles\File\share\file
NOTE: magic1.dll file MUST BE FINDABLE IN THE PATH!!!
Back to top2026, Python Software Foundation
Made with Sphinx and Shibuya theme.
| Web Proxy Viewer | New URL | Original Page |