From 09761004dd5ebdfdbb6cc49debeab9818cd977d2 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 24 Sep 2014 22:33:40 +0300 Subject: [PATCH 01/14] Ready for 0.8.0-dev --- HISTORY.rst | 4 ++++ platformio/__init__.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 423b0c19ab..98dc24a7b9 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,6 +1,10 @@ Release History =============== +0.8.0 (?) +--------- + + 0.7.0 (2014-09-24) ------------------ diff --git a/platformio/__init__.py b/platformio/__init__.py index dcc97ca2c5..b864b011ec 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -1,7 +1,7 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. -VERSION = (0, 7, 0) +VERSION = (0, 8, "0-dev") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 2a7e67b8e43a0908dbb5a1c345bb295e25272730 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 30 Sep 2014 20:55:08 +0300 Subject: [PATCH 02/14] Fix bug with order for "includes" in conversation from INO/PDE to CPP --- HISTORY.rst | 2 ++ platformio/builder/tools/platformio.py | 15 +++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 98dc24a7b9..d27a2a724e 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,6 +4,8 @@ Release History 0.8.0 (?) --------- +* Fixed bug with order for includes in conversation from INO/PDE to CPP + 0.7.0 (2014-09-24) ------------------ diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 5285309fec..a8d19e9da8 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -173,22 +173,29 @@ def delete_tmpcpp(files): continue ino_contents = item.get_text_contents() - # fetch prototypes - regexp = re.compile( + re_includes = re.compile(r"^(#include\s+(?:\<|\")[^\r\n]+)", + re.M | re.I) + includes = re_includes.findall(ino_contents) + prototypes = re.findall( r"""^( (?:\s*[a-z_\d]+){1,2} # return type \s+[a-z_\d]+\s* # name of prototype \([a-z_,\.\*\&\[\]\s\d]*\) # args )\s*\{ # must end with { """, + ino_contents, re.X | re.M | re.I ) - prototypes = regexp.findall(ino_contents) - # print prototypes + # print includes, prototypes + + # disable previous includes + ino_contents = re_includes.sub("//\g<1>", ino_contents) # create new temporary C++ valid file with open(cppfile, "w") as f: f.write("#include \n") + if includes: + f.write("%s\n" % "\n".join(includes)) if prototypes: f.write("%s;\n" % ";\n".join(prototypes)) f.write("#line 1 \"%s\"\n" % basename(item.path)) From 1c4b97c2f23f24547a88b8258da9298b7e4050b0 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 30 Sep 2014 20:58:30 +0300 Subject: [PATCH 03/14] Fix lint warning with anomalous backslash --- platformio/builder/tools/platformio.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index a8d19e9da8..19302a1a0a 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -189,7 +189,7 @@ def delete_tmpcpp(files): # print includes, prototypes # disable previous includes - ino_contents = re_includes.sub("//\g<1>", ino_contents) + ino_contents = re_includes.sub(r"//\1", ino_contents) # create new temporary C++ valid file with open(cppfile, "w") as f: From 024be2e094d8119ff6009a10dc7c2eff169e681c Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 3 Oct 2014 19:47:34 +0300 Subject: [PATCH 04/14] Automatic detection of port on upload (resolve #15) --- HISTORY.rst | 1 + platformio/builder/scripts/atmelavr.py | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index d27a2a724e..28e6f71ec2 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -5,6 +5,7 @@ Release History --------- * Fixed bug with order for includes in conversation from INO/PDE to CPP +* Automatic detection of port on upload (`issue #15 `_) 0.7.0 (2014-09-24) diff --git a/platformio/builder/scripts/atmelavr.py b/platformio/builder/scripts/atmelavr.py index dcaed8f637..5df536fa5a 100644 --- a/platformio/builder/scripts/atmelavr.py +++ b/platformio/builder/scripts/atmelavr.py @@ -11,7 +11,7 @@ from SCons.Script import (AlwaysBuild, Builder, COMMAND_LINE_TARGETS, Default, DefaultEnvironment, Exit) -from platformio.util import reset_serialport +from platformio.util import get_serialports, reset_serialport env = DefaultEnvironment() @@ -164,9 +164,19 @@ def rpi_sysgpio(path, value): is_uptarget = (set(["upload", "uploadlazy", "uploadeep"]) & set(COMMAND_LINE_TARGETS)) -if is_uptarget and not env.subst("$UPLOAD_PORT"): - Exit("Please specify environment 'upload_port' or use global " - "--upload-port option.") + +if is_uptarget: + # try autodetect upload port + if "UPLOAD_PORT" not in env: + for item in get_serialports(): + if "VID:PID" in item['hwid']: + print ("Auto-detected UPLOAD_PORT: %s" % item['port']) + env['UPLOAD_PORT'] = item['port'] + break + + if "UPLOAD_PORT" not in env: + Exit("Please specify environment 'upload_port' or use global " + "--upload-port option.") # # Setup default targets From 907a72d3bd2ab17d7230b13dd32032805b7962f5 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 3 Oct 2014 19:48:17 +0300 Subject: [PATCH 05/14] Move to latest version of SCons --- scripts/get-platformio.py | 12 ++++++++---- tox.ini | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/get-platformio.py b/scripts/get-platformio.py index aff8ba6c48..be38fcdeb9 100644 --- a/scripts/get-platformio.py +++ b/scripts/get-platformio.py @@ -73,16 +73,20 @@ def install_pip(): def install_pypi_packages(packages): - for p in packages: - print (exec_python_cmd(["-m", "pip", "install", "-U"] + p.split())) + for pipargs in packages: + print (exec_python_cmd(["-m", "pip", "install", "-U"] + pipargs)) def main(): steps = [ ("Fixing Windows %PATH% Environment", fix_winpython_pathenv, []), ("Installing Python Package Manager", install_pip, []), - ("Installing PlatformIO and dependencies", install_pypi_packages, - (["platformio", "--egg scons"],)), + ("Installing PlatformIO and dependencies", install_pypi_packages, [ + [["platformio"], [ + "--egg", + "http://sourceforge.net/projects/scons/files/latest/download" + ]] + ]) ] if not IS_WINDOWS: diff --git a/tox.ini b/tox.ini index 0185fd254a..28baf1c180 100644 --- a/tox.ini +++ b/tox.ini @@ -15,7 +15,7 @@ deps = isort flake8 commands = - pip install --egg scons + pip install --egg http://sourceforge.net/projects/scons/files/latest/download [testenv:docs] deps = From 7de5166694ec2d3e3816c0b202bebb753665054f Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 3 Oct 2014 19:54:02 +0300 Subject: [PATCH 06/14] Change "print" function to Py2.x --- platformio/builder/scripts/atmelavr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/builder/scripts/atmelavr.py b/platformio/builder/scripts/atmelavr.py index 5df536fa5a..e3806c2389 100644 --- a/platformio/builder/scripts/atmelavr.py +++ b/platformio/builder/scripts/atmelavr.py @@ -170,7 +170,7 @@ def rpi_sysgpio(path, value): if "UPLOAD_PORT" not in env: for item in get_serialports(): if "VID:PID" in item['hwid']: - print ("Auto-detected UPLOAD_PORT: %s" % item['port']) + print "Auto-detected UPLOAD_PORT: %s" % item['port'] env['UPLOAD_PORT'] = item['port'] break From 6a775f39511520274c4d6f216166dd6fa8891ccd Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 4 Oct 2014 18:53:59 +0300 Subject: [PATCH 07/14] Skip "platformio" section from "run" process --- platformio/commands/run.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/platformio/commands/run.py b/platformio/commands/run.py index 5e989c1798..4ed95befcf 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -25,7 +25,10 @@ def cli(environment, target, upload_port): raise UnknownEnvNames(", ".join(unknown)) for section in config.sections(): - if section[:4] != "env:": + # skip main configuration section + if section == "platformio": + continue + elif section[:4] != "env:": raise InvalidEnvName(section) envname = section[4:] From 719e03da168188c7dbdace64cb4abca15897171a Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 4 Oct 2014 23:30:51 +0300 Subject: [PATCH 08/14] Expand user path from lib_dir --- platformio/util.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/platformio/util.py b/platformio/util.py index c29347d95a..ef42b73cb4 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -46,7 +46,11 @@ def get_lib_dir(): config = get_project_config() if (config.has_section("platformio") and config.has_option("platformio", "lib_dir")): - return config.get("platformio", "lib_dir") + lib_dir = config.get("platformio", "lib_dir") + if lib_dir.startswith("~"): + return expanduser(lib_dir) + else: + return lib_dir except NotPlatformProject: pass return join(get_home_dir(), "lib") From 9ead140b6e2c57e971e77fffa81f0c1c18eef9ad Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 5 Oct 2014 23:34:40 +0300 Subject: [PATCH 09/14] Fix lib update crashing when no libs are installed (resolve issue #19) --- HISTORY.rst | 1 + platformio/commands/lib.py | 5 ++++- platformio/libmanager.py | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 28e6f71ec2..b20c9b4512 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -6,6 +6,7 @@ Release History * Fixed bug with order for includes in conversation from INO/PDE to CPP * Automatic detection of port on upload (`issue #15 `_) +* Fixed lib update crashing when no libs are installed (`issue #19 `_) 0.7.0 (2014-09-24) diff --git a/platformio/commands/lib.py b/platformio/commands/lib.py index 9de31be267..07aef25a71 100644 --- a/platformio/commands/lib.py +++ b/platformio/commands/lib.py @@ -140,9 +140,12 @@ def lib_show(name): @cli.command("update", short_help="Update installed libraries") def lib_update(): lm = LibraryManager(get_lib_dir()) + lib_names = lm.get_installed() - versions = get_api_result("/lib/version/" + ",".join(lib_names)) + if not lib_names: + return + versions = get_api_result("/lib/version/" + ",".join(lib_names)) for name in lib_names: info = lm.get_info(name) diff --git a/platformio/libmanager.py b/platformio/libmanager.py index 2fb4a18587..4a522d78bc 100644 --- a/platformio/libmanager.py +++ b/platformio/libmanager.py @@ -33,6 +33,8 @@ def unpack(pkgpath, dest_dir): def get_installed(self): items = [] + if not isdir(self.lib_dir): + return items for item in listdir(self.lib_dir): conf_path = join(self.lib_dir, item, self.CONFIG_NAME) if isfile(conf_path): From 2e03d27d27337bccf5ef312513242142abd6bf97 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 6 Oct 2014 13:57:40 +0300 Subject: [PATCH 10/14] Update "requests" to 2.4.3 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 984e12bdab..9a7891b485 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ click==3.3 colorama==0.3.1 pyserial==2.7 -requests==2.4.1 +requests==2.4.3 scons==2.3.0 From dcfa8995206d1071785fb0d43dcca2aaec68bd0b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 6 Oct 2014 14:09:22 +0300 Subject: [PATCH 11/14] Fix make directory operation for invalid library name --- platformio/libmanager.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/platformio/libmanager.py b/platformio/libmanager.py index 4a522d78bc..2f6960d91b 100644 --- a/platformio/libmanager.py +++ b/platformio/libmanager.py @@ -55,14 +55,13 @@ def install(self, name, version=None): if self.is_installed(name): raise LibAlreadyInstalledError() - _lib_dir = join(self.lib_dir, name) - if not isdir(_lib_dir): - makedirs(_lib_dir) - dlinfo = get_api_result("/lib/download/" + name, dict(version=version) if version else None) try: dlpath = self.download(dlinfo['url'], gettempdir()) + _lib_dir = join(self.lib_dir, name) + if not isdir(_lib_dir): + makedirs(_lib_dir) self.unpack(dlpath, _lib_dir) finally: remove(dlpath) From 8649114546b5402c6c514664c31204ad2049a447 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 6 Oct 2014 16:15:40 +0300 Subject: [PATCH 12/14] Fix link to Web Library Search site --- docs/librarymanager/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/librarymanager/index.rst b/docs/librarymanager/index.rst index 3840872c87..73b4fd0432 100644 --- a/docs/librarymanager/index.rst +++ b/docs/librarymanager/index.rst @@ -9,7 +9,7 @@ Library Manager *PlatformIO Library Manager* allows you to organize external embedded libraries. You can search for new libraries via :ref:`Command Line ` -or `WebSite `_ interfaces. +or `WebSite `_ interfaces. You don't need to bother for finding the latest version of library. Due to :ref:`cmd_lib_update` command you will have up-to-date external libraries. From c90ef9919b0ea232ecb20101b7669a19cd72e8bd Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 6 Oct 2014 16:21:24 +0300 Subject: [PATCH 13/14] Improve title --- docs/index.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index d76fb76d61..05b996a0ab 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,5 +1,5 @@ -PlatformIO: A cross-platform code builder and library manager -============================================================= +PlatformIO: A cross-platform code builder and library manager (Arduino, MSP430, ARM) +==================================================================================== `Website + Library Search `_ | `Project Examples `_ | From 466026b5c62c70c9da217afa0c134860200416a8 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 6 Oct 2014 23:27:49 +0300 Subject: [PATCH 14/14] Update project description, history and etc --- .gitignore | 1 + HISTORY.rst | 3 +++ platformio/__init__.py | 5 +++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 2de54be75f..f3fa86a211 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ examples/ide-eclipse/.metadata examples/ide-eclipse/RemoteSystemsTempFiles docs/_build +dist diff --git a/HISTORY.rst b/HISTORY.rst index b20c9b4512..610b2eb6bf 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,6 +4,9 @@ Release History 0.8.0 (?) --------- +0.7.1 (2014-10-06) +------------------ + * Fixed bug with order for includes in conversation from INO/PDE to CPP * Automatic detection of port on upload (`issue #15 `_) * Fixed lib update crashing when no libs are installed (`issue #19 `_) diff --git a/platformio/__init__.py b/platformio/__init__.py index b864b011ec..846f38f9f6 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -1,11 +1,12 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. -VERSION = (0, 8, "0-dev") +VERSION = (0, 7, 1) __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" -__description__ = ("A cross-platform code builder and library manager") +__description__ = ("A cross-platform code builder and library manager " + "(Arduino, MSP430, ARM)") __url__ = "http://platformio.ikravets.com" __author__ = "Ivan Kravets"