24
24
import logging
25
25
import optparse
26
26
import os
27
- import pkgutil
28
27
import re
29
28
import shutil
30
29
import struct
31
30
import subprocess
32
31
import sys
33
- import tempfile
34
32
import textwrap
35
33
import zlib
36
34
from distutils .util import strtobool
@@ -696,14 +694,14 @@ def main():
696
694
)
697
695
698
696
if "extend_parser" in globals ():
699
- extend_parser (parser )
697
+ extend_parser (parser ) # noqa: F821
700
698
701
699
options , args = parser .parse_args ()
702
700
703
701
global logger
704
702
705
703
if "adjust_options" in globals ():
706
- adjust_options (options , args )
704
+ adjust_options (options , args ) # noqa: F821
707
705
708
706
verbosity = options .verbose - options .quiet
709
707
logger = Logger ([(Logger .level_for_integer (2 - verbosity ), sys .stdout )])
@@ -764,7 +762,7 @@ def main():
764
762
symlink = options .symlink ,
765
763
)
766
764
if "after_install" in globals ():
767
- after_install (options , home_dir )
765
+ after_install (options , home_dir ) # noqa: F821
768
766
769
767
770
768
def call_subprocess (
@@ -1175,8 +1173,8 @@ def install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages, clear, sy
1175
1173
1176
1174
if clear :
1177
1175
rmtree (lib_dir )
1178
- ## FIXME: why not delete it?
1179
- ## Maybe it should delete everything with #!/path/to/venv/python in it
1176
+ # FIXME: why not delete it?
1177
+ # Maybe it should delete everything with #!/path/to/venv/python in it
1180
1178
logger .notify ("Not deleting %s" , bin_dir )
1181
1179
1182
1180
if hasattr (sys , "real_prefix" ):
@@ -1304,7 +1302,7 @@ def install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages, clear, sy
1304
1302
os .unlink (pyd_pth )
1305
1303
1306
1304
if sys .executable != py_executable :
1307
- ## FIXME: could I just hard link?
1305
+ # FIXME: could I just hard link?
1308
1306
executable = sys .executable
1309
1307
shutil .copyfile (executable , py_executable )
1310
1308
make_exe (py_executable )
@@ -1413,7 +1411,7 @@ def install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages, clear, sy
1413
1411
# And then change the install_name of the copied python executable
1414
1412
try :
1415
1413
mach_o_change (py_executable , os .path .join (prefix , "Python" ), "@executable_path/../.Python" )
1416
- except :
1414
+ except Exception :
1417
1415
e = sys .exc_info ()[1 ]
1418
1416
logger .warn ("Could not call mach_o_change: %s. " "Trying to call install_name_tool instead." % e )
1419
1417
try :
@@ -1426,7 +1424,7 @@ def install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages, clear, sy
1426
1424
py_executable ,
1427
1425
]
1428
1426
)
1429
- except :
1427
+ except Exception :
1430
1428
logger .fatal ("Could not call install_name_tool -- you must " "have Apple's development tools installed" )
1431
1429
raise
1432
1430
@@ -1493,7 +1491,7 @@ def install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages, clear, sy
1493
1491
pydistutils = os .path .expanduser ("~/.pydistutils.cfg" )
1494
1492
if os .path .exists (pydistutils ):
1495
1493
logger .notify ("Please make sure you remove any previous custom paths from " "your %s file." % pydistutils )
1496
- ## FIXME: really this should be calculated earlier
1494
+ # FIXME: really this should be calculated earlier
1497
1495
1498
1496
fix_local_scheme (home_dir , symlink )
1499
1497
@@ -1553,17 +1551,17 @@ def install_python_config(home_dir, bin_dir, prompt=None):
1553
1551
else :
1554
1552
files = {"python-config" : PYTHON_CONFIG }
1555
1553
install_files (home_dir , bin_dir , prompt , files )
1556
- for name , content in files .items ():
1554
+ for name , _ in files .items ():
1557
1555
make_exe (os .path .join (bin_dir , name ))
1558
1556
1559
1557
1560
1558
def install_distutils (home_dir ):
1561
1559
distutils_path = change_prefix (distutils .__path__ [0 ], home_dir )
1562
1560
mkdir (distutils_path )
1563
- ## FIXME: maybe this prefix setting should only be put in place if
1564
- ## there's a local distutils.cfg with a prefix setting?
1561
+ # FIXME: maybe this prefix setting should only be put in place if
1562
+ # there's a local distutils.cfg with a prefix setting?
1565
1563
home_dir = os .path .abspath (home_dir )
1566
- ## FIXME: this is breaking things, removing for now:
1564
+ # FIXME: this is breaking things, removing for now:
1567
1565
# distutils_cfg = DISTUTILS_CFG + "\n[install]\nprefix=%s\n" % home_dir
1568
1566
writefile (os .path .join (distutils_path , "__init__.py" ), DISTUTILS_INIT )
1569
1567
writefile (os .path .join (distutils_path , "distutils.cfg" ), DISTUTILS_CFG , overwrite = False )
@@ -1651,10 +1649,7 @@ def is_executable(exe):
1651
1649
return os .path .isfile (exe ) and os .access (exe , os .X_OK )
1652
1650
1653
1651
1654
- ############################################################
1655
- ## Relocating the environment:
1656
-
1657
-
1652
+ # Relocating the environment:
1658
1653
def make_environment_relocatable (home_dir ):
1659
1654
"""
1660
1655
Makes the already-existing environment use relative paths, and takes out
@@ -1669,7 +1664,7 @@ def make_environment_relocatable(home_dir):
1669
1664
)
1670
1665
fixup_scripts (home_dir , bin_dir )
1671
1666
fixup_pth_and_egg_link (home_dir )
1672
- ## FIXME: need to fix up distutils.cfg
1667
+ # FIXME: need to fix up distutils.cfg
1673
1668
1674
1669
1675
1670
OK_ABS_SCRIPTS = [
@@ -1733,7 +1728,12 @@ def fixup_scripts(home_dir, bin_dir):
1733
1728
1734
1729
def relative_script (lines ):
1735
1730
"Return a script that'll work in a relocatable environment."
1736
- activate = "import os; activate_this=os.path.join(os.path.dirname(os.path.realpath(__file__)), 'activate_this.py'); exec(compile(open(activate_this).read(), activate_this, 'exec'), dict(__file__=activate_this)); del os, activate_this"
1731
+ activate = (
1732
+ "import os; "
1733
+ "activate_this=os.path.join(os.path.dirname(os.path.realpath(__file__)), 'activate_this.py'); "
1734
+ "exec(compile(open(activate_this).read(), activate_this, 'exec'), dict(__file__=activate_this)); "
1735
+ "del os, activate_this"
1736
+ )
1737
1737
# Find the last future statement in the script. If we insert the activation
1738
1738
# line before a future statement, Python will raise a SyntaxError.
1739
1739
activate_at = None
@@ -1843,10 +1843,7 @@ def make_relative_path(source, dest, dest_is_directory=True):
1843
1843
return os .path .sep .join (full_parts )
1844
1844
1845
1845
1846
- ############################################################
1847
- ## Bootstrap script creation:
1848
-
1849
-
1846
+ # Bootstrap script creation:
1850
1847
def create_bootstrap_script (extra_text , python_version = "" ):
1851
1848
"""
1852
1849
Creates a bootstrap script, which is like this script but with
@@ -1893,13 +1890,11 @@ def after_install(options, home_dir):
1893
1890
with codecs .open (filename , "r" , encoding = "utf-8" ) as f :
1894
1891
content = f .read ()
1895
1892
py_exe = "python%s" % python_version
1896
- content = ("#!/usr/bin/env %s\n " % py_exe ) + "## WARNING: This file is generated\n " + content
1893
+ content = ("#!/usr/bin/env %s\n " % py_exe ) + "# WARNING: This file is generated\n " + content
1897
1894
return content .replace ("##EXT" "END##" , extra_text )
1898
1895
1899
1896
1900
- ##EXTEND##
1901
-
1902
-
1897
+ # EXTEND
1903
1898
def convert (s ):
1904
1899
b = base64 .b64decode (s .encode ("ascii" ))
1905
1900
return zlib .decompress (b ).decode ("utf-8" )
@@ -2122,10 +2117,10 @@ def convert(s):
2122
2117
# file deactivate.bat
2123
2118
DEACTIVATE_BAT = convert (
2124
2119
"""
2125
- eJyFkN0KgkAUhO8XfIdBkOoVAqFAQyF/EBO6ksrdXCg3cqvXbxdJTRTP3ZwzZ/iYDb2UAoIxgxik
2126
- phKZn6SH7T53w8zWu8QN4IhqIfGqKZYrSIHTW/ACj6c43+i9xofLErKkd/AKVrxNPcsgnKESEgVl
2127
- vKIF8mjv5L/sOImCOMVVqCw3dPxd1mwMAjWawmwWtjXyZ5mdb+SsqNf/oTMwx9SLQi8K3D6Q1n2c
2128
- 1jREag/TWN1vi9bEz4CpIv86UrqPpOQQRlc/iaH9XTdKkS98fZEs
2120
+ eJyFkN0KgkAUhO8X9h0GQapXCIQEDQX/EBO6kso1F9KN3Or1201Si6JzN+fMGT5mxQ61gKgqSijp
2121
+ mETup9nGDgo3yi29S90QjmhnEteOYb6AFNjdBC9xvoj9iTUd7lzWkDVrwFuYiZ15JiW8QiskSlbx
2122
+ lpUo4sApXtlJGodJhqNQWW7k+Ou831ACNZrC6BeW+eXPNEbfl7OiXr6H/oHZZl4ceXHoToG0nuIM
2123
+ pk+k4fAba/wd0Pr4P2CqyLeOlJ4iKfkJo6v/iaH9YzfPMEoeMG2RUA==
2129
2124
"""
2130
2125
)
2131
2126
@@ -2225,29 +2220,28 @@ def convert(s):
2225
2220
# file distutils-init.py
2226
2221
DISTUTILS_INIT = convert (
2227
2222
"""
2228
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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Y5NgscNjiPGgwi9cAsy4t0cqEq+yRx
2239
+ IC4iXikBbwhpedAnkdLxjE1FNA9Vla6Eb4Q7GhXUWHgTfCbliM8KDWJ6jS18yjFsqkV4vhRSlVSm
2240
+ vWI+FXWsGsSzkyk1zcK2osQnULnFEg352VIP6uBBHMPmsjd1+959XMsxHstwp057l1jF7FKYOPMq
2241
+ XfphuDTXC9klDGJ4ijk8M3vYuC6hSQ/QF9BE8RJNasQVjjSSXkQ3VgJqWf8j3IuopjF9FnzUuQx+
2242
+ JFwHf4ZmMUezt9eJTzyMnImpSLYKfyRPv+ZmZztgPT6dxRU/ne6Qg5ceEPRhvDTN1lradIg1fogN
2243
+ 56YTeQiK3qaly3y6k/fvfsGHaOL/N8KONihN29OwfdcfuMdo+rjwicftIz6NqDfyphmOzh8FUQjU
2244
+ OmchoHvC5YLn/jHq19/AXef8fuqdzMaUHI4sSBblY4VlK1J2kRsLnsW8+Rc/zwIT
2251
2245
"""
2252
2246
)
2253
2247
@@ -2390,7 +2384,7 @@ def do_macho(file, bits, endian):
2390
2384
if bits == 64 :
2391
2385
read_data (file , endian )
2392
2386
# The header is followed by ncmds commands
2393
- for n in range (ncmds ):
2387
+ for _ in range (ncmds ):
2394
2388
where = file .tell ()
2395
2389
# Read command header
2396
2390
cmd , cmdsize = read_data (file , endian , 2 )
@@ -2417,7 +2411,7 @@ def do_file(file, offset=0, size=maxint):
2417
2411
if magic == FAT_MAGIC :
2418
2412
# Fat binaries contain nfat_arch Mach-O binaries
2419
2413
nfat_arch = read_data (file , BIG_ENDIAN )
2420
- for n in range (nfat_arch ):
2414
+ for _ in range (nfat_arch ):
2421
2415
# Read arch header
2422
2416
cputype , cpusubtype , offset , size , align = read_data (file , BIG_ENDIAN , 5 )
2423
2417
do_file (file , offset , size )
0 commit comments