Made assets (templates, "99-platformio-udev.rules") part of Python’s module // Resolve #4458

This commit is contained in:
Ivan Kravets
2022-11-18 19:51:19 +02:00
parent b35f1ea572
commit bf7fb15941
43 changed files with 25 additions and 17 deletions

View File

@ -17,6 +17,7 @@ PlatformIO Core 6
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
* Added support for Python 3.11 * Added support for Python 3.11
* Made assets (templates, ``99-platformio-udev.rules``) part of Python's module (`issue #4458 <https://github.com/platformio/platformio-core/issues/4458>`_)
* Import the "zeroconf" module only when a user lists mDNS devices (issue with zeroconf's LGPL license) * Import the "zeroconf" module only when a user lists mDNS devices (issue with zeroconf's LGPL license)
6.1.5 (2022-11-01) 6.1.5 (2022-11-01)

2
docs

Submodule docs updated: 71741fe70c...19dff22463

View File

@ -50,6 +50,10 @@ def get_source_dir():
return os.path.dirname(curpath) return os.path.dirname(curpath)
def get_assets_dir():
return os.path.join(get_source_dir(), "assets")
def load_json(file_path): def load_json(file_path):
try: try:
with open(file_path, mode="r", encoding="utf8") as f: with open(file_path, mode="r", encoding="utf8") as f:
@ -99,7 +103,7 @@ def calculate_folder_size(path):
def get_platformio_udev_rules_path(): def get_platformio_udev_rules_path():
return os.path.abspath( return os.path.abspath(
os.path.join(get_source_dir(), "..", "scripts", "99-platformio-udev.rules") os.path.join(get_assets_dir(), "system", "99-platformio-udev.rules")
) )

View File

@ -15,7 +15,6 @@
import codecs import codecs
import os import os
import sys import sys
from pathlib import Path
import bottle import bottle
@ -51,12 +50,17 @@ class ProjectGenerator:
return envname return envname
@staticmethod @staticmethod
def get_supported_ides(): def get_ide_tpls_dir():
return os.path.join(fs.get_assets_dir(), "templates", "ide-projects")
@classmethod
def get_supported_ides(cls):
tpls_dir = cls.get_ide_tpls_dir()
return sorted( return sorted(
[ [
item.name name
for item in (Path(__file__).parent / "tpls").iterdir() for name in os.listdir(tpls_dir)
if item.is_dir() if os.path.isdir(os.path.join(tpls_dir, name))
] ]
) )
@ -132,12 +136,12 @@ class ProjectGenerator:
def get_tpls(self): def get_tpls(self):
tpls = [] tpls = []
tpls_dir = str(Path(__file__).parent / "tpls" / self.ide) ide_tpls_dir = os.path.join(self.get_ide_tpls_dir(), self.ide)
for root, _, files in os.walk(tpls_dir): for root, _, files in os.walk(ide_tpls_dir):
for f in files: for f in files:
if not f.endswith(".tpl"): if not f.endswith(".tpl"):
continue continue
_relpath = root.replace(tpls_dir, "") _relpath = root.replace(ide_tpls_dir, "")
if _relpath.startswith(os.sep): if _relpath.startswith(os.sep):
_relpath = _relpath[1:] _relpath = _relpath[1:]
tpls.append((_relpath, os.path.join(root, f))) tpls.append((_relpath, os.path.join(root, f)))

View File

@ -61,15 +61,14 @@ setup(
license=__license__, license=__license__,
install_requires=minimal_requirements + home_requirements, install_requires=minimal_requirements + home_requirements,
python_requires=">=3.6", python_requires=">=3.6",
packages=find_packages(exclude=["tests.*", "tests"]) + ["scripts"], packages=find_packages(include=["platformio", "platformio.*"]),
package_data={ package_data={
"platformio": [ "platformio": [
"project/integration/tpls/*/.*.tpl", "assets/**/*.rules",
"project/integration/tpls/*/*.tpl", "assets/**/*.tpl",
"project/integration/tpls/*/*/*.tpl", "assets/**/.*.tpl", # include hidden files
"project/integration/tpls/*/.*/*.tpl", "assets/**/.*/*.tpl", # include hidden folders
], ]
"scripts": ["99-platformio-udev.rules"],
}, },
entry_points={ entry_points={
"console_scripts": [ "console_scripts": [