Skip to content

Commit 2dba218

Browse files
authored
Fetch last release pioarduino core via github api
* load portable python from repo pioarduino * fetch latest release dynamically via API * rename to pioarduino core / remove link to Platformio faq
1 parent abc31fd commit 2dba218

File tree

8 files changed

+50
-36
lines changed

8 files changed

+50
-36
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
fail-fast: false
99
matrix:
1010
os: [ubuntu-latest, windows-latest, macos-latest]
11-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
11+
python-version: ["3.9", "3.10", "3.11", "3.12"]
1212
runs-on: ${{ matrix.os }}
1313
steps:
1414
- uses: actions/checkout@v4
@@ -35,6 +35,11 @@ jobs:
3535
- name: Pack Installer Script
3636
run: |
3737
make pack
38+
- name: Commit changed `get-platformio.py`
39+
if: matrix.os == 'macos-latest' && matrix.python-version == '"3.12"'
40+
uses: stefanzweifel/git-auto-commit-action@v5
41+
with:
42+
commit_message: "Github Action: Updated `get-platformio.py`"
3843
- name: Install PlatformIO Core
3944
run: |
4045
python3 get-platformio.py

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
__pycache__/
33
*.py[cod]
44
*$py.class
5+
.venv/
56

67
# App specific
78
*.egg-info/
@@ -11,3 +12,4 @@ build/
1112

1213
# Misc
1314
.idea
15+
.DS_Store

get-platformio.py

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

pioinstaller/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717
VERSION = (1, 2, 3)
1818
__version__ = ".".join([str(s) for s in VERSION])
1919

20-
__title__ = "platformio-installer"
21-
__description__ = "An installer for PlatformIO Core"
20+
__title__ = "pioarduino-installer"
21+
__description__ = "An installer for PlatformIO pioarduino Core"
2222

23-
__url__ = "https://platformio.org"
23+
__url__ = "https://pioarduino.org"
2424

25-
__author__ = "PlatformIO Labs"
25+
__author__ = "PlatformIO Labs and pioarduino"
2626
__email__ = "[email protected]"
2727

2828

2929
__license__ = "Apache-2.0"
30-
__copyright__ = "Copyright 2014-present PlatformIO"
30+
__copyright__ = "Copyright 2014-present PlatformIO and pioarduino"
3131

3232

3333
logging.basicConfig(format="%(levelname)s: %(message)s")

pioinstaller/__main__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
@click.pass_context
4444
def cli(
4545
ctx, verbose, shutdown_piohome, dev, ignore_python, pypi_index_url
46-
): # pylint:disable=too-many-arguments
46+
): # pylint: disable=too-many-arguments,too-many-positional-arguments
4747
if verbose:
4848
logging.getLogger("pioinstaller").setLevel(logging.DEBUG)
4949
if pypi_index_url:
@@ -119,13 +119,13 @@ def core_check(ctx, **kwargs):
119119
if kwargs.get("dump_state"):
120120
core.dump_state(target=str(kwargs.get("dump_state")), state=state)
121121
click.secho(
122-
"Found compatible PlatformIO Core %s -> %s"
122+
"Found compatible pioarduino Core %s -> %s"
123123
% (state.get("core_version"), state.get("platformio_exe")),
124124
fg="green",
125125
)
126126
except exception.InvalidPlatformIOCore as e:
127127
raise click.ClickException(
128-
"Compatible PlatformIO Core not found.\nReason: %s" % str(e)
128+
"Compatible pioarduino Core not found.\nReason: %s" % str(e)
129129
)
130130

131131

pioinstaller/core.py

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import subprocess
2222
import sys
2323
import time
24+
import requests
2425

2526
import click
2627
import semantic_version
@@ -29,15 +30,24 @@
2930

3031
log = logging.getLogger(__name__)
3132

33+
PIO_CORE_API_URL = (
34+
"https://api.github.com/repos/pioarduino/"
35+
"platformio-core/releases/latest"
36+
)
37+
api_data = requests.get(PIO_CORE_API_URL, timeout=10).json()
38+
try:
39+
data = api_data["zipball_url"]
40+
except KeyError:
41+
data = "https://github.com/pioarduino/platformio-core/archive/refs/tags/v6.1.16.zip"
42+
print(
43+
"Could not download actual pioarduino core. Try to install v6.1.16 instead."
44+
)
45+
PIO_CORE_RELEASE_URL = data
3246
PIO_CORE_DEVELOP_URL = (
3347
"https://github.com/pioarduino/platformio-core/"
3448
"archive/pio_github.zip"
3549
)
36-
PIO_CORE_RELEASE_URL = (
37-
"https://github.com/pioarduino/platformio-core/"
38-
"archive/refs/tags/v6.1.16+test.zip"
39-
)
40-
UPDATE_INTERVAL = 60 * 60 * 24 * 3 # 3 days
50+
UPDATE_INTERVAL = 60 * 60 * 24 * 31 # 31 days
4151

4252

4353
def get_core_dir(force_to_root=False):
@@ -111,10 +121,10 @@ def _install_platformio_core(shutdown_piohome=True, develop=False, ignore_python
111121
)
112122
command = [python_exe, "-m", "pip", "install", "-U"]
113123
if develop:
114-
click.echo("Installing a development version of PlatformIO Core")
124+
click.echo("Installing a development version of pioarduino Core")
115125
command.append(PIO_CORE_DEVELOP_URL)
116126
else:
117-
click.echo("Installing PlatformIO Core")
127+
click.echo("Installing pioarduino Core")
118128
command.append(PIO_CORE_RELEASE_URL)
119129
try:
120130
subprocess.check_call(command)
@@ -126,15 +136,15 @@ def _install_platformio_core(shutdown_piohome=True, develop=False, ignore_python
126136
" try to disable it for a while.\n %s" % error
127137
)
128138
raise exception.PIOInstallerException(
129-
"Could not install PlatformIO Core: %s" % error
139+
"Could not install pioarduino Core: %s" % error
130140
)
131141
platformio_exe = os.path.join(
132142
penv.get_penv_bin_dir(penv_dir),
133143
"platformio.exe" if util.IS_WINDOWS else "platformio",
134144
)
135145

136146
click.secho(
137-
"\nPlatformIO Core has been successfully installed into an isolated environment `%s`!\n"
147+
"\npioarduino Core has been successfully installed into an isolated environment `%s`!\n"
138148
% penv_dir,
139149
fg="green",
140150
)
@@ -143,9 +153,7 @@ def _install_platformio_core(shutdown_piohome=True, develop=False, ignore_python
143153
click.secho(
144154
"""
145155
If you need an access to `platformio.exe` from other applications, please install Shell Commands
146-
(add PlatformIO Core binary directory `%s` to the system environment PATH variable):
147-
148-
See https://docs.platformio.org/page/installation.html#install-shell-commands
156+
(add pioarduino Core binary directory `%s` to the system environment PATH variable).
149157
"""
150158
% penv.get_penv_bin_dir(penv_dir),
151159
fg="cyan",
@@ -173,7 +181,7 @@ def check(develop=False, global_=False, auto_upgrade=False, version_spec=None):
173181
)
174182
if not os.path.isfile(platformio_exe):
175183
raise exception.InvalidPlatformIOCore(
176-
"PlatformIO executable not found in `%s`" % penv.get_penv_bin_dir()
184+
"pioarduino executable not found in `%s`" % penv.get_penv_bin_dir()
177185
)
178186
try:
179187
subprocess.check_output([platformio_exe, "--help"], stderr=subprocess.STDOUT)
@@ -189,7 +197,7 @@ def check(develop=False, global_=False, auto_upgrade=False, version_spec=None):
189197
except subprocess.CalledProcessError as e:
190198
error = e.output.decode()
191199
raise exception.InvalidPlatformIOCore(
192-
"Could not import PlatformIO module. Error: %s" % error
200+
"Could not import pioarduino module. Error: %s" % error
193201
)
194202
piocore_version = convert_version(result.get("core_version"))
195203
develop = develop or bool(piocore_version.prerelease if piocore_version else False)
@@ -220,7 +228,7 @@ def check(develop=False, global_=False, auto_upgrade=False, version_spec=None):
220228
try:
221229
result.update(fetch_python_state(python_exe))
222230
except: # pylint:disable=bare-except
223-
raise exception.InvalidPlatformIOCore("Could not import PlatformIO module")
231+
raise exception.InvalidPlatformIOCore("Could not import pioarduino module")
224232

225233
return result
226234

@@ -229,7 +237,7 @@ def _check_core_version(piocore_version, version_spec):
229237
try:
230238
if piocore_version not in semantic_version.Spec(version_spec):
231239
raise exception.InvalidPlatformIOCore(
232-
"PlatformIO Core version %s does not match version requirements %s."
240+
"pioarduino Core version %s does not match version requirements %s."
233241
% (str(piocore_version), version_spec)
234242
)
235243
except ValueError:
@@ -254,7 +262,7 @@ def _check_platform_version():
254262
):
255263
return True
256264
raise exception.InvalidPlatformIOCore(
257-
"PlatformIO Core was installed using another platform `%s`. "
265+
"pioarduino Core was installed using another platform `%s`. "
258266
"Your current platform: %s"
259267
% (platform_state.get("platform"), platform.platform(terse=True))
260268
)
@@ -327,7 +335,7 @@ def auto_upgrade_core(platformio_exe, develop=False):
327335
return True
328336
except Exception as e: # pylint:disable=broad-except
329337
raise exception.PIOInstallerException(
330-
"Could not upgrade PlatformIO Core: %s" % str(e)
338+
"Could not upgrade pioarduino Core: %s" % str(e)
331339
)
332340
return False
333341

pioinstaller/penv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def create_core_penv(penv_dir=None, ignore_pythons=None):
6262
if not result_dir:
6363
raise exception.PIOInstallerException(
6464
"Could not create PIO Core Virtual Environment. Please report to "
65-
"https://github.com/platformio/platformio-core-installer/issues"
65+
"https://github.com/pioarduino/pioarduino-core-installer/issues"
6666
)
6767

6868
python_exe = os.path.join(

pioinstaller/python.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ def fetch_portable_python(dst):
9595
def get_portable_python_url():
9696
systype = util.get_systype()
9797
result = requests.get(
98-
"https://api.registry.platformio.org/v3/packages/"
99-
"platformio/tool/python-portable",
98+
"https://github.com/pioarduino/python-portable/"
99+
"releases/download/v3.11.7/python-portable.json",
100100
timeout=10,
101101
).json()
102102
versions = [
@@ -129,7 +129,7 @@ def check():
129129
if sys.version_info < (3, 6):
130130
raise exception.IncompatiblePythonError(
131131
"Unsupported Python version: %s. "
132-
"Minimum supported Python version is 3.6 or above."
132+
"Minimum supported Python version is 3.7 or above."
133133
% platform.python_version(),
134134
)
135135

@@ -239,7 +239,7 @@ def find_compatible_pythons(
239239
if missed_venv_module:
240240
# pylint:disable=line-too-long
241241
raise click.ClickException(
242-
"""Can not install PlatformIO Core due to a missed `venv` module in your Python installation.
242+
"""Can not install pioarduino Core due to a missed `venv` module in your Python installation.
243243
Please install this package manually using the OS package manager. For example:
244244
245245
$ apt-get install python3.%d-venv
@@ -249,9 +249,8 @@ def find_compatible_pythons(
249249
)
250250

251251
raise exception.IncompatiblePythonError(
252-
"Could not find compatible Python 3.6 or above in your system."
253-
"Please install the latest official Python 3 and restart installation:\n"
254-
"https://docs.platformio.org/page/faq.html#install-python-interpreter"
252+
"Could not find compatible Python 3.7 or above in your system."
253+
"Please install the latest official Python 3 and restart installation."
255254
)
256255

257256
return result

0 commit comments

Comments
 (0)