lextab yacctab not included with cx_freeze

Issue #392 resolved
René Dudfield
created an issue

These two files from pycparser are not included with programs built with cx_freeze.

The problem is on windows, it then tries to create the files in the current directory... which is often not permitted.

Comments (8)

  1. Armin Rigo

    As far as I know, there is nothing cffi can do for that. If I missed a way to officially declare the existence of these two files, so that packagers will automatically include them, then please reopen...

  2. René Dudfield reporter

    Sorry for the noise. Probably once my fix gets merged into cx_freeze, this won't be a problem.

    So... I looked into it a bit more.

    I'm not sure what particular packaging magic is required to ensure those files are included. And it's probably a pycparser issue. I'm also not sure if it's only a cx_freeze related issue, or if it affects other packaging tools.

    A work around might be to explicitly import the two files inside cffi (untested). Then any dependency scanning code has more of a chance to pick them up. It looks like yacctab is imported using some magic somewhere inside pycparser/ply/yacc.py dynamically with exec().

    import pycparser.lextab
    import pycparser.yacctab

    Or perhaps pycparser could be changed so that if there is no permission to write the file in the current folder that it retries in a temp folder. Or it could use the import machinery more directly for that development workflow rather than using exec.

    Importing those files in cffi is probably the easiest workaround.

    For any internet travellers that wander in on this there is a work around you can use in your setup.py... https://github.com/pygame/stuntcat/pull/53/commits/1f825cff6b29b364a47af9fea32f34cc1d124f3d

  3. René Dudfield reporter

    A related PR for a cffi using package 'pymunk'. https://github.com/viblo/pymunk/pull/152

        import pycparser.lextab
        import pycparser.yacctab

    It's quite likely cffi will work with other "module scanning" packaging tools as well because of this. Because pycparser imports those files dynamically with exec() weirdness rather than using import. Tools which scan the package statically for dependencies do not find these imports.

    I'd suggest cffi include this somewhere so all other cffi using packages will work with tools like cx_Freeze than scan for dependencies dynamically.

  4. Log in to comment