flatpak-builder icon indicating copy to clipboard operation
flatpak-builder copied to clipboard

Cleanup not removing __pycache__ created by other modules

Open santiagocezar opened this issue 2 years ago • 6 comments

Checklist

  • [X] I agree to follow the Code of Conduct that this project adheres to.
  • [X] I have searched the issue tracker for a bug that matches the one I want to file, without success.

flatpak-builder version

1.2.2

Flatpak version

1.12.7

How to reproduce

  1. Add a python build tool module (e.g. blueprint-compiler) with a cleanup file list
  2. Run the build tool when compiling the next module

Expected Behavior

__pycache__ files should be deleted during cleanup

Actual Behavior

__pycache__ are kept after cleanup (because they were generated by other module)

Additional Information

I can workaround this by adding /share/blueprint-compiler in the cleanup list of the other module, but it'd be nice if it's done automatically

santiagocezar avatar Aug 21 '22 15:08 santiagocezar

I believe flatpak-builder has no built-in cleanup rules. It just executes and cleanups what you tell it to. So I think the responsibility just falls on the user.

TingPing avatar Aug 21 '22 15:08 TingPing

I think I'd recommend setting the PYTHONDONTWRITEBYTECODE=1 env var.

TingPing avatar Aug 21 '22 15:08 TingPing

I guess that would slow down some builds if they run the build tool per file, but it's not a bad solution.

I don't know what else could be done, other than maybe adding to documentation something like "don't forget to delete your __pycache__ files!"

santiagocezar avatar Aug 21 '22 16:08 santiagocezar

In general it's expected behaviour Python bytecode is kept in apps and runtimes. When timestamp-based, timestamp is rewritten and where hash-based, they are left alone. There is significant app startup impact when Python bytecode is not present. Whether user-written cleanup rules are working as expected is another question.

nanonyme avatar Feb 24 '24 21:02 nanonyme

@nanonyme There are two separate concerns:

  • python running during build time shouldn't leave behind data
  • python code you ship to the end user would be manually compiled ahead of time

TingPing avatar Feb 24 '24 21:02 TingPing

Normally if you do the "Add a python build tool module (e.g. blueprint-compiler) with a cleanup file list" step with pip (which I would suggest using since pypa/build and pypa/install aren't shipped as part of runtime), then this step would already build the bytecode. In this case __pycache__ is not created as part of 2 but 1. I'm here assuming this is about files in /app but of course I might be wrong.

nanonyme avatar Feb 24 '24 21:02 nanonyme