8000 partial remove osp from make.py by stonebig · Pull Request #1156 · winpython/winpython · GitHub
[go: up one dir, main page]

Skip to content

partial remove osp from make.py #1156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 58 additions & 29 deletions make.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
# osp.dirname(__file__), 'changelogs'
# )
CHANGELOGS_DIR = str(Path(__file__).parent / 'changelogs')
assert osp.isdir(CHANGELOGS_DIR)
# assert osp.isdir(CHANGELOGS_DIR)
assert Path(CHANGELOGS_DIR).is_dir()


def get_drives():
Expand All @@ -51,8 +52,10 @@ def get_nsis_exe():
r'C:\Program Files (x86)',
drive + r'PortableApps\NSISPortableANSI',
drive + r'PortableApps\NSISPortable',
osp.join(localdir, 'NSISPortableANSI'),
osp.join(localdir, 'NSISPortable'),
# osp.join(localdir, 'NSISPortableANSI'),
str(Path(localdir) / 'NSISPortableANSI'),
# osp.join(localdir, 'NSISPortable'),
str(Path(localdir) / 'NSISPortable'),
):
for subdirname in ('.', 'App'):
exe = osp.join(
Expand All @@ -61,7 +64,8 @@ def get_nsis_exe():
'NSIS',
'makensis.exe',
)
if osp.isfile(exe):
# if osp.isfile(exe):
if Path(exe).is_file():
return exe
else:
raise RuntimeError(
Expand All @@ -83,7 +87,8 @@ def get_iscc_exe():
# drive+r'PortableApps\NSISPortableANSI',
# drive+r'PortableApps\NSISPortable',
# osp.join(localdir, 'NSISPortableANSI'),
osp.join(localdir, 'Inno Setup 5'),
# osp.join(localdir, 'Inno Setup 5'),
str(Path(localdir) / 'Inno Setup 5'),
):
for subdirname in ('.', 'App'):
exe = osp.join(
Expand All @@ -92,7 +97,8 @@ def get_iscc_exe():
'Inno Setup 5',
'iscc.exe',
)
if osp.isfile(exe):
# if osp.isfile(exe):
if Path(exe).is_file():
return exe
else:
#raise RuntimeError(
Expand All @@ -111,14 +117,16 @@ def get_7zip_exe():
for dirname in (
r'C:\Program Files',
r'C:\Program Files (x86)',
osp.join(localdir, '7-Zip'),
# osp.join(localdir, '7-Zip'),
str(Path(localdir) / '7-Zip'),
):
for subdirname in ('.', 'App'):
exe = osp.join(
dirname, subdirname, '7-Zip', '7z.exe'
)
# include = osp.join(dirname, subdirname, '7-Zip', 'include')
if osp.isfile(exe):
# if osp.isfile(exe):
if Path(exe).is_file():
return exe
else:
raise RuntimeError(
Expand Down Expand Up @@ -215,7 +223,8 @@ def build_nsis(srcname, dstname, data):
data = [
(
'!addincludedir',
osp.join(portable_dir, 'include'),
# osp.join(portable_dir, 'include'),
str(Path(portable_dir) / 'include'),
)
] + list(data)
replace_in_nsis_file(dstname, data)
Expand Down Expand Up @@ -350,7 +359,8 @@ def __init__(

# osp.join(self.winpydir, self.python_name) = Directory of Python exec
# self.pythondir =osp.join(self.winpydir, self.python_name)
self.python_name = osp.basename(self.python_fname)[
# self.python_name = osp.basename(self.python_fname)[
self.python_name = Path(self.python_fname).name[
:-4
]
self.distname = 'winUNKNOWN' #win%s' % self.python_name # PyPy ?
Expand Down Expand Up @@ -488,7 +498,8 @@ def winpyver(self):
@property
def python_dir(self):
"""Return Python dirname (full path) of the target distribution"""
return osp.join(self.winpydir, self.python_name) # python.exe path
# return osp.join(self.winpydir, self.python_name) # python.exe path
return str(Path(self.winpydir) / self.python_name) # python.exe path

@property
def winpy_arch(self):
Expand Down Expand Up @@ -583,8 +594,10 @@ def get_package_fname(self, pattern):
def create_batch_script(self, name, contents,
do_changes=None):
"""Create batch script %WINPYDIR%/name"""
scriptdir = osp.join(self.winpydir, 'scripts')
if not osp.isdir(scriptdir):
# scriptdir = osp.join(self.winpydir, 'scripts')
scriptdir = str(Path(self.winpydir) / 'scripts')
# if not osp.isdir(scriptdir):
if not Path(scriptdir).is_dir():
os.mkdir(scriptdir)
print ('dochanges for %s %', name, do_changes)
# live patch pypy3
Expand All @@ -593,7 +606,8 @@ def create_batch_script(self, name, contents,
for i in do_changes:
contents_final = contents_final.replace(i[0], i[1])

fd = open(osp.join(scriptdir, name), 'w')
# fd = open(osp.join(scriptdir, name), 'w')
fd = open(str(Path(scriptdir) / name), 'w')
fd.write(contents_final)
fd.close()

Expand All @@ -611,8 +625,10 @@ def create_launcher(
portable_dir = osp.join(
osp.dirname(osp.abspath(__file__)), 'portable'
)
icon_fname = osp.join(portable_dir, 'icons', icon)
assert osp.isfile(icon_fname)
# icon_fname = osp.join(portable_dir, 'icons', icon)
icon_fname = str(Path(portable_dir) / 'icons' / icon)
# assert osp.isfile(icon_fname)
assert Path(icon_fname).is_file()

# Customizing NSIS script
if command is None:
Expand Down Expand Up @@ -686,7 +702,8 @@ def create_installer(self):
portable_dir = osp.join(
osp.dirname(osp.abspath(__file__)), 'portable'
)
fname = osp.join(portable_dir, 'installer-tmp.nsi')
# fname = osp.join(portable_dir, 'installer-tmp.nsi')
fname = str(Path(portable_dir) / 'installer-tmp.nsi')
data = (
('DISTDIR', self.winpydir),
('ARCH', self.winpy_arch),
Expand Down Expand Up @@ -811,30 +828,36 @@ def _extract_python(self):
def _copy_dev_tools(self):
"""Copy dev tools"""
self._print(f"Copying tools from {self.toolsdirs} to {self.winpydir}/t")
toolsdir = osp.join(self.winpydir, 't')
# toolsdir = osp.join(self.winpydir, 't')
toolsdir = str(Path(self.winpydir) / 't')
os.mkdir(toolsdir)
for (
dirname
) in (
[ok_dir for ok_dir in self.toolsdirs if osp.isdir(ok_dir)]
): # the ones in the make.py script environment
for name in os.listdir(dirname):
path = osp.join(dirname, name)
# path = osp.join(dirname, name)
path = str(Path(dirname) / name)
copy = (
shutil.copytree
if osp.isdir(path)
# if osp.isdir(path)
if Path(path).is_dir()
else shutil.copyfile
)
if self.verbose:
print(
path
+ ' --> '
+ osp.join(toolsdir, name)
# + osp.join(toolsdir, name)
+ str(Path(toolsdir) / name)
)
copy(path, osp.join(toolsdir, name))
# copy(path, osp.join(toolsdir, name))
copy(path, str(Path(toolsdir) / name))
self._print_done()
# move node higher
nodejs_current = osp.join(toolsdir, 'n')
# nodejs_current = osp.join(toolsdir, 'n')
nodejs_current = str(Path(toolsdir) / 'n')
nodejs_target = self.winpydir + self.NODEJS_PATH
if nodejs_current != nodejs_target and osp.isdir(
nodejs_current
Expand All @@ -843,29 +866,35 @@ def _copy_dev_tools(self):

def _copy_dev_docs(self):
"""Copy dev docs"""
docsdir = osp.join(self.winpydir, 'notebooks')
# docsdir = osp.join(self.winpydir, 'notebooks')
docsdir = str(Path(self.winpydir) / 'notebooks')
self._print(f"Copying Noteebook docs from {self.docsdirs} to {docsdir}")
if not osp.isdir(docsdir):
# if not osp.isdir(docsdir):
if not Path(docsdir).is_dir():
os.mkdir(docsdir)
docsdir = osp.join(
self.winpydir, 'notebooks', 'docs'
)
if not osp.isdir(docsdir):
# if not osp.isdir(docsdir):
if not Path(docsdir).is_dir():
os.mkdir(docsdir)
for dirname in self.docsdirs:
for name in os.listdir(dirname):
path = osp.join(dirname, name)
# path = osp.join(dirname, name)
path = str(Path(dirname) / name)
copy = (
shutil.copytree
if osp.isdir(path)
# if osp.isdir(path)
if Path(path).is_dir()
else shutil.copyfile
)
copy(path, osp.join(docsdir, name))
if self.verbose:
print(
path
+ ' --> '
+ osp.join(docsdir, name)
# + osp.join(docsdir, name)
+ str(Path(docsdir) / name)
)
self._print_done()

Expand Down
0