Skip to content

Commit 80e2a83

Browse files
committed
Merge branch 'release/v0.3.3'
2 parents d2be849 + 1a059a5 commit 80e2a83

File tree

8 files changed

+59
-33
lines changed

8 files changed

+59
-33
lines changed

get-platformio.py

Lines changed: 23 additions & 7 deletions
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, 3, 2)
17+
VERSION = (0, 3, 3)
1818
__version__ = ".".join([str(s) for s in VERSION])
1919

2020
__title__ = "platformio-installer"

pioinstaller/pack/packer.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,34 +36,28 @@ def pack(target):
3636
if not os.path.isdir(os.path.dirname(target)):
3737
os.makedirs(os.path.dirname(target))
3838

39-
tmpdir = tempfile.mkdtemp()
40-
create_wheels(os.path.dirname(util.get_source_dir()), tmpdir)
39+
tmp_dir = tempfile.mkdtemp()
40+
create_wheels(os.path.dirname(util.get_source_dir()), tmp_dir)
4141

4242
new_data = io.BytesIO()
43-
for whl in os.listdir(tmpdir):
44-
with zipfile.ZipFile(os.path.join(tmpdir, whl)) as existing_zip:
43+
for whl in os.listdir(tmp_dir):
44+
with zipfile.ZipFile(os.path.join(tmp_dir, whl)) as existing_zip:
4545
with zipfile.ZipFile(new_data, mode="a") as new_zip:
4646
for zinfo in existing_zip.infolist():
4747
if re.search(r"\.dist-info/", zinfo.filename):
4848
continue
4949
new_zip.writestr(zinfo, existing_zip.read(zinfo))
5050
zipdata = base64.b64encode(new_data.getvalue()).decode("utf8")
5151
with open(target, "w") as fp:
52-
with open(
53-
os.path.join(util.get_source_dir(), "pack", "template.py"), "r"
54-
) as fp_template:
55-
fp.write(
56-
fp_template.read().format(
57-
installed_version="latest", zipfile_content=zipdata,
58-
),
59-
)
52+
with open(os.path.join(util.get_source_dir(), "pack", "template.py")) as fptlp:
53+
fp.write(fptlp.read().format(zipfile_content=zipdata))
6054

6155
# Ensure the permissions on the newly created file
6256
oldmode = os.stat(target).st_mode & 0o7777
6357
newmode = (oldmode | 0o555) & 0o7777
6458
os.chmod(target, newmode)
6559

6660
# Clearing up
67-
shutil.rmtree(tmpdir)
61+
shutil.rmtree(tmp_dir)
6862

6963
return target

pioinstaller/pack/template.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,43 @@
2525
"""
2626

2727

28+
def create_temp_dir():
29+
try:
30+
cur_dir = os.path.dirname(os.path.realpath(__file__))
31+
tmp_dir = tempfile.mkdtemp(dir=cur_dir, prefix=".piocore-installer-")
32+
testscript_path = os.path.join(tmp_dir, "test.py")
33+
with open(testscript_path, "w") as fp:
34+
fp.write("print(1)")
35+
assert os.path.isfile(testscript_path)
36+
os.remove(testscript_path)
37+
return tmp_dir
38+
except (AssertionError, NameError):
39+
pass
40+
return tempfile.mkdtemp()
41+
42+
2843
def bootstrap():
2944
import pioinstaller.__main__
3045

3146
pioinstaller.__main__.main()
3247

3348

3449
def main():
35-
tmpdir = None
50+
runtime_tmp_dir = create_temp_dir()
51+
os.environ["TMPDIR"] = runtime_tmp_dir
52+
tmp_dir = tempfile.mkdtemp(dir=runtime_tmp_dir)
3653
try:
37-
tmpdir = tempfile.mkdtemp()
38-
39-
pioinstaller_zip = os.path.join(tmpdir, "pioinstaller.zip")
54+
pioinstaller_zip = os.path.join(tmp_dir, "pioinstaller.zip")
4055
with open(pioinstaller_zip, "wb") as fp:
4156
fp.write(b64decode(DEPENDENCIES))
4257

4358
sys.path.insert(0, pioinstaller_zip)
4459

4560
bootstrap()
4661
finally:
47-
if tmpdir:
48-
shutil.rmtree(tmpdir, ignore_errors=True)
62+
for d in (runtime_tmp_dir, tmp_dir):
63+
if d and os.path.isdir(d):
64+
shutil.rmtree(d, ignore_errors=True)
4965

5066

5167
if __name__ == "__main__":

pioinstaller/penv.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def create_with_remote_venv(python_exe, penv_dir):
123123
venv_script_path = util.download_file(
124124
VIRTUALENV_URL,
125125
os.path.join(
126-
os.path.dirname(penv_dir), "penv-tmp", os.path.basename(VIRTUALENV_URL)
126+
os.path.dirname(penv_dir), ".cache", "tmp", os.path.basename(VIRTUALENV_URL)
127127
),
128128
)
129129
if not venv_script_path:
@@ -166,7 +166,7 @@ def install_pip(python_exe, penv_dir):
166166

167167
log.debug("Downloading 'get-pip.py' installer...")
168168
get_pip_path = os.path.join(
169-
os.path.dirname(penv_dir), "penv-tmp", os.path.basename(PIP_URL)
169+
os.path.dirname(penv_dir), ".cache", "tmp", os.path.basename(PIP_URL)
170170
)
171171
util.download_file(PIP_URL, get_pip_path)
172172

pioinstaller/python.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def fetch_portable_python(dst):
6969
log.debug("Downloading portable python...")
7070

7171
archive_path = util.download_file(
72-
url, os.path.join(os.path.join(dst, "penv-tmp"), os.path.basename(url))
72+
url, os.path.join(os.path.join(dst, ".cache", "tmp"), os.path.basename(url))
7373
)
7474

7575
python_dir = os.path.join(dst, "python37")

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
install_requires=[
3737
# Core
3838
"click==7.1.2",
39-
"requests==2.23.0",
39+
"requests==2.24.0",
4040
"colorama==0.4.3",
4141
"semantic-version==2.8.5",
42-
"certifi==2020.04.05.2",
42+
"certifi==2020.6.20",
4343
# Misc
4444
"wheel==0.34.2",
4545
],

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ envlist = py27, py35, py36, py37, py38
77
usedevelop = True
88
deps =
99
py35,py36,py37,py38: black
10-
isort
10+
isort<5
1111
pylint
1212
pytest
1313
commands =

0 commit comments

Comments
 (0)