Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot build with platformio 5 #69

Open
pipppy1 opened this issue Jan 10, 2021 · 2 comments
Open

cannot build with platformio 5 #69

pipppy1 opened this issue Jan 10, 2021 · 2 comments

Comments

@pipppy1
Copy link

pipppy1 commented Jan 10, 2021

Hi puuu
when building with platformio 5
fw_version.py gives error :ModuleNotFoundError: No module named 'platformio.managers.lib':
it works in pio 4 but not pio 5
plase can you help
with thanks phill

@G-Tarik
Copy link

G-Tarik commented Feb 15, 2025

This is due to deprecation in paltformio. Rewriting fw_version.py as below helps:

"""MQTT433gateway git firmware version extractor

Project home: https://github.com/puuu/MQTT433gateway/
"""
import subprocess
import json
import platformio
from platformio.package.manager.library import LibraryPackageManager
from platformio.package.manager.platform import PlatformPackageManager
Import("env")

OUTFILE = "dist/version_build.h"
TEMPLATE = """
static const char PROGMEM fw_version[] = "{version:s}";
static const char PROGMEM fw_build_with[] = "{build_with:s}";
"""
CHARS_TO_ESCAPE = ('\\', '"')


def get_fw_version():
    try:
        return subprocess.check_output(['git', 'describe', '--abbrev=8', '--dirty',
                                        '--always', '--tags']).strip().decode()
    except (subprocess.CalledProcessError, OSError):
        return "unknown"


def get_dependencies():
    lib_mgr = LibraryPackageManager()
    platform_mgr = PlatformPackageManager()

    # Get installed libraries
    dependencies = {
        pkg.metadata.name: pkg.metadata.version
        for pkg in lib_mgr.get_installed()
    }

    # Get platform information
    platform = env['PIOPLATFORM']
    dependencies[platform] = str(platform_mgr.get_installed()[0].metadata.version)
    dependencies['PlatformIO'] = platformio.__version__

    return dependencies


def get_dependencies_json():
    return json.dumps(get_dependencies(), separators=(',', ':'), sort_keys=True)


def escape_string(text, escape_chars=CHARS_TO_ESCAPE):
    for char in escape_chars:
        text = text.replace(char, '\\' + char)
    return text


def generate_file():
    with open(OUTFILE, 'w') as f:
        f.write(TEMPLATE.format(version=escape_string(get_fw_version()),
                                build_with=escape_string(get_dependencies_json())))


generate_file()

@G-Tarik
Copy link

G-Tarik commented Feb 15, 2025

apparently this project as well as https://github.com/puuu/ESPiLight and https://pilight.org/ are all dead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants