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
* 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)
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)
def get_assets_dir():
return os.path.join(get_source_dir(), "assets")
def load_json(file_path):
try:
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():
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 os
import sys
from pathlib import Path
import bottle
@ -51,12 +50,17 @@ class ProjectGenerator:
return envname
@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(
[
item.name
for item in (Path(__file__).parent / "tpls").iterdir()
if item.is_dir()
name
for name in os.listdir(tpls_dir)
if os.path.isdir(os.path.join(tpls_dir, name))
]
)
@ -132,12 +136,12 @@ class ProjectGenerator:
def get_tpls(self):
tpls = []
tpls_dir = str(Path(__file__).parent / "tpls" / self.ide)
for root, _, files in os.walk(tpls_dir):
ide_tpls_dir = os.path.join(self.get_ide_tpls_dir(), self.ide)
for root, _, files in os.walk(ide_tpls_dir):
for f in files:
if not f.endswith(".tpl"):
continue
_relpath = root.replace(tpls_dir, "")
_relpath = root.replace(ide_tpls_dir, "")
if _relpath.startswith(os.sep):
_relpath = _relpath[1:]
tpls.append((_relpath, os.path.join(root, f)))

View File

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