Skip to main content

pycompile

"""                                        _ _
    _ __  _   _  ___ ___  _ __ ___  _ __ (_) | ___
   | '_ \| | | |/ __/ _ \| '_ ` _ \| '_ \| | |/ _ \
   | |_) | |_| | (_| (_) | | | | | | |_) | | |  __/
   | .__/ \__, |\___\___/|_| |_| |_| .__/|_|_|\___|
   |_|    |___/                    |_|
   
"""

A CLI tool for compiling python source code using Cython or Nuitka.

PyPI PyPI - Downloads PyPI - License Tests Code Style PyPI - Implementation

Latest docs 📝

here

Table of contents

  1. Installation 🔨
  2. Compile
  3. Benchmark
  4. [Dry run](#dry run)
  5. Local-development 💻🏭

Installation

pip install pycompile

Compile

Usage: pycompile compile [OPTIONS]

  Compile the python files using `cython` or `nuitka`.

Options:
  -i, --input-path PATH           Specify the file/folder input path, by
                                  default it will exclude any `test` and
                                  `__init__.py` files  [required]
  -ex, --exclude-glob-paths TEXT  glob files patterns of the files to be
                                  excluded, example: **/ignore_this_module.py
  -v, --verbose                   verbose level
  -e, --engine [cython|nuitka]    CompilerWrapper to be used, defaults to:
                                  `cython`
  -cs, --clean-source             Clean source (.py) files
  -kb, --keep-builds              Keep temporary build files
  -ce, --clean-executables        Clean final executables (.so) files
  --help                          Show this message and exit.
pycompile compile -i your_python_files --clean-source --engine nuitka 

cython_compile.gif or

After the compilation the input dir will have the following structure.

examples
    ├── fib.py.py                           
    ├── fib.cpython-310-darwin.so                      
    ├── test_fib.py                   

Benchmark

Usage: pycompile benchmark [OPTIONS]

  Run a memory and cpu benchmark.

Options:
  -i, --input-path PATH           Specify the file/folder input path
                                  [required]
  -e, --engine [cython|nuitka|both|none]
                                  compiler wrapper(s) to be used for the
                                  benchmark, defaults to `both`.
  -t, --type [memory|cpu|both]    type of benchmark to execute, defaults to
                                  `both`.
  -p, --profile_func_pattern TEXT
                                  function name pattern for profiling,
                                  defaults to `benchmark`. All the functions
                                  with a name that matches this pattern will
                                  be decorated with `@profile` from: `memory-
                                  profiler`, in addition their module needs to
                                  follow  the pattern
                                  (`something_prof_func_name.py` to be
                                  excluded from compilation).
  -v, --verbose                   verbose level
  --help                          Show this message and exit.

It starts a memory and a cpu benchmark, starting with

  • python,
  • cython and,
  • nuitka
pycompile benchmark -i src/examples -vvv

benchmark_cython_python.gif

The following structure is required for the benchmark subcommand.

 module
    ├── sample_funcs.py                        # implementation
    ├── main.py                                # entrypoint with a `main` function, during compilation will be excluded
    ├── test_sample_funcs.py                   # test cases

dry run

pycompile dry_run -i ./src

dry_run.gif

Local-development

For local development run the following command

make setup-local-dev

All available make commands

make help

Metadata

Release files for pycompile 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pycompile 0.2.3
File Size Uploaded Provenance Actions
pycompile-0.2.3.tar.gz 12.4 kB Without provenance Details for pycompile-0.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pycompile 0.2.3
File Interpreter ABI Platform Actions
pycompile-0.2.3-py3-none-any.whl Python 3 none any Details for pycompile-0.2.3-py3-none-any.whl

Total release size: 27.8 kB

Release files / pycompile-0.2.3.tar.gz

Download URL pycompile-0.2.3.tar.gz
Size 12.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8971604e17cdab2cae8fab954cd4ba40d5db1125de8eaf9c75fa755d66a77ae3
BLAKE2b-256 checksum
How to use checksums
aa4a7739feab96fdbe37c3d5497a9b874cca2b7bbb33b42403000831d7077d66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.4 CPython/3.10.9 Linux/6.5.0-1025-azure

Release files / pycompile-0.2.3-py3-none-any.whl

Download URL pycompile-0.2.3-py3-none-any.whl
Size 15.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aaea0d7614b7a13f1944c314e0c08dddf0d748ebbf5d19303357398214e070ba
BLAKE2b-256 checksum
How to use checksums
5ef5f9ecb7244e99b67f970a658b4b1ea8850399908dac93a14cfa96ca06c35f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.4 CPython/3.10.9 Linux/6.5.0-1025-azure

Security for pycompile 0.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page