openpreserve / jpylyzer

JP2 (JPEG 2000 Part 1) validator and properties extractor. Jpylyzer was specifically created to check that a JP2 file really conforms to the format's specifications. Additionally jpylyzer is able to extract technical characteristics.
http://jpylyzer.openpreservation.org/
Other
69 stars 28 forks source link

Linux build script and build instructions are out of date #99

Closed FoxKyong closed 6 years ago

FoxKyong commented 7 years ago

Hi, When I try to compile it on linux it fails. On windows it worked but on linux just ends with 'IndexError: tuple index out of range'.

216 INFO: PyInstaller: 3.2.1
216 INFO: Python: 3.6.0
217 INFO: Platform: Linux-4.10.2-1-ARCH-x86_64-with-arch
218 INFO: wrote /home/radim/jpylyzer/jpylyzer.spec
219 INFO: UPX is not available.
221 INFO: Extending PYTHONPATH with paths
['/home/radim/jpylyzer', '/home/radim/jpylyzer']
221 INFO: checking Analysis
221 INFO: Building Analysis because out00-Analysis.toc is non existent
221 INFO: Initializing module dependency graph...
278 INFO: Initializing module graph hooks...
312 INFO: Analyzing base_library.zip ...
Traceback (most recent call last):
  File "/usr/bin/pyinstaller", line 11, in <module>
    load_entry_point('PyInstaller==3.2.1', 'console_scripts', 'pyinstaller')()
  File "/usr/lib/python3.6/site-packages/PyInstaller/__main__.py", line 90, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "/usr/lib/python3.6/site-packages/PyInstaller/__main__.py", line 46, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "/usr/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 788, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "/usr/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 734, in build
    exec(text, spec_namespace)
  File "<string>", line 16, in <module>
  File "/usr/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 212, in __init__
    self.__postinit__()
  File "/usr/lib/python3.6/site-packages/PyInstaller/building/datastruct.py", line 161, in __postinit__
    self.assemble()
  File "/usr/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 317, in assemble
    excludes=self.excludes, user_hook_dirs=self.hookspath)
  File "/usr/lib/python3.6/site-packages/PyInstaller/depend/analysis.py", line 560, in initialize_modgraph
    graph.import_hook(m)
  File "/usr/lib/python3.6/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 1509, in import_hook
    source_package, target_module_partname, level)
  File "/usr/lib/python3.6/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 1661, in _find_head_package
    target_module_headname, target_package_name, source_package)
  File "/usr/lib/python3.6/site-packages/PyInstaller/depend/analysis.py", line 209, in _safe_import_module
    module_basename, module_name, parent_package)
  File "/usr/lib/python3.6/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 2077, in _safe_import_module
    module_name, file_handle, pathname, metadata)
  File "/usr/lib/python3.6/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 2167, in _load_module
    self._scan_code(m, co, co_ast)
  File "/usr/lib/python3.6/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 2585, in _scan_code
    module, module_code_object, is_scanning_imports=False)
  File "/usr/lib/python3.6/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 2831, in _scan_bytecode
    global_attr_name = get_operation_arg_name()
  File "/usr/lib/python3.6/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 2731, in get_operation_arg_name
    return module_code_object.co_names[co_names_index]
IndexError: tuple index out of range
bitsgalore commented 7 years ago

Hi,

Not 100% sure, but I suspect the build script is not compatible with Python 3.x (Python 3 support for PyInstaller was only added relatively recently, and I've only ran it with Python 2.7 so I'm not surprised this doesn't work).

I will look into this during the next development iteration (which may take while, but most likely this spring).

As a workaround you could try to build the binaries under Python 2.7.

FoxKyong commented 7 years ago

Thanks for the answer. I managed to compile it using older version of Python. But there is another problem now. Compilation has been done without any errors but if I try to run jpylyzer then I get:

Traceback (most recent call last):
  File "jpylyzer/jpylyzer.py", line 43, in <module>
ImportError: No module named config
Failed to execute script jpylyzer

I compiled it as written in BUILD_HOWTO_LINUX with: pyinstaller --onefile ./jpylyzer/jpylyzer.py and I used for compilation Python 2.7.9 and 3.5. Both compiled version of jpylyzer do the same error output.

bitsgalore commented 7 years ago

Oops, I'd completely forgotten about the BUILD_HOWTO_LINUX instructions, they're completely out of date (also I was assuming you were trying to build a Debian package, which is obviously not the case!).

Try this instead: go to the root directory of the jpylyzer repo and then run:

 ./build-with-pyinstaller.sh

Then try to run the jpylyzer binary that is created in the pyi-build/dist directory. I just tried this and it created a fully functional on my machine. Let me know if this doesn't work for you!

FoxKyong commented 7 years ago

I am using Arch linux and openSuse. I have already tried the script ./build-with-pyinstaller.sh but I got this: ./build-with-pyinstaller.sh: řádek 27: ./pyi-build/dist/jpylyzer: Adresář nebo soubor neexistuje (folder or file doesn't exist (I use czech language in console)).

bitsgalore commented 7 years ago

Hard to give any advice on this as it looks like some kind of platform-related issue. I don't know if this helps you at all, but one thing you could do is use Vagrant to set up a working virtual environment and use that for the builds. See e.g. the instructions I created here for creating Debian packages in this way:

https://github.com/openpreserve/jpylyzer/tree/master/vagrant

BUT that would result in packages for Ubuntu/Linux Mint, which may not be what you're looking at all?

Do you really need stand-alone binaries in the first place? I.e. your platform already has Python installed on it, so you could just run jpylyzer.py as a Python script?

bitsgalore commented 7 years ago

FWIW one of the things I'll do for the next development cycle is add support for pip install, which should eliminate the need for Linux binaries altogether.

FoxKyong commented 7 years ago

It is easier for my needs to use binary of it. But I have finally manage to run build-with-pyinstaller.sh. I was logged in as root and in the script there is comment that PyInstaller cannot be run as root which I overlooked and the code in if statetment of userid 0 is not working so that is the reason why the script didn't worked as root at all. I have tested the compiled jpylyzer and it works. Thanks for you help. There is just need to fix the if statement in the script if someone is trying to run it as root.

bitsgalore commented 7 years ago

Great to hear it worked in the end. I'll leave the issue open for now just to to remind me of looking at the build script & the outdated instructions.

bitsgalore commented 6 years ago

Updated build script & instructions: https://github.com/openpreserve/jpylyzer/commit/2ffe5a35cf47002d865bcddba6066b0eaa7257d8