From a1483c263fa92442629deb619af1ea1b3a13e63e Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 22 Aug 2015 17:09:28 +0300 Subject: [PATCH] Simplified installation process of PlatformIO // Resolve #274 --- HISTORY.rst | 3 ++ docs/ci/appveyor.rst | 23 +++--------- docs/installation.rst | 73 +++++++++++++++++++++--------------- platformio/__init__.py | 2 +- platformio/__main__.py | 1 - scripts/appveyor/install.ps1 | 15 +++----- scripts/get-platformio.py | 14 +++---- setup.py | 2 +- tox.ini | 3 -- 9 files changed, 63 insertions(+), 73 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 0c7e75de..bf77dfd3 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -12,6 +12,9 @@ Release History `windows_x86 `__ development platforms (`issue #263 `_) +* Simplified `installation `__ + process of PlatformIO + (`issue #274 `_) * Added support for Adafruit Gemma board to `atmelavr `__ platform diff --git a/docs/ci/appveyor.rst b/docs/ci/appveyor.rst index edfafcd5..e05ca4f2 100644 --- a/docs/ci/appveyor.rst +++ b/docs/ci/appveyor.rst @@ -113,17 +113,12 @@ same for the all projects, don't need to modify them): function InstallPip ($python_home) { - $pip_path = $python_home + "/Scripts/pip.exe" $python_path = $python_home + "/python.exe" - if (-not(Test-Path $pip_path)) { - Write-Host "Installing pip..." - $webclient = New-Object System.Net.WebClient - $webclient.DownloadFile($GET_PIP_URL, $GET_PIP_PATH) - Write-Host "Executing:" $python_path $GET_PIP_PATH - Start-Process -FilePath "$python_path" -ArgumentList "$GET_PIP_PATH" -Wait -Passthru - } else { - Write-Host "pip already installed." - } + Write-Host "Installing pip..." + $webclient = New-Object System.Net.WebClient + $webclient.DownloadFile($GET_PIP_URL, $GET_PIP_PATH) + Write-Host "Executing:" $python_path $GET_PIP_PATH + Start-Process -FilePath "$python_path" -ArgumentList "$GET_PIP_PATH" -Wait -Passthru } function InstallPackage ($python_home, $pkg) { @@ -131,19 +126,11 @@ same for the all projects, don't need to modify them): & $pip_path install -U $pkg } - function InstallScons ($python_home) { - Write-Host "Start installing Scons" - $pip_path = $python_home + "/Scripts/pip.exe" - & $pip_path install --egg "http://dl.platformio.org/scons.zip" - Write-Host "Scons installed" - } - function main () { InstallPython $env:PYTHON_VERSION $env:PYTHON_ARCH $env:PYTHON_HOME InstallPip $env:PYTHON_HOME InstallPackage $env:PYTHON_HOME setuptools InstallPackage $env:PYTHON_HOME platformio - InstallScons $env:PYTHON_HOME } main diff --git a/docs/installation.rst b/docs/installation.rst index 59670659..1ad6142f 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -18,7 +18,7 @@ System requirements * Mac OS X * Linux, +ARM * Windows -* `Python 2.6 or Python 2.7 `_ +* Python 2.6.x or Python 2.7.x(recommended) All commands below should be executed in `Command-line `_ @@ -29,6 +29,9 @@ application: `Command Prompt `_ (``cmd.exe``) application. +Troubleshooting +--------------- + .. warning:: If you are going to run *PlatformIO* from **subprocess**, you :ref:`MUST DISABLE ` all prompts. @@ -41,34 +44,52 @@ application: **Windows Users:** Please check that you have correctly installed USB driver from board manufacturer -Troubleshooting ---------------- - For further details, frequently questions, please refer to :ref:`faq`. Installation Methods -------------------- +.. note:: + **Windows Users**: `Download the latest Python 2.7.x + `_ and install it. + *DON'T FORGET* to select ``Add python.exe to Path`` feature in installation + dialog on "Customize" stage. + Please *choose one of* the following installation methods: -Super-Quick (Mac / Linux) -~~~~~~~~~~~~~~~~~~~~~~~~~ +Python Package Manager +~~~~~~~~~~~~~~~~~~~~~~ -To install or upgrade *PlatformIO* paste that at a *Terminal* prompt -(**you MIGHT need** to run ``sudo`` first, just for installation): +Run the following (**MAY require** administrator access ``sudo``): .. code-block:: bash - [sudo] python -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/master/scripts/get-platformio.py)" + pip install --upgrade pip setuptools scons + pip install platformio + +If your computer does not recognize ``pip`` command, try to install it first +using `these instructions `_. + +Installer Script +~~~~~~~~~~~~~~~~ + +Super-Quick (Mac / Linux) +''''''''''''''''''''''''' + +To install or upgrade *PlatformIO* paste that at a *Terminal* prompt +(**MAY require** administrator access ``sudo``): + +.. code-block:: bash + + python -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/master/scripts/get-platformio.py)" -Installer Script (Mac / Linux / Windows) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Local Download (Mac / Linux / Windows) +'''''''''''''''''''''''''''''''''''''' To install or upgrade *PlatformIO*, download (save as...) `get-platformio.py `_ -script. Then run the following (**you MIGHT need** to run ``sudo`` first, -just for installation): +script. Then run the following (**MAY require** administrator access ``sudo``): .. code-block:: bash @@ -96,9 +117,9 @@ Full Guide .. code-block:: bash - $ python --version + python --version -*Windows OS* Users only: +*Windows Users* only: * `Download Python 2.7 `_ and install it. * Add to PATH system variable ``;C:\Python27;C:\Python27\Scripts;`` and @@ -106,30 +127,21 @@ Full Guide article `How to set the path and environment variables in Windows `_. - -2. Check a ``pip`` tool for installing and managing *Python* packages: +2. Install a ``platformio`` and related packages: .. code-block:: bash - $ pip search platformio - -You should see short information about ``platformio`` package. + pip install --upgrade pip setuptools scons + pip install platformio If your computer does not recognize ``pip`` command, try to install it first using `these instructions `_. -3. Install a ``platformio`` and related packages: +For upgrading ``platformio`` to the latest version: .. code-block:: bash - $ pip install platformio && pip install --egg scons - -For upgrading the ``platformio`` to new version please use this command: - -.. code-block:: bash - - $ pip install -U platformio - + pip install --upgrade platformio Development Version ~~~~~~~~~~~~~~~~~~~ @@ -141,7 +153,8 @@ Install the latest PlatformIO from the ``develop`` branch: .. code-block:: bash - $ pip install https://github.com/platformio/platformio/archive/develop.zip + pip install -U pip setuptools scons + pip install -U https://github.com/platformio/platformio/archive/develop.zip If you want to be up-to-date with the latest ``develop`` version of PlatformIO, then you need to re-install PlatformIO each time if you see the new commits in diff --git a/platformio/__init__.py b/platformio/__init__.py index 9988d3fd..c2a8a344 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -1,7 +1,7 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. -VERSION = (2, 3, "0a1") +VERSION = (2, 3, "0a2") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/__main__.py b/platformio/__main__.py index b6f88342..fc1af876 100644 --- a/platformio/__main__.py +++ b/platformio/__main__.py @@ -80,7 +80,6 @@ def main(): ) return 1 - cli(None, None) except Exception as e: # pylint: disable=W0703 if not isinstance(e, exception.ReturnErrorCode): diff --git a/scripts/appveyor/install.ps1 b/scripts/appveyor/install.ps1 index 311cb38d..61e93c1e 100644 --- a/scripts/appveyor/install.ps1 +++ b/scripts/appveyor/install.ps1 @@ -59,17 +59,12 @@ function InstallPython ($python_version, $architecture, $python_home) { function InstallPip ($python_home) { - $pip_path = $python_home + "/Scripts/pip.exe" $python_path = $python_home + "/python.exe" - if (-not(Test-Path $pip_path)) { - Write-Host "Installing pip..." - $webclient = New-Object System.Net.WebClient - $webclient.DownloadFile($GET_PIP_URL, $GET_PIP_PATH) - Write-Host "Executing:" $python_path $GET_PIP_PATH - Start-Process -FilePath "$python_path" -ArgumentList "$GET_PIP_PATH" -Wait -Passthru - } else { - Write-Host "pip already installed." - } + Write-Host "Installing pip..." + $webclient = New-Object System.Net.WebClient + $webclient.DownloadFile($GET_PIP_URL, $GET_PIP_PATH) + Write-Host "Executing:" $python_path $GET_PIP_PATH + Start-Process -FilePath "$python_path" -ArgumentList "$GET_PIP_PATH" -Wait -Passthru } function InstallPackage ($python_home, $pkg) { diff --git a/scripts/get-platformio.py b/scripts/get-platformio.py index 3054d2bb..bcab3d14 100644 --- a/scripts/get-platformio.py +++ b/scripts/get-platformio.py @@ -87,21 +87,17 @@ def install_pip(): def install_pypi_packages(packages): - for pipargs in packages: - print (exec_python_cmd([ - "-m", "pip.__main__" if sys.version_info < (2, 7, 0) else "pip", - "install", "-U"] + pipargs)) + print (exec_python_cmd([ + "-m", "pip.__main__" if sys.version_info < (2, 7, 0) else "pip", + "install", "-U"] + packages)) def main(): steps = [ ("Fixing Windows %PATH% Environment", fix_winpython_pathenv, []), ("Installing Python Package Manager", install_pip, []), - ("Installing PlatformIO and dependencies", install_pypi_packages, [ - [["setuptools"], ["platformio"], [ - "--egg", "http://dl.platformio.org/scons.zip" - ]] - ]) + ("Installing PlatformIO and dependencies", install_pypi_packages, + [["setuptools", "platformio"]]) ] if not IS_WINDOWS: diff --git a/setup.py b/setup.py index 6ba5f435..f068f99a 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ setup( "click>=3.0", "pyserial", "requests>=2.4.0", - # "SCons" + "SCons" ] + (["colorama"] if system() == "Windows" else []), packages=find_packages(), package_data={ diff --git a/tox.ini b/tox.ini index 1f425256..df5261d5 100644 --- a/tox.ini +++ b/tox.ini @@ -10,8 +10,6 @@ usedevelop = True deps = isort flake8 -commands = - pip install --egg http://dl.platformio.org/scons.zip [testenv:docs] basepython = python2.7 @@ -48,5 +46,4 @@ passenv = * deps = pytest commands = {envpython} --version - pip install --egg http://dl.platformio.org/scons.zip py.test -v --basetemp="{envtmpdir}" tests