Skip to content

Commit 831f7f5

Browse files
committed
Automatically update PIO Core PyPi dependencies on "upgrade" operation
1 parent dccc14b commit 831f7f5

File tree

3 files changed

+53
-50
lines changed

3 files changed

+53
-50
lines changed

platformio/__init__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,22 @@
5656
"88.198.170.159", # platformio.org
5757
"github.com",
5858
] + __registry_mirror_hosts__
59+
60+
__install_requires__ = [
61+
# Core requirements
62+
"bottle == 0.12.*",
63+
"click >=8.0.4, <=8.2",
64+
"colorama",
65+
"marshmallow == 3.*",
66+
"pyelftools == 0.29",
67+
"pyserial == 3.5.*", # keep in sync "device/monitor/terminal.py"
68+
"requests == 2.*",
69+
"semantic_version == 2.10.*",
70+
"tabulate == 0.*",
71+
] + [
72+
# PIO Home requirements
73+
"ajsonrpc == 1.2.*",
74+
"starlette >=0.19, <0.32",
75+
"uvicorn >=0.16, <0.24",
76+
"wsproto == 1.*",
77+
]

platformio/commands/upgrade.py

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import click
2020

21-
from platformio import VERSION, __version__, app, exception
21+
from platformio import VERSION, __install_requires__, __version__, app, exception
2222
from platformio.http import fetch_remote_content
2323
from platformio.package.manager.core import update_core_packages
2424
from platformio.proc import get_pythonexe_path
@@ -33,9 +33,14 @@
3333

3434
@click.command("upgrade", short_help="Upgrade PlatformIO Core to the latest version")
3535
@click.option("--dev", is_flag=True, help="Use development branch")
36+
@click.option("--only-dependencies", is_flag=True)
3637
@click.option("--verbose", "-v", is_flag=True)
37-
def cli(dev, verbose):
38+
def cli(dev, only_dependencies, verbose):
39+
if only_dependencies:
40+
return upgrade_pypi_dependencies(verbose)
41+
3842
update_core_packages()
43+
3944
if not dev and __version__ == get_latest_version():
4045
return click.secho(
4146
"You're up-to-date!\nPlatformIO %s is currently the "
@@ -50,11 +55,21 @@ def cli(dev, verbose):
5055
pkg_spec = DEVELOP_ZIP_URL if to_develop else "platformio"
5156

5257
try:
58+
# PIO Core
5359
subprocess.run(
5460
[python_exe, "-m", "pip", "install", "--upgrade", pkg_spec],
5561
check=True,
5662
stdout=subprocess.PIPE if not verbose else None,
5763
)
64+
65+
# PyPI dependencies
66+
subprocess.run(
67+
[python_exe, "-m", "platformio", "upgrade", "--only-dependencies"],
68+
check=False,
69+
stdout=subprocess.PIPE,
70+
)
71+
72+
# Check version
5873
output = subprocess.run(
5974
[python_exe, "-m", "platformio", "--version"],
6075
check=True,
@@ -87,9 +102,20 @@ def cli(dev, verbose):
87102
return True
88103

89104

90-
def get_pkg_spec(to_develop):
91-
if to_develop:
92-
return
105+
def upgrade_pypi_dependencies(verbose):
106+
subprocess.run(
107+
[
108+
get_pythonexe_path(),
109+
"-m",
110+
"pip",
111+
"install",
112+
"--upgrade",
113+
"pip",
114+
*__install_requires__,
115+
],
116+
check=True,
117+
stdout=subprocess.PIPE if not verbose else None,
118+
)
93119

94120

95121
def get_latest_version():

setup.py

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import platform
1516
from setuptools import find_packages, setup
1617

1718
from platformio import (
@@ -22,52 +23,9 @@
2223
__title__,
2324
__url__,
2425
__version__,
26+
__install_requires__,
2527
)
2628

27-
py_37 = "python_version == '3.7'"
28-
py_below_37 = "python_version < '3.7'"
29-
py_gte_37 = "python_version >= '3.7'"
30-
py_gte_38 = "python_version >= '3.8'"
31-
32-
minimal_requirements = [
33-
"bottle==0.12.*",
34-
"click==8.0.4; " + py_below_37,
35-
"click==8.1.*; " + py_gte_37,
36-
"colorama",
37-
"marshmallow==3.14.1; " + py_below_37,
38-
"marshmallow==3.19.0; " + py_37,
39-
"marshmallow==3.20.*; " + py_gte_38,
40-
"pyelftools==0.29",
41-
"pyserial==3.5.*", # keep in sync "device/monitor/terminal.py"
42-
"requests==2.*",
43-
"semantic_version==2.10.*",
44-
"tabulate==0.*",
45-
]
46-
47-
home_requirements = [
48-
"ajsonrpc==1.2.*",
49-
"starlette==0.19.1; " + py_below_37,
50-
"starlette==0.29.0; " + py_37,
51-
"starlette==0.31.*; " + py_gte_38,
52-
"uvicorn==0.16.0; " + py_below_37,
53-
"uvicorn==0.22.0; " + py_37,
54-
"uvicorn==0.23.*; " + py_gte_38,
55-
"wsproto==1.0.0; " + py_below_37,
56-
"wsproto==1.2.*; " + py_gte_37,
57-
]
58-
59-
# issue 4614: urllib3 v2.0 only supports OpenSSL 1.1.1+
60-
try:
61-
import ssl
62-
63-
if ssl.OPENSSL_VERSION.startswith("OpenSSL ") and ssl.OPENSSL_VERSION_INFO < (
64-
1,
65-
1,
66-
1,
67-
):
68-
minimal_requirements.append("urllib3<2")
69-
except ImportError:
70-
pass
7129

7230

7331
setup(
@@ -79,7 +37,7 @@
7937
author_email=__email__,
8038
url=__url__,
8139
license=__license__,
82-
install_requires=minimal_requirements + home_requirements,
40+
install_requires=__install_requires__,
8341
python_requires=">=3.6",
8442
packages=find_packages(include=["platformio", "platformio.*"]),
8543
package_data={

0 commit comments

Comments
 (0)