GithubHelp home page GithubHelp logo

compileall2's Introduction

compileall2's People

Contributors

ammaraskar avatar blueyed avatar encukou avatar ffy00 avatar frenzymadness avatar gpshead avatar hetmankp avatar hroncok avatar jellezijlstra avatar methane avatar paulproteus avatar pitrou avatar stefanhoelzl avatar vishalpandeynits avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

compileall2's Issues

--exclude option with regex path

brp-python-bytecompile has exclude option with path regex:

https://github.com/rpm-software-management/rpm/blob/master/scripts/brp-python-bytecompile

It uses this regex not to compile stuff in some dirs:

"/bin/|/sbin/|/usr/lib(64)?/python[0-9]\.[0-9]|/usr/share/doc"

In order to be able to use compileall2 in brp-python-bytecompile, it needs to gain support for exclude option. It can either support regular expressions or repeated file globs.

I suppose for us it will be more convenient to check the excluded paths after the -s and -a options are applied.

Python 3.4 doesn't produce optimzied bytecode

$ mkdir empty
$ echo '0' > empty/zero.py
$ python3.4 -m compileall2 -o 0 -o 1 -o 2 empty/
Listing 'empty/'...
Compiling 'empty/zero.py'...
$ ls empty/__pycache__/
zero.cpython-34.pyc
$ rm empty/__pycache__/ -rf
$ python3.5 -m compileall2 -o 0 -o 1 -o 2 empty/
Listing 'empty/'...
Compiling 'empty/zero.py'...
$ ls empty/__pycache__/
zero.cpython-35.opt-1.pyc  zero.cpython-35.opt-2.pyc  zero.cpython-35.pyc

Note that 3.4 was the last version with .pyo files and the results should include __pycache__/zero.cpython-34.pyo.

Should append be prepend?

"append" option makes me think the path goes at the end. Here it puts the path in front. Should it be called "prepend"?

RFE: Option to hardlink duplicate bytecache files of different opt. levels

I'd like to have and option of compileall that deduplicates identical .pyc files of the same module if compiled for different optimization levels.

Example:

$ python -m compileall -o0 -o1 -o2 --hardlink-dupes ...

This would hardlink module.cpython-3?.pyc with module.cpython-3?.opt-1.pyc with module.cpython-3?.opt-1.pyc if identical, on operating systems supporting hardlinks.

Given the nature of the bytecode caches, the non-optimized, optimized level 1 and optimized level 2 .pyc files may or may not be identical.

Consider the following Python module:

1

All three bytecode cache files would by identical.

While with:

assert 1

Only the two optimized cache files would be identical with each other.

And this:

"""Dummy module docstring"""
1

Would produce two identical bytecode cache files but the opt-2 file would differ.

Only modules like this would produce 3 different files:

"""Dummy module docstring"""
assert 1

Hardlinking identical .pyc files can cause significant storage savings. As a single data point: On my workstation I have 360 MiB of various Python 3.7 bytecode files in /usr and I can save 108 MiB.

If the .pyc file can't be written, compileall2 fails silently

During testing upstream, it was found that py_compile, and thus compileall, silently skips writing .pyc files it can't write (because of path size limits; probably also because of permissions etc.).

For Fedora, it would make sense to fail with an exception (or error exit code). It should probably be an option โ€“ not everyone will want it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.