trailofbits / polyfile

A pure Python cleanroom implementation of libmagic, with instrumented parsing from Kaitai struct and an interactive hex viewer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build of 0.3.3 fails with `TypeError: '>' not supported between instances of 'NoneType' and 'float'`

dkasak opened this issue · comments

Downloading https://github.com/trailofbits/polyfile/archive/refs/tags/v0.3.3.tar.gz and building yields an error.

❯ python setup.py build

Traceback (most recent call last):
  File "/home/dkasak/code/dkasak/packages/aur_packages/polyfile/src/polyfile-0.3.3/setup.py", line 47, in <module>
    if not MANIFEST_PATH.exists() or newest_definition > MANIFEST_PATH.stat().st_mtime:
TypeError: '>' not supported between instances of 'NoneType' and 'float'

Looking at setup.py, the cause is here

# see if any of the files are out of date and need to be recompiled
newest_definition: Optional[float] = None
for definition in KAITAI_FORMAT_LIBRARY.glob("**/*.ksy"):
    mtime = definition.stat().st_mtime
    if newest_definition is None or newest_definition < mtime:
        newest_definition = mtime

It turns out that the KAITAI_FORMAT_LIBRARY: Path = POLYFILE_DIR / "kaitai_struct_formats" dir is empty so the above loop never gets executed and newest_definition remains None:

❯ ls -l kaitai_struct_formats
total 0

Hi dkasak,
Thanks for reaching out! I verified myself that I cannot download the v0.3.3.tar.gz and build according to your description. The error I see is different, it indicates that I am not able to fetch git submodules (one of them being kaitai_struct_formats). I believe this is the root cause of the problem.

One option is to clone the repo for this release using the following command

git clone --branch v0.3.3 https://github.com/trailofbits/polyfile.git

When I run

python3 setup.py build

it works. Hope this helps.