Skip to main content

No project description provided

Project description

pymaketool

pymaketool is an elegant and simple tool to build and manage large C/C++ projects and libraries. The main purpose is to simplify the build process by using Python to find and organize source files.

Quick Start

Install required packages:

Ubuntu

$ sudo apt-get install -y gcc make python3 python3-pip python3-gi python3-gi-cairo gir1.2-gtk-3.0 git time zip

Fedora

$ sudo dnf install python3 python3-pip python3-gobject gtk3 time zip git gcc

Arch Linux

$ sudo pacman -S gcc make python python-pip python-gobject gtk3 time zip git 

Install pymaketool:

$ pip3 install pymaketool 

Quick Start with Poetry

If you prefer using Poetry for dependency management, you can set up your C project as a Poetry project:

Install Poetry

$ curl -sSL https://install.python-poetry.org | python3 -

Create a new C project with Poetry

$ pynewproject CLinuxGCC
  (author) Your name: Ericson
  (project_name) Your project name: hello

$ cd hello

# Initialize Poetry in your project
hello$ poetry init --name hello --dependency pymaketool

# Install dependencies
hello$ poetry install

Build using Poetry

# Clean the project
hello$ poetry run make clean

# Build the project
hello$ poetry run make

# Run the executable
hello$ ./Release/hello

Example pyproject.toml for a C project

[project]
name = "hello"
version = "0.1.0"
description = "My C project using pymaketool"
authors = [{ name = "Your Name", email = "your@email.com" }]
requires-python = ">=3.10"
dependencies = ["pymaketool"]

[build-system]
requires = ["poetry-core>=2.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.scripts]
build = "subprocess:run"

Using Poetry ensures consistent Python environments across different machines and simplifies dependency management for your build tools.

Create new basic C project.

$ pynewproject CLinuxGCC
  (author) Your name: Ericson
  (project_name) Your project name: hello

$ cd hello

hello$ make clean

hello$ make

hello$ ./Release/hello

Note: This example uses EclipseAddon by default; pymaketool generates the files .settings/language.settings.xml and .cproject.

Quick start in Docker

Pull the image and run a container:

$ docker pull ericsonjoseph/pymaketool

$ docker run -it ericsonjoseph/pymaketool

ubuntu@$ pynewproject CLinuxGCC

Quick Info

pymaketool processes code modules as objects. These objects are defined by files ending with _mk.py. With Python, you can write code to discover and retrieve source files and include paths, e.g.:

# File app_mk.py

from pymakelib import module

@module.ModuleClass
class App(module.AbstractModule):

    def getSrcs(self):
        # Get all .c source files in the current folder ./app/
        # Returns e.g.: [ 'app/app.c' ]
        return self.getAllSrcsC() 

    def getIncs(self):
        # Get all include paths in the current folder ./app/
        # Returns e.g.: [ 'app' ]
        return self.getAllIncsC()

The file app_mk.py can be shorter and simpler, e.g.:

# File app_mk.py

from pymakelib import module

# BasicCModule inherits from AbstractModule and implements getSrcs and getIncs.
@module.ModuleClass
class App(module.BasicCModule):
    pass

The file app_mk.py in raw style:

# File app_mk.py

from pymakelib import module

@module.ModuleClass
class App():
    
    def getSrcs(self):
        return [
            'app/app.c'
        ]

    def getIncs(self):
        return [
            'app'
        ]
    

Remote modules can be loaded as static libraries with custom compiler flags, e.g.:

# File extlib_mk.py

from pymakelib import module

@module.ModuleClass
class ExtLib(module.ExternalModule):
    
    def init(self):
        # Compile modulelib as a static library (Optional)
        return module.StaticLibrary("modulelib", "Release", rebuild=True)
     
    def getModulePath(self)->str:
        # Location of module
        return '/LIBS/module_lib/module_lib_mk.py'


    def getCompilerOpts(self):
        # Override method and set special compiler flags (Optional)
        opts = project.getCompilerOpts()
        opts['CONTROL-C-OPTS'] = ['-std=c99']
        return opts
    

For install guide go to install-guide

For more documentation go to Read the Docs

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymaketool-3.0.0rc2.tar.gz (191.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pymaketool-3.0.0rc2-py3-none-any.whl (222.6 kB view details)

Uploaded Python 3

File details

Details for the file pymaketool-3.0.0rc2.tar.gz.

File metadata

  • Download URL: pymaketool-3.0.0rc2.tar.gz
  • Upload date:
  • Size: 191.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.3 CPython/3.14.3 Linux/6.17.0-1010-azure

File hashes

Hashes for pymaketool-3.0.0rc2.tar.gz
Algorithm Hash digest
SHA256 a9f864cee2e7738a107d6aa0a131cd6d2aa0767aa0be6e6004327fa83f7e3376
MD5 e6e70b04697d8cc1bc2881ddcf935db4
BLAKE2b-256 8745179de18724020001be7b2e6356250ceed990c1ddacc4185262c9674dfbce

See more details on using hashes here.

File details

Details for the file pymaketool-3.0.0rc2-py3-none-any.whl.

File metadata

  • Download URL: pymaketool-3.0.0rc2-py3-none-any.whl
  • Upload date:
  • Size: 222.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.3 CPython/3.14.3 Linux/6.17.0-1010-azure

File hashes

Hashes for pymaketool-3.0.0rc2-py3-none-any.whl
Algorithm Hash digest
SHA256 ebb0d9c112fd230bb6fac0fbde9ce77437c3b88b21f2e108d6efb0403a76ceb2
MD5 5e27992c3b2698feb5983a557720adeb
BLAKE2b-256 f8c21e9b9c7b8dd450f2e71e29196585168b7285885f101443a39a382e889662

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page