Resolved installation issues with PIO Remote on Raspberry Pi and other small form-factor PCs // Resolve #4425 , Resolve #4493 , Resolve #4607

This commit is contained in:
Ivan Kravets
2023-04-27 14:24:34 +03:00
parent 2312ca929d
commit 2c94fb2aad
5 changed files with 13 additions and 143 deletions

View File

@@ -33,6 +33,7 @@ PlatformIO Core 6
* Resolved an issue where native tests would fail if a custom program name was specified (`issue #4546 <https://github.com/platformio/platformio-core/issues/4546>`_) * Resolved an issue where native tests would fail if a custom program name was specified (`issue #4546 <https://github.com/platformio/platformio-core/issues/4546>`_)
* Resolved an issue where the PlatformIO |DEBUGGING| solution was not escaping the tool installation process into MI2 correctly (`issue #4565 <https://github.com/platformio/platformio-core/issues/4565>`_) * Resolved an issue where the PlatformIO |DEBUGGING| solution was not escaping the tool installation process into MI2 correctly (`issue #4565 <https://github.com/platformio/platformio-core/issues/4565>`_)
* Resolved an issue where multiple targets were not executed sequentially (`issue #4604 <https://github.com/platformio/platformio-core/issues/4604>`_) * Resolved an issue where multiple targets were not executed sequentially (`issue #4604 <https://github.com/platformio/platformio-core/issues/4604>`_)
* Resolved installation issues with PIO Remote on Raspberry Pi and other small form-factor PCs (`issue #4425 <https://github.com/platformio/platformio-core/issues/4425>`_, `issue #4493 <https://github.com/platformio/platformio-core/issues/4493>`_, `issue #4607 <https://github.com/platformio/platformio-core/issues/4607>`_)
6.1.6 (2023-01-23) 6.1.6 (2023-01-23)
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~

2
docs

Submodule docs updated: 890d8e20fe...88d4514ccc

View File

@@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import sys
VERSION = (6, 1, "7b2") VERSION = (6, 1, "7b2")
__version__ = ".".join([str(s) for s in VERSION]) __version__ = ".".join([str(s) for s in VERSION])
@@ -46,7 +44,7 @@ __pioremote_endpoint__ = "ssl:host=remote.platformio.org:port=4413"
__core_packages__ = { __core_packages__ = {
"contrib-piohome": "~3.4.2", "contrib-piohome": "~3.4.2",
"contrib-pysite": "~2.%d%d.0" % (sys.version_info.major, sys.version_info.minor), "contrib-pioremote": "~1.0.0",
"tool-scons": "~4.40502.0", "tool-scons": "~4.40502.0",
"tool-cppcheck": "~1.270.0", "tool-cppcheck": "~1.270.0",
"tool-clangtidy": "~1.150005.0", "tool-clangtidy": "~1.150005.0",

View File

@@ -12,19 +12,12 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import json
import os import os
import shutil
import subprocess
import sys
from datetime import date
from platformio import __core_packages__, exception, fs, util from platformio import __core_packages__, exception
from platformio.exception import UserSideException
from platformio.package.exception import UnknownPackageError from platformio.package.exception import UnknownPackageError
from platformio.package.manager.tool import ToolPackageManager from platformio.package.manager.tool import ToolPackageManager
from platformio.package.meta import PackageItem, PackageSpec from platformio.package.meta import PackageSpec
from platformio.proc import get_pythonexe_path
def get_installed_core_packages(): def get_installed_core_packages():
@@ -98,131 +91,3 @@ def remove_unnecessary_core_packages(dry_run=False):
pm.uninstall(pkg) pm.uninstall(pkg)
return candidates return candidates
def inject_contrib_pysite():
# pylint: disable=import-outside-toplevel
from site import addsitedir
try:
contrib_pysite_dir = get_core_package_dir("contrib-pysite")
except UnknownPackageError:
pm = ToolPackageManager()
contrib_pysite_dir = build_contrib_pysite_package(
os.path.join(pm.package_dir, "contrib-pysite")
)
if contrib_pysite_dir in sys.path:
return True
addsitedir(contrib_pysite_dir)
sys.path.insert(0, contrib_pysite_dir)
try:
# pylint: disable=import-error,unused-import,unused-variable
from OpenSSL import SSL
except: # pylint: disable=bare-except
build_contrib_pysite_package(contrib_pysite_dir)
return True
def build_contrib_pysite_package(target_dir, with_metadata=True):
systype = util.get_systype()
if os.path.isdir(target_dir):
fs.rmtree(target_dir)
os.makedirs(target_dir)
# issue 3865: There is no "rustup" in "Raspbian GNU/Linux 10 (buster)"
os.environ["CRYPTOGRAPHY_DONT_BUILD_RUST"] = "1"
# build dependencies
args = [
get_pythonexe_path(),
"-m",
"pip",
"install",
"--no-compile",
"-t",
target_dir,
]
if "linux" in systype:
args.extend(["--no-binary", ":all:"])
try:
subprocess.run(args + get_contrib_pysite_deps(), check=True, env=os.environ)
except subprocess.CalledProcessError as exc:
if "linux" in systype:
raise UserSideException(
"\n\nPlease ensure that the next packages are installed:\n\n"
"sudo apt install python3-dev libffi-dev libssl-dev\n"
) from exc
raise exc
# build manifests
with open(
os.path.join(target_dir, "package.json"), mode="w", encoding="utf8"
) as fp:
json.dump(
dict(
name="contrib-pysite",
version="2.%d%d.%s"
% (
sys.version_info.major,
sys.version_info.minor,
date.today().strftime("%y%m%d"),
),
system=list(
set([systype, "linux_armv6l", "linux_armv7l", "linux_armv8l"])
)
if systype.startswith("linux_arm")
else systype,
description="Extra Python package for PlatformIO Core",
keywords=["platformio", "platformio-core"],
homepage="https://docs.platformio.org/page/core/index.html",
repository={
"type": "git",
"url": "https://github.com/platformio/platformio-core",
},
),
fp,
)
# generate package metadata
if with_metadata:
pm = ToolPackageManager()
pkg = PackageItem(target_dir)
pkg.metadata = pm.build_metadata(
target_dir, PackageSpec(owner="platformio", name="contrib-pysite")
)
pkg.dump_meta()
# remove unused files
for root, dirs, files in os.walk(target_dir):
for t in ("_test", "test", "tests"):
if t in dirs:
shutil.rmtree(os.path.join(root, t))
for name in files:
if name.endswith((".chm", ".pyc")):
os.remove(os.path.join(root, name))
return target_dir
def get_contrib_pysite_deps():
systype = util.get_systype()
twisted_version = "22.1.0"
if "linux_arm" in systype:
result = [
# twisted[tls], see setup.py for %twisted_version%
"twisted == %s" % twisted_version,
# pyopenssl depends on it, use RUST-less version
"cryptography >= 3.3, < 35.0.0",
"pyopenssl >= 16.0.0, <= 21.0.0",
"service_identity >= 18.1.0, <= 21.1.0",
]
else:
result = ["twisted[tls] == %s" % twisted_version]
if "windows" in systype:
result.append("pywin32 != 226")
return result

View File

@@ -17,7 +17,9 @@
import os import os
import subprocess import subprocess
import sys
import threading import threading
from site import addsitedir
from tempfile import mkdtemp from tempfile import mkdtemp
from time import sleep from time import sleep
@@ -29,7 +31,7 @@ from platformio.device.monitor.command import (
device_monitor_cmd, device_monitor_cmd,
get_project_options, get_project_options,
) )
from platformio.package.manager.core import inject_contrib_pysite from platformio.package.manager.core import get_core_package_dir
from platformio.project.exception import NotPlatformIOProjectError from platformio.project.exception import NotPlatformIOProjectError
from platformio.project.options import ProjectOptions from platformio.project.options import ProjectOptions
from platformio.run.cli import cli as cmd_run from platformio.run.cli import cli as cmd_run
@@ -41,7 +43,11 @@ from platformio.test.cli import cli as test_cmd
@click.pass_context @click.pass_context
def cli(ctx, agent): def cli(ctx, agent):
ctx.obj = agent ctx.obj = agent
inject_contrib_pysite() # inject twisted dependencies
contrib_dir = get_core_package_dir("contrib-pioremote")
if contrib_dir not in sys.path:
addsitedir(contrib_dir)
sys.path.insert(0, contrib_dir)
@cli.group("agent", short_help="Start a new agent or list active") @cli.group("agent", short_help="Start a new agent or list active")