Skip to content

Commit

Permalink
Merge branch 'release/v1.2.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankravets committed Jan 20, 2024
2 parents 923523d + 30e73f7 commit 7d1203d
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 23 deletions.
2 changes: 1 addition & 1 deletion get-platformio.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pioinstaller/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import logging.config

VERSION = (1, 2, 1)
VERSION = (1, 2, 2)
__version__ = ".".join([str(s) for s in VERSION])

__title__ = "platformio-installer"
Expand Down
15 changes: 9 additions & 6 deletions pioinstaller/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,15 @@ def get_core_dir(force_to_root=False):
return core_dir


def get_cache_dir(path=None):
core_dir = path or get_core_dir()
path = os.path.join(core_dir, ".cache")
if not os.path.isdir(path):
os.makedirs(path)
return path
def get_cache_dir():
cache_dir = (
os.getenv("PLATFORMIO_CACHE_DIR")
if os.getenv("PLATFORMIO_CACHE_DIR")
else os.path.join(get_core_dir(), ".cache")
)
if not os.path.isdir(cache_dir):
os.makedirs(cache_dir)
return cache_dir


def install_platformio_core(shutdown_piohome=True, develop=False, ignore_pythons=None):
Expand Down
36 changes: 23 additions & 13 deletions pioinstaller/penv.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def create_core_penv(penv_dir=None, ignore_pythons=None):
get_penv_bin_dir(penv_dir), "python.exe" if util.IS_WINDOWS else "python"
)
init_state(python_exe, penv_dir)
install_pip(python_exe, penv_dir)
update_pip(python_exe, penv_dir)
click.echo("Virtual environment has been successfully created!")
return result_dir

Expand Down Expand Up @@ -107,7 +107,7 @@ def create_with_local_venv(python_exe, penv_dir):
util.safe_remove_dir(penv_dir)
log.debug("Creating virtual environment: %s", " ".join(command))
try:
subprocess.check_output(command, stderr=subprocess.PIPE)
subprocess.run(command, check=True)
return penv_dir
except Exception as e: # pylint:disable=broad-except
last_error = e
Expand All @@ -128,7 +128,7 @@ def create_with_remote_venv(python_exe, penv_dir):
raise exception.PIOInstallerException("Could not find virtualenv script")
command = [python_exe, venv_script_path, penv_dir]
log.debug("Creating virtual environment: %s", " ".join(command))
subprocess.check_output(command, stderr=subprocess.PIPE)
subprocess.run(command, check=True)
return penv_dir


Expand Down Expand Up @@ -178,26 +178,36 @@ def save_state(state, penv_dir=None):
return state_path


def install_pip(python_exe, penv_dir):
click.echo("Updating Python package manager (PIP) in a virtual environment")
def update_pip(python_exe, penv_dir):
click.echo("Updating Python package manager (PIP) in the virtual environment")
try:
log.debug("Creating pip.conf file in %s", penv_dir)
with open(os.path.join(penv_dir, "pip.conf"), "w") as fp:
fp.write("\n".join(["[global]", "user=no"]))

log.debug("Downloading 'get-pip.py' installer...")
get_pip_path = os.path.join(
os.path.dirname(penv_dir), ".cache", "tmp", os.path.basename(PIP_URL)
)
util.download_file(PIP_URL, get_pip_path)
try:
log.debug("Updating PIP ...")
subprocess.run(
[python_exe, "-m", "pip", "install", "-U", "pip"], check=True
)
except subprocess.CalledProcessError as e:
log.debug(
"Could not update PIP. Error: %s",
str(e),
)
log.debug("Downloading 'get-pip.py' installer...")
get_pip_path = os.path.join(
os.path.dirname(penv_dir), ".cache", "tmp", os.path.basename(PIP_URL)
)
util.download_file(PIP_URL, get_pip_path)
log.debug("Installing PIP ...")
subprocess.run([python_exe, get_pip_path], check=True)

log.debug("Installing pip")
subprocess.check_output([python_exe, get_pip_path], stderr=subprocess.PIPE)
click.echo("PIP has been successfully updated!")
return True
except Exception as e: # pylint:disable=broad-except
log.debug(
"Could not install pip. Error: %s",
"Could not install PIP. Error: %s",
str(e),
)
return False
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
"requests==2.31.0",
"colorama==0.4.6",
"semantic-version==2.8.5", # >2.8.5 does not support Python 3.6
"certifi==2023.7.22",
"certifi==2023.11.17",
# Misc
"wheel==0.41.0",
"wheel==0.42.0",
],
packages=find_packages(),
entry_points={
Expand Down

0 comments on commit 7d1203d

Please sign in to comment.