Consider option for disabling .pyc generation #68

Closed
brejoc opened this Issue Jun 7, 2013 · 9 comments

Projects

None yet

3 participants

@brejoc
brejoc commented Jun 7, 2013

Might be nicer of invoke to not generate a tasks.pyc.

@bitprophet
Member

Can you provide a specific example of how this is problematic? We have to import/run tasks.py at some point, which is what generates the pyc.

Also not sure if one CAN tell Python not to bytecode-compile at runtime, I'm mostly used to the Python interpreter option like PYTHONDONTWRITEBYTECODE.

@brejoc
brejoc commented Jun 25, 2013

I wouldn't go so far to call it problematic. I just think it's not nice of an build tool to save some of its own meta data (I know it's not meta data, but let's just pretend it is) persistently in the folder it just happens to be. Call me anal, but I would prefer to have a clean project/build folder.
Some projects managed with invoke might not be python projects and developers might wonder where this pyc file is coming from and whether they have to add it to the repository or should better put it on the ignore list.

But still - this is not really an issue.

You can prevent Python from generating pyc files with the following two lines in /usr/bin/invoke:

import sys 
sys.dont_write_bytecode = True

This has the downside of not generating pyc files at all. So there is no speed improvement with the second execution. It might be possible to insert this a bit later but I didn't try it, since invoke is pretty fast.

@bitprophet
Member

I forgot all about the sys. angle - thanks. I understand your argument and right now I'm +0 on it - given pyc compilation is intended to help with speed, it's not critical for Invoke's use case. In an average use case I'd expect bytecode compilation time to be dwarfed by the runtime of the subcommands the user is triggering.

If you have time to add this as an option (so advanced users who do have a "care about speed" use case have an 'out') I'd merge it. Thanks!

@brejoc
brejoc commented Jul 11, 2013

Okay, I'll take care of this in the next few weeks. I've got a dealine ahead, so this will have to wait a few days.

@bitprophet
Member

Sure, no rush on my part, I've had to let my OSS slide real bad lately myself :( Thanks!

@bitprophet bitprophet added the Feature label Aug 25, 2014
@bitprophet bitprophet changed the title from tasks.pyc pollute pwd to Consider option for disabling .pyc generation Aug 25, 2014
@brutus
brutus commented Apr 11, 2015

This sounds pretty neat. What's the state of it and ea93218?

@bitprophet
Member

Is that commit part of an actual PR somewhere? If it is, github's not telling me. @brutus

@brutus
brutus commented May 5, 2015

I just tired it again here: brutus@e424074 and it still works for me.

Just had a quick look though. The tests run fine, expect core_help_option_prints_core_help that fails on the additional --write-pyc option in the help output as expected, but I handled that in my no-pyc branch.

@bitprophet bitprophet added a commit that referenced this issue Jan 13, 2016
@bitprophet bitprophet Implement #68 + tests
Went a more direct route than #244 since it was more test-friendly.
Turned out to be less code too, not like it matters here...
2824ddc
@bitprophet bitprophet added a commit that referenced this issue Jan 13, 2016
@bitprophet bitprophet Changelog re #68, re #244 b3f2853
@bitprophet
Member

Implemented, finally. Thanks again @brutus & @brejoc!

@bitprophet bitprophet closed this Jan 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment