Skip to content

Commit 3f25fec

Browse files
committed
check then cleanup osp comments
1 parent b77a0e7 commit 3f25fec

File tree

1 file changed

+0
-64
lines changed

1 file changed

+0
-64
lines changed

winpython/disthelpers.py

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import sys
2222
import os
23-
# import os.path as osp
2423
from pathlib import Path
2524
import shutil
2625
import traceback
@@ -36,7 +35,6 @@
3635
def get_module_path(modname):
3736
"""Return module *modname* base path"""
3837
module = sys.modules.get(modname, __import__(modname))
39-
# return osp.abspath(osp.dirname(module.__file__))
4038
return str(Path(module.__file__).parent.resolve())
4139

4240

@@ -68,14 +66,11 @@ def prepend_module_to_path(module_path):
6866
1) In your application to import local frozen copies of internal libraries
6967
2) In your py2exe distributed package to add a text file containing the returned string
7068
"""
71-
#if not osp.isdir(module_path):
7269
if not Path(module_path).is_dir():
7370
# Assuming py2exe distribution
7471
return
75-
#sys.path.insert(0, osp.abspath(module_path))
7672
sys.path.insert(0, str(Path(module_path).resolve()))
7773
changeset = get_changeset(module_path)
78-
# name = osp.basename(module_path)
7974
name = Path(module_path).name
8075
prefix = "Prepending module to sys.path"
8176
message = prefix + (
@@ -99,12 +94,10 @@ def prepend_module_to_path(module_path):
9994

10095
def prepend_modules_to_path(module_base_path):
10196
"""Prepend to sys.path all modules located in *module_base_path*"""
102-
# if not osp.isdir(module_base_path):
10397
if not Path(module_base_path).is_dir():
10498
# Assuming py2exe distribution
10599
return
106100
fnames = [
107-
# osp.join(module_base_path, name)
108101
str(Path(module_base_path) / name)
109102
for name in os.listdir(module_base_path)
110103
]
@@ -124,11 +117,9 @@ def _remove_later(fname):
124117
"""Try to remove file later (at exit)"""
125118

126119
def try_to_remove(fname):
127-
# if osp.exists(fname):
128120
if Path(fname).exists():
129121
os.remove(fname)
130122

131-
# atexit.register(try_to_remove, osp.abspath(fname))
132123
atexit.register(try_to_remove, str(Path(fname).resolve()))
133124

134125

@@ -147,8 +138,6 @@ def to_include_files(data_files):
147138
include_files = []
148139
for dest_dir, fnames in data_files:
149140
for source_fname in fnames:
150-
#dest_fname = osp.join(
151-
# dest_dir, osp.basename(source_fname))
152141
dest_fname = str(Path(dest_dir) /
153142
Path(source_fname).name)
154143
include_files.append((source_fname, dest_fname))
@@ -284,7 +273,6 @@ def setup(
284273
else version
285274
)
286275
self.description = description
287-
# assert osp.isfile(script)
288276
assert Path(script).is_file()
289277
self.script = script
290278
self.target_name = target_name
@@ -348,7 +336,6 @@ def add_pyqt4(self):
348336

349337
import PyQt4
350338

351-
# pyqt_path = osp.dirname(PyQt4.__file__)
352339
pyqt_path = str(Path(PyQt4.__file__).parent)
353340

354341
# Configuring PyQt4
@@ -361,11 +348,9 @@ def add_pyqt4(self):
361348
if self.msvc:
362349
vc90man = "Microsoft.VC90.CRT.manifest"
363350
pyqt_tmp = 'pyqt_tmp'
364-
# if osp.isdir(pyqt_tmp):
365351
if Path(pyqt_tmp).is_dir():
366352
shutil.rmtree(pyqt_tmp)
367353
os.mkdir(pyqt_tmp)
368-
# vc90man_pyqt = osp.join(pyqt_tmp, vc90man)
369354
vc90man_pyqt = str(Path(pyqt_tmp) / vc90man)
370355
man = (
371356
open(vc90man, "r")
@@ -377,20 +362,16 @@ def add_pyqt4(self):
377362
)
378363
open(vc90man_pyqt, 'w').write(man)
379364
for dirpath, _, filenames in os.walk(
380-
# osp.join(pyqt_path, "plugins")
381365
str(Path(pyqt_path) / "plugins")
382366
):
383367
filelist = [
384-
# osp.join(dirpath, f)
385368
str(Path(dirpath) / f)
386369
for f in filenames
387-
# if osp.splitext(f)[1] in ('.dll', '.py')
388370
if Path(f).suffix in ('.dll', '.py')
389371
]
390372
if self.msvc and [
391373
f
392374
for f in filelist
393-
# if osp.splitext(f)[1] == '.dll'
394375
if Path(f).suffix == '.dll'
395376
]:
396377
# Where there is a DLL build with Microsoft Visual C++ 2008,
@@ -408,11 +389,7 @@ def add_pyqt4(self):
408389
if self.msvc:
409390
atexit.register(remove_dir, pyqt_tmp)
410391
# Including french translation
411-
# fr_trans = osp.join(
412-
# pyqt_path, "translations", "qt_fr.qm"
413-
# )
414392
fr_trans = str(Path(pyqt_path) / "translations" / "qt_fr.qm")
415-
# if osp.exists(fr_trans):
416393
if Path(fr_trans).exists():
417394
self.data_files.append(
418395
('translations', (fr_trans,))
@@ -443,7 +420,6 @@ def add_pyside(self):
443420

444421
import PySide
445422

446-
# pyside_path = osp.dirname(PySide.__file__)
447423
pyside_path = str(Path(PySide.__file__).parent)
448424

449425
# Configuring PySide
@@ -456,7 +432,6 @@ def add_pyside(self):
456432
if self.msvc:
457433
vc90man = "Microsoft.VC90.CRT.manifest"
458434
os.mkdir('pyside_tmp')
459-
# vc90man_pyside = osp.join('pyside_tmp', vc90man)
460435
vc90man_pyside = str(Path('pyside_tmp') / vc90man)
461436
man = (
462437
open(vc90man, "r")
@@ -468,20 +443,16 @@ def add_pyside(self):
468443
)
469444
open(vc90man_pyside, 'w').write(man)
470445
for dirpath, _, filenames in os.walk(
471-
# osp.join(pyside_path, "plugins")
472446
str(Path(pyside_path) / "plugins")
473447
):
474448
filelist = [
475-
# osp.join(dirpath, f)
476449
str(Path(dirpath) / f)
477450
for f in filenames
478-
# if osp.splitext(f)[1] in ('.dll', '.py')
479451
if Path(f).suffix in ('.dll', '.py')
480452
]
481453
if self.msvc and [
482454
f
483455
for f in filelist
484-
# if osp.splitext(f)[1] == '.dll'
485456
if Path(f).suffix == '.dll'
486457
]:
487458
# Where there is a DLL build with Microsoft Visual C++ 2008,
@@ -499,21 +470,16 @@ def add_pyside(self):
499470
# Replacing dlls found by cx_Freeze by the real PySide Qt dlls:
500471
# (http://qt-project.org/wiki/Packaging_PySide_applications_on_Windows)
501472
dlls = [
502-
# osp.join(pyside_path, fname)
503473
str(Path(pyside_path) / fname)
504474
for fname in os.listdir(pyside_path)
505-
#if osp.splitext(fname)[1] == '.dll'
506475
if Path(fname).suffix == '.dll'
507476
]
508477
self.data_files.append(('', dlls))
509478

510479
if self.msvc:
511480
atexit.register(remove_dir, 'pyside_tmp')
512481
# Including french translation
513-
# fr_trans = osp.join(
514-
# pyside_path, "translations", "qt_fr.qm")
515482
fr_trans = str(Path(pyside_path) / "translations" / "qt_fr.qm")
516-
#if osp.exists(fr_trans):
517483
if Path(fr_trans).exists():
518484
self.data_files.append(
519485
('translations', (fr_trans,))
@@ -603,9 +569,6 @@ def add_modules(self, *module_names):
603569
(
604570
'',
605571
(
606-
#osp.join(
607-
# get_module_path('h5py'),
608-
# 'zlib1.dll',
609572
str(Path(get_module_path('h5py')) / 'zlib1.dll'
610573
),
611574
),
@@ -632,14 +595,11 @@ def add_modules(self, *module_names):
632595
import sphinx.ext
633596

634597
for fname in os.listdir(
635-
#osp.dirname(sphinx.ext.__file__)
636598
str(Path(sphinx.ext.__file__).parent)
637599
):
638-
#if osp.splitext(fname)[1] == '.py':
639600
if Path(fname).suffix == '.py':
640601
modname = (
641602
'sphinx.ext.%s'
642-
# % osp.splitext(fname)[0]
643603
% Path(fname).stem
644604
)
645605
self.includes.append(modname)
@@ -721,11 +681,8 @@ def add_module_data_dir(
721681
*extensions*: list of file extensions, e.g. ('.png', '.svg')
722682
"""
723683
module_dir = get_module_path(module_name)
724-
# nstrip = len(module_dir) + len(osp.sep)
725684
nstrip = len(module_dir) + len(os.sep)
726-
# data_dir = osp.join(module_dir, data_dir_name)
727685
data_dir = str(Path(module_dir) / data_dir_name)
728-
# if not osp.isdir(data_dir):
729686
if not Path(data_dir).is_dir():
730687
raise IOError(
731688
"Directory not found: %s" % data_dir
@@ -734,17 +691,13 @@ def add_module_data_dir(
734691
data_dir
735692
):
736693
dirname = dirpath[nstrip:]
737-
#if osp.basename(dirpath) in exclude_dirs:
738694
if Path(dirpath).name in exclude_dirs:
739695
continue
740696
if not copy_to_root:
741-
# dirname = osp.join(module_name, dirname)
742697
dirname = str(Path(module_name) / dirname)
743698
pathlist = [
744-
# osp.join(dirpath, f)
745699
str(Path(dirpath) / f)
746700
for f in filenames
747-
# if osp.splitext(f)[1].lower() in extensions
748701
if Path(f).suffix.lower() in extensions
749702
]
750703
self.data_files.append((dirname, pathlist))
@@ -784,25 +737,11 @@ def add_module_data_files(
784737
verbose,
785738
exclude_dirs,
786739
)
787-
#translation_file = osp.join(
788-
# module_dir,
789-
# "locale",
790-
# "fr",
791-
# "LC_MESSAGES",
792-
# "%s.mo" % module_name,
793-
#)
794740
translation_file = str(Path(module_dir) / "locale" / "fr" /
795741
"LC_MESSAGES" / f"{module_name}.mo" )
796-
# if osp.isfile(translation_file):
797742
if Path(translation_file).is_file():
798743
self.data_files.append(
799744
(
800-
#osp.join(
801-
# module_name,
802-
# "locale",
803-
# "fr",
804-
# "LC_MESSAGES",
805-
#),
806745
str(Path(
807746
module_name) /
808747
"locale" /
@@ -815,7 +754,6 @@ def add_module_data_files(
815754
"Adding module '%s' translation file: %s"
816755
% (
817756
module_name,
818-
#osp.basename(translation_file),
819757
Path(translation_file).name,
820758
)
821759
)
@@ -854,7 +792,6 @@ def build(
854792
def __cleanup(self):
855793
"""Remove old build and dist directories"""
856794
remove_dir("build")
857-
# if osp.isdir("dist"):
858795
if Path("dist").is_dir():
859796
remove_dir("dist")
860797
remove_dir(self.target_dir)
@@ -911,7 +848,6 @@ def build_py2exe(
911848
icon_resources=[(0, self.icon)],
912849
bitmap_resources=[],
913850
other_resources=[],
914-
# dest_base=osp.splitext(self.target_name)[0],
915851
dest_base=Path(self.target_name).stem,
916852
version=self.version,
917853
company_name=company_name,

0 commit comments

Comments
 (0)