Skip to content

Commit bf0ecbf

Browse files
committed
pathlib and f-string the code
1 parent e264388 commit bf0ecbf

File tree

2 files changed

+30
-20
lines changed

2 files changed

+30
-20
lines changed

make.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import os
1616
import os.path as osp
17+
from pathlib import Path
1718
import re
1819
import subprocess
1920
import shutil
@@ -41,7 +42,8 @@ def get_drives():
4142

4243
def get_nsis_exe():
4344
"""Return NSIS executable"""
44-
localdir = osp.join(sys.prefix, os.pardir, os.pardir)
45+
# localdir = osp.join(sys.prefix, os.pardir, os.pardir)
46+
localdir = str(Path(sys.prefix).parent.parent)
4547
for drive in get_drives():
4648
for dirname in (
4749
r'C:\Program Files',
@@ -71,7 +73,8 @@ def get_nsis_exe():
7173

7274
def get_iscc_exe():
7375
"""Return ISCC executable"""
74-
localdir = osp.join(sys.prefix, os.pardir, os.pardir)
76+
# localdir = osp.join(sys.prefix, os.pardir, os.pardir)
77+
localdir = str(Path(sys.prefix).parent.parent)
7578
for drive in get_drives():
7679
for dirname in (
7780
r'C:\Program Files',
@@ -101,7 +104,8 @@ def get_iscc_exe():
101104

102105
def get_7zip_exe():
103106
"""Return 7zip executable"""
104-
localdir = osp.join(sys.prefix, os.pardir, os.pardir)
107+
# localdir = osp.join(sys.prefix, os.pardir, os.pardir)
108+
localdir = str(Path(sys.prefix).parent.parent)
105109
for drive in get_drives():
106110
for dirname in (
107111
r'C:\Program Files',
@@ -2198,16 +2202,20 @@ def make(
21982202
self.python_fullversion,
21992203
self.build_number,
22002204
)
2201-
fname = osp.join(
2202-
self.winpydir,
2203-
os.pardir,
2204-
'WinPython%s-%sbit-%s.md'
2205-
% (
2206-
self.flavor,
2207-
self.distribution.architecture,
2208-
self.winpyver2,
2209-
),
2210-
)
2205+
#fname = osp.join(
2206+
# self.winpydir,
2207+
# os.pardir,
2208+
# 'WinPython%s-%sbit-%s.md'
2209+
# % (
2210+
# self.flavor,
2211+
# self.distribution.architecture,
2212+
# self.winpyver2,
2213+
# ),
2214+
#)
2215+
fname = str(Path(self.winpydir).parent / (
2216+
f'WinPython{self.flavor}-' +
2217+
f'-{self.distribution.architecture}bit-'+
2218+
f'{self.winpyver2}.md'))
22112219
open(fname, 'w').write(self.package_index_wiki)
22122220
# Copy to winpython/changelogs
22132221
shutil.copyfile(

winpython/wppm.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import os
1616
import os.path as osp
17+
from pathlib import Path
1718
import shutil
1819
import re
1920
import sys
@@ -793,13 +794,14 @@ def install_script(self, script, install_options=None):
793794

794795
def main(test=False):
795796
if test:
796-
sbdir = osp.join(
797-
osp.dirname(__file__),
798-
os.pardir,
799-
os.pardir,
800-
os.pardir,
801-
'sandbox',
802-
)
797+
#sbdir = osp.join(
798+
# osp.dirname(__file__),
799+
# os.pardir,
800+
# os.pardir,
801+
# os.pardir,
802+
# 'sandbox',
803+
#)
804+
sbdir = str(Path(__file__).parents[0].parent.parent.parent / 'sandbox')
803805
tmpdir = osp.join(sbdir, 'tobedeleted')
804806

805807
# fname = osp.join(tmpdir, 'scipy-0.10.1.win-amd64-py2.7.exe')

0 commit comments

Comments
 (0)