Automatically update PIO Core PyPi dependencies on "upgrade" operation

This commit is contained in:
Ivan Kravets
2023-07-29 16:01:57 +03:00
parent dccc14b507
commit 831f7f52bc
3 changed files with 53 additions and 50 deletions

View File

@ -56,3 +56,22 @@ __check_internet_hosts__ = [
"88.198.170.159", # platformio.org "88.198.170.159", # platformio.org
"github.com", "github.com",
] + __registry_mirror_hosts__ ] + __registry_mirror_hosts__
__install_requires__ = [
# Core requirements
"bottle == 0.12.*",
"click >=8.0.4, <=8.2",
"colorama",
"marshmallow == 3.*",
"pyelftools == 0.29",
"pyserial == 3.5.*", # keep in sync "device/monitor/terminal.py"
"requests == 2.*",
"semantic_version == 2.10.*",
"tabulate == 0.*",
] + [
# PIO Home requirements
"ajsonrpc == 1.2.*",
"starlette >=0.19, <0.32",
"uvicorn >=0.16, <0.24",
"wsproto == 1.*",
]

View File

@ -18,7 +18,7 @@ import subprocess
import click import click
from platformio import VERSION, __version__, app, exception from platformio import VERSION, __install_requires__, __version__, app, exception
from platformio.http import fetch_remote_content from platformio.http import fetch_remote_content
from platformio.package.manager.core import update_core_packages from platformio.package.manager.core import update_core_packages
from platformio.proc import get_pythonexe_path from platformio.proc import get_pythonexe_path
@ -33,9 +33,14 @@ DEVELOP_INIT_SCRIPT_URL = (
@click.command("upgrade", short_help="Upgrade PlatformIO Core to the latest version") @click.command("upgrade", short_help="Upgrade PlatformIO Core to the latest version")
@click.option("--dev", is_flag=True, help="Use development branch") @click.option("--dev", is_flag=True, help="Use development branch")
@click.option("--only-dependencies", is_flag=True)
@click.option("--verbose", "-v", is_flag=True) @click.option("--verbose", "-v", is_flag=True)
def cli(dev, verbose): def cli(dev, only_dependencies, verbose):
if only_dependencies:
return upgrade_pypi_dependencies(verbose)
update_core_packages() update_core_packages()
if not dev and __version__ == get_latest_version(): if not dev and __version__ == get_latest_version():
return click.secho( return click.secho(
"You're up-to-date!\nPlatformIO %s is currently the " "You're up-to-date!\nPlatformIO %s is currently the "
@ -50,11 +55,21 @@ def cli(dev, verbose):
pkg_spec = DEVELOP_ZIP_URL if to_develop else "platformio" pkg_spec = DEVELOP_ZIP_URL if to_develop else "platformio"
try: try:
# PIO Core
subprocess.run( subprocess.run(
[python_exe, "-m", "pip", "install", "--upgrade", pkg_spec], [python_exe, "-m", "pip", "install", "--upgrade", pkg_spec],
check=True, check=True,
stdout=subprocess.PIPE if not verbose else None, stdout=subprocess.PIPE if not verbose else None,
) )
# PyPI dependencies
subprocess.run(
[python_exe, "-m", "platformio", "upgrade", "--only-dependencies"],
check=False,
stdout=subprocess.PIPE,
)
# Check version
output = subprocess.run( output = subprocess.run(
[python_exe, "-m", "platformio", "--version"], [python_exe, "-m", "platformio", "--version"],
check=True, check=True,
@ -87,9 +102,20 @@ def cli(dev, verbose):
return True return True
def get_pkg_spec(to_develop): def upgrade_pypi_dependencies(verbose):
if to_develop: subprocess.run(
return [
get_pythonexe_path(),
"-m",
"pip",
"install",
"--upgrade",
"pip",
*__install_requires__,
],
check=True,
stdout=subprocess.PIPE if not verbose else None,
)
def get_latest_version(): def get_latest_version():

View File

@ -12,6 +12,7 @@
# 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 platform
from setuptools import find_packages, setup from setuptools import find_packages, setup
from platformio import ( from platformio import (
@ -22,52 +23,9 @@ from platformio import (
__title__, __title__,
__url__, __url__,
__version__, __version__,
__install_requires__,
) )
py_37 = "python_version == '3.7'"
py_below_37 = "python_version < '3.7'"
py_gte_37 = "python_version >= '3.7'"
py_gte_38 = "python_version >= '3.8'"
minimal_requirements = [
"bottle==0.12.*",
"click==8.0.4; " + py_below_37,
"click==8.1.*; " + py_gte_37,
"colorama",
"marshmallow==3.14.1; " + py_below_37,
"marshmallow==3.19.0; " + py_37,
"marshmallow==3.20.*; " + py_gte_38,
"pyelftools==0.29",
"pyserial==3.5.*", # keep in sync "device/monitor/terminal.py"
"requests==2.*",
"semantic_version==2.10.*",
"tabulate==0.*",
]
home_requirements = [
"ajsonrpc==1.2.*",
"starlette==0.19.1; " + py_below_37,
"starlette==0.29.0; " + py_37,
"starlette==0.31.*; " + py_gte_38,
"uvicorn==0.16.0; " + py_below_37,
"uvicorn==0.22.0; " + py_37,
"uvicorn==0.23.*; " + py_gte_38,
"wsproto==1.0.0; " + py_below_37,
"wsproto==1.2.*; " + py_gte_37,
]
# issue 4614: urllib3 v2.0 only supports OpenSSL 1.1.1+
try:
import ssl
if ssl.OPENSSL_VERSION.startswith("OpenSSL ") and ssl.OPENSSL_VERSION_INFO < (
1,
1,
1,
):
minimal_requirements.append("urllib3<2")
except ImportError:
pass
setup( setup(
@ -79,7 +37,7 @@ setup(
author_email=__email__, author_email=__email__,
url=__url__, url=__url__,
license=__license__, license=__license__,
install_requires=minimal_requirements + home_requirements, install_requires=__install_requires__,
python_requires=">=3.6", python_requires=">=3.6",
packages=find_packages(include=["platformio", "platformio.*"]), packages=find_packages(include=["platformio", "platformio.*"]),
package_data={ package_data={