KenKundert / psf_utils

Read Spectre PSF files
49 stars 14 forks source link

Preventing generation of parsetab.py and parser.out #6

Closed mswiggers closed 2 years ago

mswiggers commented 3 years ago

Hi Ken,

First of all a big thanks for the wonderful psf_utils module. It perfectly suits my needs.

I noticed some warnings coming from the PLY module, about the fact that it is unable to write a parsetab.py or a parser.out file (this has been addressed before in #1 ). Making this directory writeable is not an option in my case.

I think we might be able to prevent the generation of those files by passing write_tables = False, debug = False upon instantiation of lex and yacc like mentioned in this thread .

The relevant lines of code can be found here . Is it possible to make these arguments accessible to the user of psf_utils?

KenKundert commented 3 years ago

Ply writes the tables into the psf_utils source code repository. The fact that you cannot write to this directory suggests that you are using a version that was installed in shared location by someone else. However there is another option. You can install it into your home directory. Simply use:

    pip3 install --user psf-utils

That will install into ~/.local, which should always be writable by you. Alternately, you can have whoever is installing psf-utils into the shared location run psf-utils once. That will create the parsetab file. Once it exists there will be no further complains. I can modify psf-utils so that it no longer generates the parsetab file. I don't think recreating each time represents a significant burden. Or, I might upgrade to Sly, the next generation of Ply, in which case the whole issue goes away. My natural inclination would be to spend some time to determine the best course. However, if you need this right away let me know. I can turn off the file generation and check it in without too much work.

KenKundert commented 3 years ago

If you want the person installing your version of psf-utils to generate the parsetab file, they would need to run either list-psf or plot-psf in such a way that it runs the parser. This will not happen unless a PSF file without a cache is specified to the command. For example, assume they have an ASCII PSF file named noise.noise. Then they should run something like:

rm -f noise.noise.cache
list-psf -f noise.noise

They are successful if the following line is printed:

Generating LALR tables