mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-29 17:47:14 +02:00
Fix an issue with incorrect handling of a custom package name
This commit is contained in:
22
HISTORY.rst
22
HISTORY.rst
@ -7,31 +7,25 @@ PlatformIO 3.0
|
||||
3.6.1 (2018-??-??)
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* Generate an `include <http://docs.platformio.org/page/projectconf/section_platformio.html#include-dir>`__
|
||||
and `test <http://docs.platformio.org/page/projectconf/section_platformio.html#test-dir>`__
|
||||
directories with a README file when initializing a new project
|
||||
* Generate an `include <http://docs.platformio.org/page/projectconf/section_platformio.html#include-dir>`__ and `test <http://docs.platformio.org/page/projectconf/section_platformio.html#test-dir>`__ directories with a README file when initializing a new project
|
||||
* Support in-line comments for multi-line value (``lib_deps``, ``build_flags``, etc) in `“platformio.ini” (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__
|
||||
* Improved `PIO Unified Debugger <https://docs.platformio.org/en/page/plus/debugging.html>`__
|
||||
for "mbed" framework and fixed issue with missed local variables
|
||||
* Improved `PIO Unified Debugger <https://docs.platformio.org/en/page/plus/debugging.html>`__ for "mbed" framework and fixed issue with missed local variables
|
||||
* Introduced `"Release" and "Debug" Build Configurations <http://docs.platformio.org/page/projectconf/build_configurations.html>`__
|
||||
* Build project in "Debug Mode" including debug information with a new
|
||||
``debug`` target using `platformio run <https://docs.platformio.org/page/userguide/cmd_run.html>`__ command or `targets <http://docs.platformio.org/page/projectconf/section_env_general.html#targets>`__ option in ``platformio.ini``.
|
||||
The last option allows to avoid project rebuilding between "Run/Debug" modes.
|
||||
* Build project in "Debug Mode" including debug information with a new ``debug`` target using `platformio run <https://docs.platformio.org/page/userguide/cmd_run.html>`__ command or `targets <http://docs.platformio.org/page/projectconf/section_env_general.html#targets>`__ option in ``platformio.ini``. The last option allows to avoid project rebuilding between "Run/Debug" modes.
|
||||
(`issue #1833 <https://github.com/platformio/platformio-core/issues/1833>`_)
|
||||
* Do not re-create ".gitignore" and ".travis.yml" files if they were removed
|
||||
from a project
|
||||
* Do not re-create ".gitignore" and ".travis.yml" files if they were removed from a project
|
||||
* Report about outdated `99-platformio-udev.rules <http://docs.platformio.org/page/faq.html#platformio-udev-rules>`__
|
||||
(`issue #1823 <https://github.com/platformio/platformio-core/issues/1823>`_)
|
||||
* Show a valid error when Internet is off-line while initializing a new project
|
||||
(`issue #1784 <https://github.com/platformio/platformio-core/issues/1784>`_)
|
||||
* Fixed an issue when dynamic build flags were not handled correctly
|
||||
(`issue #1799 <https://github.com/platformio/platformio-core/issues/1799>`_)
|
||||
* Fixed an issue when ``pio run -t monitor`` always uses first ``monitor_port``
|
||||
even with multiple environments
|
||||
* Fixed an issue when ``pio run -t monitor`` always uses first ``monitor_port`` even with multiple environments
|
||||
(`issue #1841 <https://github.com/platformio/platformio-core/issues/1841>`_)
|
||||
* Fixed an issue with broken includes when generating ``.clang_complete`` and
|
||||
space is used in path
|
||||
* Fixed an issue with broken includes when generating ``.clang_complete`` and space is used in path
|
||||
(`issue #1873 <https://github.com/platformio/platformio-core/issues/1873>`_)
|
||||
* Fixed an issue with incorrect handling of a custom package name when using `platformio lib install <http://docs.platformio.org/page/userguide/lib/cmd_install.html>`__ or `platformio platform install <http://docs.platformio.org/page/userguide/platforms/cmd_install.html>`__ commands
|
||||
|
||||
|
||||
3.6.0 (2018-08-06)
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
@ -259,6 +259,69 @@ class PkgInstallerMixin(object):
|
||||
raise e
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def parse_pkg_uri( # pylint: disable=too-many-branches
|
||||
text, requirements=None):
|
||||
text = str(text)
|
||||
name, url = None, None
|
||||
|
||||
# Parse requirements
|
||||
req_conditions = [
|
||||
"@" in text, not requirements, ":" not in text
|
||||
or text.rfind("/") < text.rfind("@")
|
||||
]
|
||||
if all(req_conditions):
|
||||
text, requirements = text.rsplit("@", 1)
|
||||
|
||||
# Handle PIO Library Registry ID
|
||||
if text.isdigit():
|
||||
text = "id=" + text
|
||||
# Parse custom name
|
||||
elif "=" in text and not text.startswith("id="):
|
||||
name, text = text.split("=", 1)
|
||||
|
||||
# Parse URL
|
||||
# if valid URL with scheme vcs+protocol://
|
||||
if "+" in text and text.find("+") < text.find("://"):
|
||||
url = text
|
||||
elif "/" in text or "\\" in text:
|
||||
git_conditions = [
|
||||
# Handle GitHub URL (https://github.com/user/package)
|
||||
text.startswith("https://github.com/") and not text.endswith(
|
||||
(".zip", ".tar.gz")),
|
||||
(text.split("#", 1)[0]
|
||||
if "#" in text else text).endswith(".git")
|
||||
]
|
||||
hg_conditions = [
|
||||
# Handle Developer Mbed URL
|
||||
# (https://developer.mbed.org/users/user/code/package/)
|
||||
# (https://os.mbed.com/users/user/code/package/)
|
||||
text.startswith("https://developer.mbed.org"),
|
||||
text.startswith("https://os.mbed.com")
|
||||
]
|
||||
if any(git_conditions):
|
||||
url = "git+" + text
|
||||
elif any(hg_conditions):
|
||||
url = "hg+" + text
|
||||
elif "://" not in text and (isfile(text) or isdir(text)):
|
||||
url = "file://" + text
|
||||
elif "://" in text:
|
||||
url = text
|
||||
# Handle short version of GitHub URL
|
||||
elif text.count("/") == 1:
|
||||
url = "git+https://github.com/" + text
|
||||
|
||||
# Parse name from URL
|
||||
if url and not name:
|
||||
_url = url.split("#", 1)[0] if "#" in url else url
|
||||
if _url.endswith(("\\", "/")):
|
||||
_url = _url[:-1]
|
||||
name = basename(_url)
|
||||
if "." in name and not name.startswith("."):
|
||||
name = name.rsplit(".", 1)[0]
|
||||
|
||||
return (name or text, requirements, url)
|
||||
|
||||
@staticmethod
|
||||
def get_install_dirname(manifest):
|
||||
name = re.sub(r"[^\da-z\_\-\. ]", "_", manifest['name'], flags=re.I)
|
||||
@ -316,11 +379,13 @@ class PkgInstallerMixin(object):
|
||||
manifest[key.strip()] = value.strip()
|
||||
|
||||
if src_manifest:
|
||||
if "name" not in manifest:
|
||||
manifest['name'] = src_manifest['name']
|
||||
if "version" in src_manifest:
|
||||
manifest['version'] = src_manifest['version']
|
||||
manifest['__src_url'] = src_manifest['url']
|
||||
# handle a custom package name
|
||||
autogen_name = self.parse_pkg_uri(manifest['__src_url'])[0]
|
||||
if "name" not in manifest or autogen_name != src_manifest['name']:
|
||||
manifest['name'] = src_manifest['name']
|
||||
|
||||
if "name" not in manifest:
|
||||
manifest['name'] = basename(pkg_dir)
|
||||
@ -563,69 +628,6 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin):
|
||||
def print_message(self, message, nl=True):
|
||||
click.echo("%s: %s" % (self.__class__.__name__, message), nl=nl)
|
||||
|
||||
@staticmethod
|
||||
def parse_pkg_uri( # pylint: disable=too-many-branches
|
||||
text, requirements=None):
|
||||
text = str(text)
|
||||
name, url = None, None
|
||||
|
||||
# Parse requirements
|
||||
req_conditions = [
|
||||
"@" in text, not requirements, ":" not in text
|
||||
or text.rfind("/") < text.rfind("@")
|
||||
]
|
||||
if all(req_conditions):
|
||||
text, requirements = text.rsplit("@", 1)
|
||||
|
||||
# Handle PIO Library Registry ID
|
||||
if text.isdigit():
|
||||
text = "id=" + text
|
||||
# Parse custom name
|
||||
elif "=" in text and not text.startswith("id="):
|
||||
name, text = text.split("=", 1)
|
||||
|
||||
# Parse URL
|
||||
# if valid URL with scheme vcs+protocol://
|
||||
if "+" in text and text.find("+") < text.find("://"):
|
||||
url = text
|
||||
elif "/" in text or "\\" in text:
|
||||
git_conditions = [
|
||||
# Handle GitHub URL (https://github.com/user/package)
|
||||
text.startswith("https://github.com/") and not text.endswith(
|
||||
(".zip", ".tar.gz")),
|
||||
(text.split("#", 1)[0]
|
||||
if "#" in text else text).endswith(".git")
|
||||
]
|
||||
hg_conditions = [
|
||||
# Handle Developer Mbed URL
|
||||
# (https://developer.mbed.org/users/user/code/package/)
|
||||
# (https://os.mbed.com/users/user/code/package/)
|
||||
text.startswith("https://developer.mbed.org"),
|
||||
text.startswith("https://os.mbed.com")
|
||||
]
|
||||
if any(git_conditions):
|
||||
url = "git+" + text
|
||||
elif any(hg_conditions):
|
||||
url = "hg+" + text
|
||||
elif "://" not in text and (isfile(text) or isdir(text)):
|
||||
url = "file://" + text
|
||||
elif "://" in text:
|
||||
url = text
|
||||
# Handle short version of GitHub URL
|
||||
elif text.count("/") == 1:
|
||||
url = "git+https://github.com/" + text
|
||||
|
||||
# Parse name from URL
|
||||
if url and not name:
|
||||
_url = url.split("#", 1)[0] if "#" in url else url
|
||||
if _url.endswith(("\\", "/")):
|
||||
_url = _url[:-1]
|
||||
name = basename(_url)
|
||||
if "." in name and not name.startswith("."):
|
||||
name = name.rsplit(".", 1)[0]
|
||||
|
||||
return (name or text, requirements, url)
|
||||
|
||||
def outdated(self, pkg_dir, requirements=None):
|
||||
"""
|
||||
Has 3 different results:
|
||||
|
@ -61,7 +61,7 @@ def test_global_install_archive(clirunner, validate_cliresult,
|
||||
"http://www.airspayce.com/mikem/arduino/RadioHead/RadioHead-1.62.zip",
|
||||
"https://github.com/bblanchon/ArduinoJson/archive/v5.8.2.zip",
|
||||
"https://github.com/bblanchon/ArduinoJson/archive/v5.8.2.zip@5.8.2",
|
||||
"http://dl.platformio.org/libraries/archives/0/9540.tar.gz",
|
||||
"SomeLib=http://dl.platformio.org/libraries/archives/0/9540.tar.gz",
|
||||
"https://github.com/Pedroalbuquerque/ESP32WebServer/archive/master.zip"
|
||||
])
|
||||
validate_cliresult(result)
|
||||
@ -75,7 +75,7 @@ def test_global_install_archive(clirunner, validate_cliresult,
|
||||
|
||||
items1 = [d.basename for d in isolated_pio_home.join("lib").listdir()]
|
||||
items2 = [
|
||||
"RadioHead-1.62", "ArduinoJson", "DallasTemperature_ID54",
|
||||
"RadioHead-1.62", "ArduinoJson", "SomeLib_ID54",
|
||||
"OneWire_ID1", "ESP32WebServer"
|
||||
]
|
||||
assert set(items1) >= set(items2)
|
||||
@ -158,7 +158,7 @@ def test_global_lib_list(clirunner, validate_cliresult):
|
||||
items1 = [i['name'] for i in json.loads(result.output)]
|
||||
items2 = [
|
||||
"ESP32WebServer", "ArduinoJson", "ArduinoJson", "ArduinoJson",
|
||||
"ArduinoJson", "AsyncMqttClient", "AsyncTCP", "DallasTemperature",
|
||||
"ArduinoJson", "AsyncMqttClient", "AsyncTCP", "SomeLib",
|
||||
"ESPAsyncTCP", "NeoPixelBus", "OneWire", "PJON", "PJON",
|
||||
"PubSubClient", "RFcontrol", "RadioHead-1.62", "platformio-libmirror",
|
||||
"rs485-nodeproto"
|
||||
@ -234,7 +234,7 @@ def test_global_lib_uninstall(clirunner, validate_cliresult,
|
||||
items2 = [
|
||||
"RadioHead-1.62", "rs485-nodeproto", "platformio-libmirror",
|
||||
"PubSubClient", "ArduinoJson@src-69ebddd821f771debe7ee734d3c7fa81",
|
||||
"ESPAsyncTCP_ID305", "DallasTemperature_ID54", "NeoPixelBus_ID547",
|
||||
"ESPAsyncTCP_ID305", "SomeLib_ID54", "NeoPixelBus_ID547",
|
||||
"PJON", "AsyncMqttClient_ID346", "ArduinoJson_ID64",
|
||||
"PJON@src-79de467ebe19de18287becff0a1fb42d", "ESP32WebServer"
|
||||
]
|
||||
|
Reference in New Issue
Block a user