Skip to content

Commit 553e755

Browse files
committed
Merge branch 'release/v0.3.0'
2 parents 5db7459 + 6548bc3 commit 553e755

File tree

12 files changed

+137
-116
lines changed

12 files changed

+137
-116
lines changed

.appveyor.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ environment:
1313
install:
1414
- cmd: git submodule update --init --recursive
1515
- cmd: SET PATH=C:\MinGW\bin;%PATH%
16-
- cmd: pip install --force-reinstall tox
16+
- cmd: pip install --force-reinstall tox pytest
1717

1818
test_script:
1919
- cmd: tox
20+
- cmd: python --version
21+
- cmd: py.test --verbose --capture=no --exitfirst tests
2022

2123
notifications:
2224
- provider: Slack

.travis.yml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,39 @@
1-
language: python
1+
language: generic
22

33
matrix:
44
include:
55
- os: linux
6+
dist: bionic
67
sudo: required
7-
python: 2.7
8-
env: TOX_ENV=py27
8+
env:
9+
- TOX_ENV=py27
910
- os: linux
11+
dist: bionic
1012
sudo: required
11-
python: 3.6
12-
env: TOX_ENV=py36
13+
env:
14+
- TOX_ENV=py37
1315
- os: osx
14-
language: generic
15-
env: TOX_ENV=py27
16+
env:
17+
- TOX_ENV=py27
18+
- os: osx
19+
env:
20+
- TOX_ENV=py37
1621

1722
install:
18-
- git submodule update --init --recursive
23+
- if [[ "$TOX_ENV" == "py27" ]] && [[ "$TRAVIS_OS_NAME" == "linux" ]]; then pyenv global 2.7; fi
24+
- if [[ "$TOX_ENV" == "py37" ]] && [[ "$TRAVIS_OS_NAME" == "linux" ]]; then pyenv global 3.7; fi
25+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]] && [[ "$TOX_ENV" == "py27" ]]; then pyenv install 2.7.17; pyenv global 2.7.17; eval "$(pyenv init -)"; fi
26+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]] && [[ "$TOX_ENV" == "py37" ]]; then pyenv install 3.7.5; pyenv global 3.7.5; eval "$(pyenv init -)"; fi
1927
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -fsSL https://bootstrap.pypa.io/get-pip.py | sudo python; fi
20-
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O /tmp/miniconda.sh; bash /tmp/miniconda.sh -b -p /tmp/miniconda; export MINICONDA="/tmp/miniconda/python"; else wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/miniconda.sh; bash /tmp/miniconda.sh -b -p /tmp/miniconda; export MINICONDA="/tmp/miniconda/python"; fi
21-
- pip install -U tox
28+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O /tmp/miniconda.sh; bash /tmp/miniconda.sh -b -p /tmp/miniconda; export MINICONDA="/tmp/miniconda/bin/python"; else wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/miniconda.sh; bash /tmp/miniconda.sh -b -p /tmp/miniconda; export MINICONDA="/tmp/miniconda/bin/python"; fi
29+
- python --version
30+
- pip install -U tox pytest
31+
- pip install -e .
2232

2333
script:
34+
- python --version
2435
- tox -e $TOX_ENV
36+
- make test
2537

2638
notifications:
2739
email: false
@@ -30,4 +42,4 @@ notifications:
3042
rooms:
3143
secure: GOUanPMgPnway2tjAblGgoI3FKJD4bM+1fzcpTi4Rutd58WOb9ejgEOTOtfPhrjuUfQt1SP04C5igMQa8o9fagmtI4PUleSC2b8aGivB18gyvMWH4uceHA645+ElulT45SPqkzTYeRsGjrjKD5O1D3JFk6lwFsfzQM5yZ2QSplpMvGG9IvGVfulNzCuSUa66fzzsSRgDWqAfc76s2o6YTF+/gngbxYgwjZp+dGuWOBhEvxEcKXAq4ohSCxPKzTqR87DzS+IMH/nt71hOFZyHRO+5sUDBIxiTyGCIesS9gYVrMgvjCFp8QHWYapj3E3CFaBC5XOE1r/DfNyHfvdqBn6zLwhZPtrflg3dfD8+uPbrwfYRihraUCdI0NiprJGYTSYyduJeg5MqHGD5saTQtpNAMZshxTTse7FcAYT7oYPGf2pxkAGkKfMZb/z3aAIDBQpcUIoWBuZURShFZ1qBmxtVaIiZ9Wm7fLvXXpmINn0xJNeCva57otv4RVWvPj3X5xhCFdshkUeaZndTZPF9RFoCf2FNIR9p4hKqVeBcvpEyMWg/BrczVeLy44NiLgzb8mBx87rU+M9Hxi6OUsCdpAJ4UgHtuQ6XeO0P380KSTDOULdOUuxvPcwoB3QyVxP8lxQNCCH+dFBbeRdQhbu7PYeTmKp0P7/omFiXEGdIycvY=
3244
on_failure: always
33-
on_success: change
45+
on_success: change

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ format:
1010
black --target-version py27 ./tests
1111

1212
test:
13-
py.test --verbose --capture=no --exitfirst -n 1 --dist=loadscope tests
13+
py.test --verbose --capture=no --exitfirst tests
1414

1515
before-commit: isort format lint test
1616

README.rst

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,10 @@ PlatformIO Core Installer
1212
:alt: License
1313

1414

15-
Standalone installer for `PlatformIO Core <https://docs.platformio.org/en/latest/core/index.html>`_.
15+
A standalone installer for `PlatformIO Core <https://docs.platformio.org/page/core/index.html>`_.
1616

1717
Usage
1818
-----
1919

20-
1. Install the latest Python 3 following `this guide <https://docs.platformio.org/en/latest/faq.html#install-python-interpreter>`_ (for Windows)
21-
2. Save contents of https://raw.githubusercontent.com/platformio/platformio-core-installer/develop/get-platformio.py to ``get-platformio.py``
22-
3. Please open system terminal (``cmd.exe``) and run this command
23-
24-
.. code-block::
25-
26-
python get-platformio.py
27-
28-
29-
More detailed documentation https://docs.platformio.org/page/core/installation.html#installer-script
20+
* `Installation Guide <https://docs.platformio.org/page/core/installation.html>`_
21+
* `Integration with custom applications (extensions, plugins) <https://docs.platformio.org/page/core/installation.htmll#integration-with-custom-applications-extensions-plugins>`_.

get-platformio.py

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

pioinstaller/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import logging.config
1616

17-
VERSION = (0, 2, 0)
17+
VERSION = (0, 3, 0)
1818
__version__ = ".".join([str(s) for s in VERSION])
1919

2020
__title__ = "platformio-installer"

pioinstaller/__main__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def cli(
4545
ctx.obj["dev"] = dev
4646
if not ctx.invoked_subcommand:
4747
click.echo("Installer version: %s" % __version__)
48-
click.echo("Platform: %s" % platform.platform())
48+
click.echo("Platform: %s" % platform.platform(terse=True))
4949
click.echo("Python version: %s" % sys.version)
5050
click.echo("Python path: %s" % sys.executable)
5151
try:
@@ -92,21 +92,21 @@ def python():
9292
@click.option("--auto-upgrade/--no-auto-upgrade", is_flag=True, default=True)
9393
@click.option("--version-requirements", default=None)
9494
@click.option(
95-
"--dump-state-path",
95+
"--dump-state",
9696
type=click.Path(
9797
exists=False, file_okay=True, dir_okay=True, writable=True, resolve_path=True
9898
),
9999
)
100100
@click.pass_context
101-
def core_check(ctx, auto_upgrade, version_requirements, dump_state_path):
101+
def core_check(ctx, auto_upgrade, version_requirements, dump_state):
102102
try:
103103
state = core.check(
104104
dev=ctx.obj.get("dev", False),
105105
auto_upgrade=auto_upgrade,
106106
version_requirements=version_requirements,
107107
)
108-
if dump_state_path:
109-
core.dump_state(target=dump_state_path, state=state)
108+
if dump_state:
109+
core.dump_state(target=dump_state, state=state)
110110
click.secho(
111111
"Found compatible PlatformIO Core %s -> %s"
112112
% (state.get("core_version"), state.get("platformio_exe")),

pioinstaller/core.py

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

15-
import io
1615
import json
1716
import logging
1817
import os
1918
import platform
2019
import subprocess
21-
import sys
2220
import time
2321

2422
import click
@@ -122,13 +120,17 @@ def install_platformio_core(shutdown_piohome=True, develop=False, ignore_pythons
122120

123121

124122
def check(dev=False, auto_upgrade=False, version_requirements=None):
125-
126123
# pylint: disable=bad-option-value, import-outside-toplevel, unused-import, import-error, unused-variable, cyclic-import
127124
from pioinstaller import penv
128125

129126
platformio_exe = os.path.join(
130127
penv.get_penv_bin_dir(), "platformio.exe" if util.IS_WINDOWS else "platformio",
131128
)
129+
python_exe = os.path.join(
130+
penv.get_penv_bin_dir(), "python.exe" if util.IS_WINDOWS else "python"
131+
)
132+
result = {}
133+
132134
if not os.path.isfile(platformio_exe):
133135
raise exception.InvalidPlatformIOCore(
134136
"PlatformIO executable not found in `%s`" % penv.get_penv_bin_dir()
@@ -141,18 +143,35 @@ def check(dev=False, auto_upgrade=False, version_requirements=None):
141143
)
142144

143145
try:
144-
# pylint: disable=bad-option-value, import-outside-toplevel, unused-import, import-error, unused-variable, cyclic-import
145-
import platformio
146-
except ImportError:
147-
raise exception.InvalidPlatformIOCore("Could not import PlatformIO module")
146+
result.update(fetch_python_state(python_exe))
147+
except subprocess.CalledProcessError as e:
148+
error = e.output.decode()
149+
raise exception.InvalidPlatformIOCore(
150+
"Could not import PlatformIO module. Error: %s" % error
151+
)
152+
153+
piocore_version = convert_version(result.get("core_version"))
154+
dev = dev or bool(piocore_version.prerelease if piocore_version else False)
155+
result.update(
156+
{
157+
"core_dir": get_core_dir(),
158+
"cache_dir": get_cache_dir(),
159+
"penv_dir": penv.get_penv_dir(),
160+
"penv_bin_dir": penv.get_penv_bin_dir(),
161+
"platformio_exe": platformio_exe,
162+
"installer_version": __version__,
163+
"python_exe": python_exe,
164+
"system": util.get_systype(),
165+
"is_develop_core": dev,
166+
}
167+
)
148168

149-
pio_version = get_pio_version(platformio)
150169
if version_requirements:
151170
try:
152-
if pio_version in semantic_version.Spec(version_requirements):
171+
if piocore_version in semantic_version.Spec(version_requirements):
153172
raise exception.InvalidPlatformIOCore(
154173
"PlatformIO Core version %s does not match version requirements %s."
155-
% (str(pio_version), version_requirements)
174+
% (str(piocore_version), version_requirements)
156175
)
157176
except ValueError:
158177
click.secho(
@@ -161,46 +180,28 @@ def check(dev=False, auto_upgrade=False, version_requirements=None):
161180
% version_requirements
162181
)
163182

164-
state = None
165-
166183
with open(os.path.join(penv.get_penv_dir(), "state.json")) as fp:
167-
state = json.load(fp)
168-
if state.get("platform") != platform.platform():
184+
penv_state = json.load(fp)
185+
if penv_state.get("platform") != platform.platform(terse=True):
169186
raise exception.InvalidPlatformIOCore(
170187
"PlatformIO installed using another platform `%s`. Your platform: %s"
171-
% (state.get("platform"), platform.platform())
188+
% (penv_state.get("platform"), platform.platform(terse=True))
172189
)
173190

174191
try:
175192
subprocess.check_output([platformio_exe, "--version"], stderr=subprocess.STDOUT)
176193
except subprocess.CalledProcessError as e:
177194
error = e.output.decode()
178195
raise exception.InvalidPlatformIOCore(
179-
"Could not run `%s --version`.\nError: %s" % (platformio, str(error))
196+
"Could not run `%s --version`.\nError: %s" % (platformio_exe, str(error))
180197
)
181198

182-
dev = dev or bool(pio_version.prerelease)
183-
result = {
184-
"core_dir": get_core_dir(),
185-
"cache_dir": get_cache_dir(),
186-
"penv_dir": penv.get_penv_dir(),
187-
"penv_bin_dir": penv.get_penv_bin_dir(),
188-
"platformio_exe": platformio_exe,
189-
"core_version": str(pio_version),
190-
"installer_version": __version__,
191-
"python_exe": os.path.join(
192-
penv.get_penv_bin_dir(), "python.exe" if util.IS_WINDOWS else "python"
193-
),
194-
"system": util.get_systype(),
195-
"is_develop_core": dev,
196-
}
197-
198199
if not auto_upgrade:
199200
return result
200201

201202
time_now = int(round(time.time()))
202203

203-
last_piocore_version_check = state.get("last_piocore_version_check")
204+
last_piocore_version_check = penv_state.get("last_piocore_version_check")
204205

205206
if (
206207
last_piocore_version_check
@@ -209,31 +210,43 @@ def check(dev=False, auto_upgrade=False, version_requirements=None):
209210
return result
210211

211212
with open(os.path.join(penv.get_penv_dir(), "state.json"), "w") as fp:
212-
state["last_piocore_version_check"] = time_now
213-
json.dump(state, fp)
213+
penv_state["last_piocore_version_check"] = time_now
214+
json.dump(penv_state, fp)
214215

215216
if not last_piocore_version_check:
216217
return result
217218

218219
upgrade_core(platformio_exe, dev)
219220

220-
result["core_version"] = get_pio_version(platformio)
221-
221+
try:
222+
result.update(fetch_python_state(python_exe))
223+
except: # pylint:disable=bare-except
224+
raise exception.InvalidPlatformIOCore("Could not import PlatformIO module")
222225
return result
223226

224227

225-
def get_pio_version(platformio):
228+
def fetch_python_state(python_exe):
229+
code = """import platform
230+
import json
231+
import platformio
232+
233+
state = {
234+
"core_version": platformio.__version__,
235+
"python_version": platform.python_version()
236+
}
237+
print(json.dumps(state))
238+
"""
239+
state = subprocess.check_output(
240+
[python_exe, "-c", code,], stderr=subprocess.STDOUT,
241+
)
242+
return json.loads(state.decode())
243+
244+
245+
def convert_version(version):
226246
try:
227-
if sys.version_info[0] == 3:
228-
# pylint: disable=bad-option-value, import-outside-toplevel, unused-import, import-error, unused-variable, cyclic-import
229-
import importlib
230-
231-
importlib.reload(platformio) # pylint:disable=no-member
232-
else:
233-
reload(platformio)
234-
return semantic_version.Version(util.pepver_to_semver(platformio.__version__))
247+
return semantic_version.Version(util.pepver_to_semver(version))
235248
except: # pylint:disable=bare-except
236-
return platformio.__version__
249+
return None
237250

238251

239252
def upgrade_core(platformio_exe, dev=False):
@@ -259,5 +272,5 @@ def dump_state(target, state):
259272
if not os.path.isdir(os.path.dirname(target)):
260273
os.makedirs(os.path.dirname(target))
261274

262-
with io.open(target, "w", encoding="utf-8") as fp:
275+
with open(target, "w") as fp:
263276
json.dump(state, fp)

pioinstaller/penv.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ def create_core_penv(penv_dir=None, ignore_pythons=None):
6565

6666
if not result_dir:
6767
raise exception.PIOInstallerException(
68-
"Could not create PIO Core Virtual Environment. "
69-
"Please create it manually -> http://bit.ly/pio-core-virtualenv"
68+
"Could not create PIO Core Virtual Environment. Please report to "
69+
"https://github.com/platformio/platformio-core-installer/issues"
7070
)
7171

7272
python_exe = os.path.join(
@@ -150,7 +150,7 @@ def add_state_info(python_exe, penv_dir):
150150
"created_on": int(round(time.time())),
151151
"python": {"path": python_exe, "version": python_version,},
152152
"installer_version": __version__,
153-
"platform": platform.platform(),
153+
"platform": platform.platform(terse=True),
154154
}
155155
with open(os.path.join(penv_dir, "state.json"), "w") as fp:
156156
json.dump(state, fp)

setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@
3838
"click==7.1.1",
3939
"requests==2.23.0",
4040
"colorama==0.4.3",
41-
"semantic-version==2.8.4"
41+
"semantic-version==2.8.4",
42+
"certifi==2020.04.05.1",
43+
# Misc
44+
"wheel==0.34.2",
4245
],
4346
packages=find_packages(),
4447
entry_points={

0 commit comments

Comments
 (0)