diff --git a/HISTORY.rst b/HISTORY.rst index a1a9aec8..c65b827a 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -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 `_) * Import the "zeroconf" module only when a user lists mDNS devices (issue with zeroconf's LGPL license) 6.1.5 (2022-11-01) diff --git a/docs b/docs index 71741fe7..19dff224 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 71741fe70c5bdb031a0182de027ac7dbe0ac02d5 +Subproject commit 19dff224639b6f2e97062841349fd48269ef1923 diff --git a/scripts/99-platformio-udev.rules b/platformio/assets/system/99-platformio-udev.rules similarity index 100% rename from scripts/99-platformio-udev.rules rename to platformio/assets/system/99-platformio-udev.rules diff --git a/platformio/project/integration/tpls/atom/.clang_complete.tpl b/platformio/assets/templates/ide-projects/atom/.clang_complete.tpl similarity index 100% rename from platformio/project/integration/tpls/atom/.clang_complete.tpl rename to platformio/assets/templates/ide-projects/atom/.clang_complete.tpl diff --git a/platformio/project/integration/tpls/atom/.gcc-flags.json.tpl b/platformio/assets/templates/ide-projects/atom/.gcc-flags.json.tpl similarity index 100% rename from platformio/project/integration/tpls/atom/.gcc-flags.json.tpl rename to platformio/assets/templates/ide-projects/atom/.gcc-flags.json.tpl diff --git a/platformio/project/integration/tpls/atom/.gitignore.tpl b/platformio/assets/templates/ide-projects/atom/.gitignore.tpl similarity index 100% rename from platformio/project/integration/tpls/atom/.gitignore.tpl rename to platformio/assets/templates/ide-projects/atom/.gitignore.tpl diff --git a/platformio/project/integration/tpls/clion/.gitignore.tpl b/platformio/assets/templates/ide-projects/clion/.gitignore.tpl similarity index 100% rename from platformio/project/integration/tpls/clion/.gitignore.tpl rename to platformio/assets/templates/ide-projects/clion/.gitignore.tpl diff --git a/platformio/project/integration/tpls/clion/CMakeLists.txt.tpl b/platformio/assets/templates/ide-projects/clion/CMakeLists.txt.tpl similarity index 100% rename from platformio/project/integration/tpls/clion/CMakeLists.txt.tpl rename to platformio/assets/templates/ide-projects/clion/CMakeLists.txt.tpl diff --git a/platformio/project/integration/tpls/clion/CMakeListsPrivate.txt.tpl b/platformio/assets/templates/ide-projects/clion/CMakeListsPrivate.txt.tpl similarity index 100% rename from platformio/project/integration/tpls/clion/CMakeListsPrivate.txt.tpl rename to platformio/assets/templates/ide-projects/clion/CMakeListsPrivate.txt.tpl diff --git a/platformio/project/integration/tpls/codeblocks/platformio.cbp.tpl b/platformio/assets/templates/ide-projects/codeblocks/platformio.cbp.tpl similarity index 100% rename from platformio/project/integration/tpls/codeblocks/platformio.cbp.tpl rename to platformio/assets/templates/ide-projects/codeblocks/platformio.cbp.tpl diff --git a/platformio/project/integration/tpls/eclipse/.cproject.tpl b/platformio/assets/templates/ide-projects/eclipse/.cproject.tpl similarity index 100% rename from platformio/project/integration/tpls/eclipse/.cproject.tpl rename to platformio/assets/templates/ide-projects/eclipse/.cproject.tpl diff --git a/platformio/project/integration/tpls/eclipse/.project.tpl b/platformio/assets/templates/ide-projects/eclipse/.project.tpl similarity index 100% rename from platformio/project/integration/tpls/eclipse/.project.tpl rename to platformio/assets/templates/ide-projects/eclipse/.project.tpl diff --git a/platformio/project/integration/tpls/eclipse/.settings/PlatformIO Debugger.launch.tpl b/platformio/assets/templates/ide-projects/eclipse/.settings/PlatformIO Debugger.launch.tpl similarity index 100% rename from platformio/project/integration/tpls/eclipse/.settings/PlatformIO Debugger.launch.tpl rename to platformio/assets/templates/ide-projects/eclipse/.settings/PlatformIO Debugger.launch.tpl diff --git a/platformio/project/integration/tpls/eclipse/.settings/language.settings.xml.tpl b/platformio/assets/templates/ide-projects/eclipse/.settings/language.settings.xml.tpl similarity index 100% rename from platformio/project/integration/tpls/eclipse/.settings/language.settings.xml.tpl rename to platformio/assets/templates/ide-projects/eclipse/.settings/language.settings.xml.tpl diff --git a/platformio/project/integration/tpls/eclipse/.settings/org.eclipse.cdt.core.prefs.tpl b/platformio/assets/templates/ide-projects/eclipse/.settings/org.eclipse.cdt.core.prefs.tpl similarity index 100% rename from platformio/project/integration/tpls/eclipse/.settings/org.eclipse.cdt.core.prefs.tpl rename to platformio/assets/templates/ide-projects/eclipse/.settings/org.eclipse.cdt.core.prefs.tpl diff --git a/platformio/project/integration/tpls/emacs/.ccls.tpl b/platformio/assets/templates/ide-projects/emacs/.ccls.tpl similarity index 100% rename from platformio/project/integration/tpls/emacs/.ccls.tpl rename to platformio/assets/templates/ide-projects/emacs/.ccls.tpl diff --git a/platformio/project/integration/tpls/emacs/.gitignore.tpl b/platformio/assets/templates/ide-projects/emacs/.gitignore.tpl similarity index 100% rename from platformio/project/integration/tpls/emacs/.gitignore.tpl rename to platformio/assets/templates/ide-projects/emacs/.gitignore.tpl diff --git a/platformio/project/integration/tpls/netbeans/nbproject/configurations.xml.tpl b/platformio/assets/templates/ide-projects/netbeans/nbproject/configurations.xml.tpl similarity index 100% rename from platformio/project/integration/tpls/netbeans/nbproject/configurations.xml.tpl rename to platformio/assets/templates/ide-projects/netbeans/nbproject/configurations.xml.tpl diff --git a/platformio/project/integration/tpls/netbeans/nbproject/private/configurations.xml.tpl b/platformio/assets/templates/ide-projects/netbeans/nbproject/private/configurations.xml.tpl similarity index 100% rename from platformio/project/integration/tpls/netbeans/nbproject/private/configurations.xml.tpl rename to platformio/assets/templates/ide-projects/netbeans/nbproject/private/configurations.xml.tpl diff --git a/platformio/project/integration/tpls/netbeans/nbproject/private/launcher.properties.tpl b/platformio/assets/templates/ide-projects/netbeans/nbproject/private/launcher.properties.tpl similarity index 100% rename from platformio/project/integration/tpls/netbeans/nbproject/private/launcher.properties.tpl rename to platformio/assets/templates/ide-projects/netbeans/nbproject/private/launcher.properties.tpl diff --git a/platformio/project/integration/tpls/netbeans/nbproject/private/private.xml.tpl b/platformio/assets/templates/ide-projects/netbeans/nbproject/private/private.xml.tpl similarity index 100% rename from platformio/project/integration/tpls/netbeans/nbproject/private/private.xml.tpl rename to platformio/assets/templates/ide-projects/netbeans/nbproject/private/private.xml.tpl diff --git a/platformio/project/integration/tpls/netbeans/nbproject/project.xml.tpl b/platformio/assets/templates/ide-projects/netbeans/nbproject/project.xml.tpl similarity index 100% rename from platformio/project/integration/tpls/netbeans/nbproject/project.xml.tpl rename to platformio/assets/templates/ide-projects/netbeans/nbproject/project.xml.tpl diff --git a/platformio/project/integration/tpls/qtcreator/.gitignore.tpl b/platformio/assets/templates/ide-projects/qtcreator/.gitignore.tpl similarity index 100% rename from platformio/project/integration/tpls/qtcreator/.gitignore.tpl rename to platformio/assets/templates/ide-projects/qtcreator/.gitignore.tpl diff --git a/platformio/project/integration/tpls/qtcreator/Makefile.tpl b/platformio/assets/templates/ide-projects/qtcreator/Makefile.tpl similarity index 100% rename from platformio/project/integration/tpls/qtcreator/Makefile.tpl rename to platformio/assets/templates/ide-projects/qtcreator/Makefile.tpl diff --git a/platformio/project/integration/tpls/qtcreator/platformio.cflags.tpl b/platformio/assets/templates/ide-projects/qtcreator/platformio.cflags.tpl similarity index 100% rename from platformio/project/integration/tpls/qtcreator/platformio.cflags.tpl rename to platformio/assets/templates/ide-projects/qtcreator/platformio.cflags.tpl diff --git a/platformio/project/integration/tpls/qtcreator/platformio.config.tpl b/platformio/assets/templates/ide-projects/qtcreator/platformio.config.tpl similarity index 100% rename from platformio/project/integration/tpls/qtcreator/platformio.config.tpl rename to platformio/assets/templates/ide-projects/qtcreator/platformio.config.tpl diff --git a/platformio/project/integration/tpls/qtcreator/platformio.creator.tpl b/platformio/assets/templates/ide-projects/qtcreator/platformio.creator.tpl similarity index 100% rename from platformio/project/integration/tpls/qtcreator/platformio.creator.tpl rename to platformio/assets/templates/ide-projects/qtcreator/platformio.creator.tpl diff --git a/platformio/project/integration/tpls/qtcreator/platformio.cxxflags.tpl b/platformio/assets/templates/ide-projects/qtcreator/platformio.cxxflags.tpl similarity index 100% rename from platformio/project/integration/tpls/qtcreator/platformio.cxxflags.tpl rename to platformio/assets/templates/ide-projects/qtcreator/platformio.cxxflags.tpl diff --git a/platformio/project/integration/tpls/qtcreator/platformio.files.tpl b/platformio/assets/templates/ide-projects/qtcreator/platformio.files.tpl similarity index 100% rename from platformio/project/integration/tpls/qtcreator/platformio.files.tpl rename to platformio/assets/templates/ide-projects/qtcreator/platformio.files.tpl diff --git a/platformio/project/integration/tpls/qtcreator/platformio.includes.tpl b/platformio/assets/templates/ide-projects/qtcreator/platformio.includes.tpl similarity index 100% rename from platformio/project/integration/tpls/qtcreator/platformio.includes.tpl rename to platformio/assets/templates/ide-projects/qtcreator/platformio.includes.tpl diff --git a/platformio/project/integration/tpls/sublimetext/.ccls.tpl b/platformio/assets/templates/ide-projects/sublimetext/.ccls.tpl similarity index 100% rename from platformio/project/integration/tpls/sublimetext/.ccls.tpl rename to platformio/assets/templates/ide-projects/sublimetext/.ccls.tpl diff --git a/platformio/project/integration/tpls/sublimetext/platformio.sublime-project.tpl b/platformio/assets/templates/ide-projects/sublimetext/platformio.sublime-project.tpl similarity index 100% rename from platformio/project/integration/tpls/sublimetext/platformio.sublime-project.tpl rename to platformio/assets/templates/ide-projects/sublimetext/platformio.sublime-project.tpl diff --git a/platformio/project/integration/tpls/vim/.ccls.tpl b/platformio/assets/templates/ide-projects/vim/.ccls.tpl similarity index 100% rename from platformio/project/integration/tpls/vim/.ccls.tpl rename to platformio/assets/templates/ide-projects/vim/.ccls.tpl diff --git a/platformio/project/integration/tpls/vim/.gitignore.tpl b/platformio/assets/templates/ide-projects/vim/.gitignore.tpl similarity index 100% rename from platformio/project/integration/tpls/vim/.gitignore.tpl rename to platformio/assets/templates/ide-projects/vim/.gitignore.tpl diff --git a/platformio/project/integration/tpls/visualstudio/platformio.vcxproj.filters.tpl b/platformio/assets/templates/ide-projects/visualstudio/platformio.vcxproj.filters.tpl similarity index 100% rename from platformio/project/integration/tpls/visualstudio/platformio.vcxproj.filters.tpl rename to platformio/assets/templates/ide-projects/visualstudio/platformio.vcxproj.filters.tpl diff --git a/platformio/project/integration/tpls/visualstudio/platformio.vcxproj.tpl b/platformio/assets/templates/ide-projects/visualstudio/platformio.vcxproj.tpl similarity index 100% rename from platformio/project/integration/tpls/visualstudio/platformio.vcxproj.tpl rename to platformio/assets/templates/ide-projects/visualstudio/platformio.vcxproj.tpl diff --git a/platformio/project/integration/tpls/vscode/.gitignore.tpl b/platformio/assets/templates/ide-projects/vscode/.gitignore.tpl similarity index 100% rename from platformio/project/integration/tpls/vscode/.gitignore.tpl rename to platformio/assets/templates/ide-projects/vscode/.gitignore.tpl diff --git a/platformio/project/integration/tpls/vscode/.vscode/c_cpp_properties.json.tpl b/platformio/assets/templates/ide-projects/vscode/.vscode/c_cpp_properties.json.tpl similarity index 100% rename from platformio/project/integration/tpls/vscode/.vscode/c_cpp_properties.json.tpl rename to platformio/assets/templates/ide-projects/vscode/.vscode/c_cpp_properties.json.tpl diff --git a/platformio/project/integration/tpls/vscode/.vscode/extensions.json.tpl b/platformio/assets/templates/ide-projects/vscode/.vscode/extensions.json.tpl similarity index 100% rename from platformio/project/integration/tpls/vscode/.vscode/extensions.json.tpl rename to platformio/assets/templates/ide-projects/vscode/.vscode/extensions.json.tpl diff --git a/platformio/project/integration/tpls/vscode/.vscode/launch.json.tpl b/platformio/assets/templates/ide-projects/vscode/.vscode/launch.json.tpl similarity index 100% rename from platformio/project/integration/tpls/vscode/.vscode/launch.json.tpl rename to platformio/assets/templates/ide-projects/vscode/.vscode/launch.json.tpl diff --git a/platformio/fs.py b/platformio/fs.py index 60111694..bd17950b 100644 --- a/platformio/fs.py +++ b/platformio/fs.py @@ -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") ) diff --git a/platformio/project/integration/generator.py b/platformio/project/integration/generator.py index 7ffd05e3..4a4eb480 100644 --- a/platformio/project/integration/generator.py +++ b/platformio/project/integration/generator.py @@ -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))) diff --git a/setup.py b/setup.py index e348cf9d..95877bd6 100644 --- a/setup.py +++ b/setup.py @@ -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": [