updated codebase to support count
This commit is contained in:
parent
d591991f03
commit
2106592146
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
env/
|
||||||
|
.vscode/
|
||||||
|
testData.txt
|
||||||
44
PyGeoIP.py
44
PyGeoIP.py
@ -1,4 +1,7 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
# Benjamyn Love
|
||||||
|
# 2018/2019
|
||||||
|
# bip (Bulk IP lookup)
|
||||||
|
|
||||||
import dns.resolver
|
import dns.resolver
|
||||||
import ipwhois
|
import ipwhois
|
||||||
@ -9,6 +12,13 @@ import warnings
|
|||||||
|
|
||||||
ipList = []
|
ipList = []
|
||||||
|
|
||||||
|
def loadBlacklist():
|
||||||
|
with open('blacklist.txt') as handle:
|
||||||
|
blacklist = handle.readlines()
|
||||||
|
for i in range(len(blacklist)):
|
||||||
|
blacklist[i] = blacklist[i].strip()
|
||||||
|
return blacklist
|
||||||
|
|
||||||
def lookupIP(inData):
|
def lookupIP(inData):
|
||||||
try:
|
try:
|
||||||
with warnings.catch_warnings():
|
with warnings.catch_warnings():
|
||||||
@ -26,30 +36,45 @@ def lookupIP(inData):
|
|||||||
|
|
||||||
|
|
||||||
def parseIPS():
|
def parseIPS():
|
||||||
|
global countIncluded
|
||||||
with open("ips.txt", 'r') as f:
|
with open("ips.txt", 'r') as f:
|
||||||
testdata = f.read()
|
ipData = f.read()
|
||||||
|
|
||||||
data = testdata.split('\n')
|
data = ipData.split('\n')
|
||||||
for ip in data:
|
for ip in data:
|
||||||
ip = ip.strip()
|
ip = ip.strip()
|
||||||
ipAddr = ip.split()
|
ipAddr = ip.split()
|
||||||
if len(ipAddr) == 2:
|
if len(ipAddr) == 2:
|
||||||
|
countIncluded = True
|
||||||
ipList.append(ipAddr)
|
ipList.append(ipAddr)
|
||||||
else:
|
else:
|
||||||
|
if len(ipAddr) == 0:
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
countIncluded = False
|
||||||
|
ipList.append(ipAddr)
|
||||||
|
|
||||||
|
|
||||||
|
blacklist = loadBlacklist()
|
||||||
parseIPS()
|
parseIPS()
|
||||||
|
|
||||||
for ips in ipList:
|
for ips in ipList:
|
||||||
# ccode = ipCheck(lookupIP(ips[1]))
|
# ccode = ipCheck(lookupIP(ips[1]))
|
||||||
|
if countIncluded == True:
|
||||||
ret = lookupIP(ips[1])
|
ret = lookupIP(ips[1])
|
||||||
|
reverseName = reversename.from_address(ips[1])
|
||||||
|
else:
|
||||||
|
ret = lookupIP(ips[0])
|
||||||
|
reverseName = reversename.from_address(ips[0])
|
||||||
|
|
||||||
if ret == None:
|
if ret == None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
cc = ret["asn_country_code"]
|
cc = ret["asn_country_code"]
|
||||||
desc = ret["asn_description"]
|
desc = ret["asn_description"]
|
||||||
if cc == "AU" or cc == "NZ" or cc == "US":
|
if cc in blacklist:
|
||||||
continue
|
continue
|
||||||
reverseName = reversename.from_address(ips[1])
|
|
||||||
try:
|
try:
|
||||||
ptr = str(dns.resolver.query(reverseName, "PTR")[0])
|
ptr = str(dns.resolver.query(reverseName, "PTR")[0])
|
||||||
except dns.resolver.NoAnswer as E:
|
except dns.resolver.NoAnswer as E:
|
||||||
@ -58,12 +83,9 @@ for ips in ipList:
|
|||||||
ptr = reverseName
|
ptr = reverseName
|
||||||
except dns.resolver.NXDOMAIN as E:
|
except dns.resolver.NXDOMAIN as E:
|
||||||
ptr = reverseName
|
ptr = reverseName
|
||||||
|
|
||||||
|
if countIncluded == True:
|
||||||
print("IP: {}\t\tCountry: {}\tDesc: {}\tPTR: {}\tCount: {}".format(ips[1], cc, desc, ptr, ips[0]))
|
print("IP: {}\t\tCountry: {}\tDesc: {}\tPTR: {}\tCount: {}".format(ips[1], cc, desc, ptr, ips[0]))
|
||||||
|
else:
|
||||||
|
print("IP: {}\t\tCountry: {}\tDesc: {}\tPTR: {}".format(ips[0], cc, desc, ptr))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# print(ipList[0])
|
|
||||||
# lookupIP("123.23.23.12")
|
|
||||||
|
|
||||||
##{'asn_registry': 'apnic', 'asn': '4134', 'asn_cidr': '220.174.0.0/16', 'asn_country_code': 'CN', 'asn_date': '2002-10-30', 'asn_description': 'CHINANET-BACKBONE No.31,Jin-rong Street, CN'}
|
|
||||||
|
|||||||
13
bip.sh
Normal file
13
bip.sh
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
FILENAME=$PWD/ips.txt
|
||||||
|
INSTDIR=$PWD
|
||||||
|
source ./env/bin/activate
|
||||||
|
if [ -z "${EDITOR}" ]
|
||||||
|
then
|
||||||
|
nano $FILENAME
|
||||||
|
else
|
||||||
|
$EDITOR $FILENAME
|
||||||
|
fi
|
||||||
|
clear
|
||||||
|
python $INSTDIR/PyGeoIP.py #set to python3 that is in use on the system, usually python3 will suffice
|
||||||
|
rm -f $FILENAME
|
||||||
BIN
env/bin/__pycache__/ipwhois_cli.cpython-37.pyc
vendored
BIN
env/bin/__pycache__/ipwhois_cli.cpython-37.pyc
vendored
Binary file not shown.
BIN
env/bin/__pycache__/ipwhois_utils_cli.cpython-37.pyc
vendored
BIN
env/bin/__pycache__/ipwhois_utils_cli.cpython-37.pyc
vendored
Binary file not shown.
20
env/bin/activate.csh
vendored
20
env/bin/activate.csh
vendored
@ -2,30 +2,37 @@
|
|||||||
# You cannot run it directly.
|
# You cannot run it directly.
|
||||||
# Created by Davide Di Blasi <davidedb@gmail.com>.
|
# Created by Davide Di Blasi <davidedb@gmail.com>.
|
||||||
|
|
||||||
alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate && unalias pydoc'
|
set newline='\
|
||||||
|
'
|
||||||
|
|
||||||
|
alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH:q" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT:q" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate && unalias pydoc'
|
||||||
|
|
||||||
# Unset irrelevant variables.
|
# Unset irrelevant variables.
|
||||||
deactivate nondestructive
|
deactivate nondestructive
|
||||||
|
|
||||||
setenv VIRTUAL_ENV "/home/ben/Documents/Projects/Python/PyGeoIP/env"
|
setenv VIRTUAL_ENV "/home/ben/Documents/Projects/Python/PyGeoIP/env"
|
||||||
|
|
||||||
set _OLD_VIRTUAL_PATH="$PATH"
|
set _OLD_VIRTUAL_PATH="$PATH:q"
|
||||||
setenv PATH "$VIRTUAL_ENV/bin:$PATH"
|
setenv PATH "$VIRTUAL_ENV:q/bin:$PATH:q"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ("" != "") then
|
if ("" != "") then
|
||||||
set env_name = ""
|
set env_name = ""
|
||||||
else
|
else
|
||||||
set env_name = `basename "$VIRTUAL_ENV"`
|
set env_name = "$VIRTUAL_ENV:t:q"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Could be in a non-interactive environment,
|
# Could be in a non-interactive environment,
|
||||||
# in which case, $prompt is undefined and we wouldn't
|
# in which case, $prompt is undefined and we wouldn't
|
||||||
# care about the prompt anyway.
|
# care about the prompt anyway.
|
||||||
if ( $?prompt ) then
|
if ( $?prompt ) then
|
||||||
set _OLD_VIRTUAL_PROMPT="$prompt"
|
set _OLD_VIRTUAL_PROMPT="$prompt:q"
|
||||||
set prompt = "[$env_name] $prompt"
|
if ( "$prompt:q" =~ *"$newline:q"* ) then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
set prompt = "[$env_name:q] $prompt:q"
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
unset env_name
|
unset env_name
|
||||||
@ -33,4 +40,3 @@ unset env_name
|
|||||||
alias pydoc python -m pydoc
|
alias pydoc python -m pydoc
|
||||||
|
|
||||||
rehash
|
rehash
|
||||||
|
|
||||||
|
|||||||
2
env/bin/activate.fish
vendored
2
env/bin/activate.fish
vendored
@ -1,4 +1,4 @@
|
|||||||
# This file must be used using `. bin/activate.fish` *within a running fish ( http://fishshell.com ) session*.
|
# This file must be used using `source bin/activate.fish` *within a running fish ( http://fishshell.com ) session*.
|
||||||
# Do not run it directly.
|
# Do not run it directly.
|
||||||
|
|
||||||
function deactivate -d 'Exit virtualenv mode and return to the normal environment.'
|
function deactivate -d 'Exit virtualenv mode and return to the normal environment.'
|
||||||
|
|||||||
24
env/bin/activate_this.py
vendored
24
env/bin/activate_this.py
vendored
@ -9,19 +9,21 @@ try:
|
|||||||
__file__
|
__file__
|
||||||
except NameError:
|
except NameError:
|
||||||
raise AssertionError(
|
raise AssertionError(
|
||||||
"You must run this like execfile('path/to/activate_this.py', dict(__file__='path/to/activate_this.py'))")
|
"You must run this like execfile('path/to/activate_this.py', dict(__file__='path/to/activate_this.py'))"
|
||||||
import sys
|
)
|
||||||
import os
|
import os
|
||||||
|
|
||||||
old_os_path = os.environ.get('PATH', '')
|
|
||||||
os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + os.pathsep + old_os_path
|
|
||||||
base = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
||||||
if sys.platform == 'win32':
|
|
||||||
site_packages = os.path.join(base, 'Lib', 'site-packages')
|
|
||||||
else:
|
|
||||||
site_packages = os.path.join(base, 'lib', 'python%s' % sys.version[:3], 'site-packages')
|
|
||||||
prev_sys_path = list(sys.path)
|
|
||||||
import site
|
import site
|
||||||
|
import sys
|
||||||
|
|
||||||
|
old_os_path = os.environ.get("PATH", "")
|
||||||
|
os.environ["PATH"] = os.path.dirname(os.path.abspath(__file__)) + os.pathsep + old_os_path
|
||||||
|
base = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
if sys.platform == "win32":
|
||||||
|
site_packages = os.path.join(base, "Lib", "site-packages")
|
||||||
|
else:
|
||||||
|
site_packages = os.path.join(base, "lib", "python%s" % sys.version[:3], "site-packages")
|
||||||
|
prev_sys_path = list(sys.path)
|
||||||
|
|
||||||
site.addsitedir(site_packages)
|
site.addsitedir(site_packages)
|
||||||
sys.real_prefix = sys.prefix
|
sys.real_prefix = sys.prefix
|
||||||
sys.prefix = base
|
sys.prefix = base
|
||||||
|
|||||||
8
env/bin/ipwhois_cli.py
vendored
8
env/bin/ipwhois_cli.py
vendored
@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2013-2017 Philip Hane
|
# Copyright (c) 2013-2019 Philip Hane
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@ -482,10 +482,8 @@ class IPWhoisCLI:
|
|||||||
if json_data is None:
|
if json_data is None:
|
||||||
json_data = {}
|
json_data = {}
|
||||||
|
|
||||||
# Python 2.6 doesn't support set literal expressions, use explicit
|
keys = {'asn', 'asn_cidr', 'asn_country_code', 'asn_date',
|
||||||
# set() instead.
|
'asn_registry', 'asn_description'}.intersection(json_data)
|
||||||
keys = set(['asn', 'asn_cidr', 'asn_country_code', 'asn_date',
|
|
||||||
'asn_registry', 'asn_description']).intersection(json_data)
|
|
||||||
|
|
||||||
output = ''
|
output = ''
|
||||||
|
|
||||||
|
|||||||
2
env/bin/ipwhois_utils_cli.py
vendored
2
env/bin/ipwhois_utils_cli.py
vendored
@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2013-2017 Philip Hane
|
# Copyright (c) 2013-2019 Philip Hane
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
|||||||
BIN
env/bin/python
vendored
BIN
env/bin/python
vendored
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
env/lib/python3.7/__pycache__/abc.cpython-37.pyc
vendored
BIN
env/lib/python3.7/__pycache__/abc.cpython-37.pyc
vendored
Binary file not shown.
BIN
env/lib/python3.7/__pycache__/base64.cpython-37.pyc
vendored
BIN
env/lib/python3.7/__pycache__/base64.cpython-37.pyc
vendored
Binary file not shown.
BIN
env/lib/python3.7/__pycache__/bisect.cpython-37.pyc
vendored
BIN
env/lib/python3.7/__pycache__/bisect.cpython-37.pyc
vendored
Binary file not shown.
BIN
env/lib/python3.7/__pycache__/codecs.cpython-37.pyc
vendored
BIN
env/lib/python3.7/__pycache__/codecs.cpython-37.pyc
vendored
Binary file not shown.
BIN
env/lib/python3.7/__pycache__/copy.cpython-37.pyc
vendored
BIN
env/lib/python3.7/__pycache__/copy.cpython-37.pyc
vendored
Binary file not shown.
BIN
env/lib/python3.7/__pycache__/copyreg.cpython-37.pyc
vendored
BIN
env/lib/python3.7/__pycache__/copyreg.cpython-37.pyc
vendored
Binary file not shown.
BIN
env/lib/python3.7/__pycache__/enum.cpython-37.pyc
vendored
BIN
env/lib/python3.7/__pycache__/enum.cpython-37.pyc
vendored
Binary file not shown.
BIN
env/lib/python3.7/__pycache__/fnmatch.cpython-37.pyc
vendored
BIN
env/lib/python3.7/__pycache__/fnmatch.cpython-37.pyc
vendored
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
env/lib/python3.7/__pycache__/hashlib.cpython-37.pyc
vendored
BIN
env/lib/python3.7/__pycache__/hashlib.cpython-37.pyc
vendored
Binary file not shown.
BIN
env/lib/python3.7/__pycache__/heapq.cpython-37.pyc
vendored
BIN
env/lib/python3.7/__pycache__/heapq.cpython-37.pyc
vendored
Binary file not shown.
BIN
env/lib/python3.7/__pycache__/hmac.cpython-37.pyc
vendored
BIN
env/lib/python3.7/__pycache__/hmac.cpython-37.pyc
vendored
Binary file not shown.
BIN
env/lib/python3.7/__pycache__/imp.cpython-37.pyc
vendored
BIN
env/lib/python3.7/__pycache__/imp.cpython-37.pyc
vendored
Binary file not shown.
BIN
env/lib/python3.7/__pycache__/io.cpython-37.pyc
vendored
BIN
env/lib/python3.7/__pycache__/io.cpython-37.pyc
vendored
Binary file not shown.
BIN
env/lib/python3.7/__pycache__/keyword.cpython-37.pyc
vendored
BIN
env/lib/python3.7/__pycache__/keyword.cpython-37.pyc
vendored
Binary file not shown.
Binary file not shown.
BIN
env/lib/python3.7/__pycache__/locale.cpython-37.pyc
vendored
BIN
env/lib/python3.7/__pycache__/locale.cpython-37.pyc
vendored
Binary file not shown.
Binary file not shown.
BIN
env/lib/python3.7/__pycache__/os.cpython-37.pyc
vendored
BIN
env/lib/python3.7/__pycache__/os.cpython-37.pyc
vendored
Binary file not shown.
Binary file not shown.
BIN
env/lib/python3.7/__pycache__/random.cpython-37.pyc
vendored
BIN
env/lib/python3.7/__pycache__/random.cpython-37.pyc
vendored
Binary file not shown.
BIN
env/lib/python3.7/__pycache__/re.cpython-37.pyc
vendored
BIN
env/lib/python3.7/__pycache__/re.cpython-37.pyc
vendored
Binary file not shown.
BIN
env/lib/python3.7/__pycache__/reprlib.cpython-37.pyc
vendored
BIN
env/lib/python3.7/__pycache__/reprlib.cpython-37.pyc
vendored
Binary file not shown.
BIN
env/lib/python3.7/__pycache__/shutil.cpython-37.pyc
vendored
BIN
env/lib/python3.7/__pycache__/shutil.cpython-37.pyc
vendored
Binary file not shown.
BIN
env/lib/python3.7/__pycache__/site.cpython-37.pyc
vendored
BIN
env/lib/python3.7/__pycache__/site.cpython-37.pyc
vendored
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
env/lib/python3.7/__pycache__/stat.cpython-37.pyc
vendored
BIN
env/lib/python3.7/__pycache__/stat.cpython-37.pyc
vendored
Binary file not shown.
BIN
env/lib/python3.7/__pycache__/struct.cpython-37.pyc
vendored
BIN
env/lib/python3.7/__pycache__/struct.cpython-37.pyc
vendored
Binary file not shown.
BIN
env/lib/python3.7/__pycache__/tarfile.cpython-37.pyc
vendored
BIN
env/lib/python3.7/__pycache__/tarfile.cpython-37.pyc
vendored
Binary file not shown.
Binary file not shown.
BIN
env/lib/python3.7/__pycache__/token.cpython-37.pyc
vendored
BIN
env/lib/python3.7/__pycache__/token.cpython-37.pyc
vendored
Binary file not shown.
Binary file not shown.
BIN
env/lib/python3.7/__pycache__/types.cpython-37.pyc
vendored
BIN
env/lib/python3.7/__pycache__/types.cpython-37.pyc
vendored
Binary file not shown.
Binary file not shown.
BIN
env/lib/python3.7/__pycache__/weakref.cpython-37.pyc
vendored
BIN
env/lib/python3.7/__pycache__/weakref.cpython-37.pyc
vendored
Binary file not shown.
61
env/lib/python3.7/distutils/__init__.py
vendored
61
env/lib/python3.7/distutils/__init__.py
vendored
@ -1,20 +1,21 @@
|
|||||||
|
import imp
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
import imp
|
|
||||||
import opcode # opcode is not a virtualenv module, so we can use it to find the stdlib
|
# opcode is not a virtualenv module, so we can use it to find the stdlib
|
||||||
# Important! To work on pypy, this must be a module that resides in the
|
# Important! To work on pypy, this must be a module that resides in the
|
||||||
# lib-python/modified-x.y.z directory
|
# lib-python/modified-x.y.z directory
|
||||||
|
import opcode
|
||||||
|
|
||||||
dirname = os.path.dirname
|
dirname = os.path.dirname
|
||||||
|
|
||||||
distutils_path = os.path.join(os.path.dirname(opcode.__file__), 'distutils')
|
distutils_path = os.path.join(os.path.dirname(opcode.__file__), "distutils")
|
||||||
if os.path.normpath(distutils_path) == os.path.dirname(os.path.normpath(__file__)):
|
if os.path.normpath(distutils_path) == os.path.dirname(os.path.normpath(__file__)):
|
||||||
warnings.warn(
|
warnings.warn("The virtualenv distutils package at %s appears to be in the same location as the system distutils?")
|
||||||
"The virtualenv distutils package at %s appears to be in the same location as the system distutils?")
|
|
||||||
else:
|
else:
|
||||||
__path__.insert(0, distutils_path)
|
__path__.insert(0, distutils_path) # noqa: F821
|
||||||
real_distutils = imp.load_module("_virtualenv_distutils", None, distutils_path, ('', '', imp.PKG_DIRECTORY))
|
real_distutils = imp.load_module("_virtualenv_distutils", None, distutils_path, ("", "", imp.PKG_DIRECTORY))
|
||||||
# Copy the relevant attributes
|
# Copy the relevant attributes
|
||||||
try:
|
try:
|
||||||
__revision__ = real_distutils.__revision__
|
__revision__ = real_distutils.__revision__
|
||||||
@ -22,18 +23,19 @@ else:
|
|||||||
pass
|
pass
|
||||||
__version__ = real_distutils.__version__
|
__version__ = real_distutils.__version__
|
||||||
|
|
||||||
from distutils import dist, sysconfig
|
from distutils import dist, sysconfig # isort:skip
|
||||||
|
|
||||||
try:
|
try:
|
||||||
basestring
|
basestring
|
||||||
except NameError:
|
except NameError:
|
||||||
basestring = str
|
basestring = str
|
||||||
|
|
||||||
## patch build_ext (distutils doesn't know how to get the libs directory
|
# patch build_ext (distutils doesn't know how to get the libs directory
|
||||||
## path on windows - it hardcodes the paths around the patched sys.prefix)
|
# path on windows - it hardcodes the paths around the patched sys.prefix)
|
||||||
|
|
||||||
if sys.platform == 'win32':
|
if sys.platform == "win32":
|
||||||
from distutils.command.build_ext import build_ext as old_build_ext
|
from distutils.command.build_ext import build_ext as old_build_ext
|
||||||
|
|
||||||
class build_ext(old_build_ext):
|
class build_ext(old_build_ext):
|
||||||
def finalize_options(self):
|
def finalize_options(self):
|
||||||
if self.library_dirs is None:
|
if self.library_dirs is None:
|
||||||
@ -45,57 +47,70 @@ if sys.platform == 'win32':
|
|||||||
old_build_ext.finalize_options(self)
|
old_build_ext.finalize_options(self)
|
||||||
|
|
||||||
from distutils.command import build_ext as build_ext_module
|
from distutils.command import build_ext as build_ext_module
|
||||||
|
|
||||||
build_ext_module.build_ext = build_ext
|
build_ext_module.build_ext = build_ext
|
||||||
|
|
||||||
## distutils.dist patches:
|
# distutils.dist patches:
|
||||||
|
|
||||||
old_find_config_files = dist.Distribution.find_config_files
|
old_find_config_files = dist.Distribution.find_config_files
|
||||||
|
|
||||||
|
|
||||||
def find_config_files(self):
|
def find_config_files(self):
|
||||||
found = old_find_config_files(self)
|
found = old_find_config_files(self)
|
||||||
system_distutils = os.path.join(distutils_path, 'distutils.cfg')
|
if os.name == "posix":
|
||||||
#if os.path.exists(system_distutils):
|
|
||||||
# found.insert(0, system_distutils)
|
|
||||||
# What to call the per-user config file
|
|
||||||
if os.name == 'posix':
|
|
||||||
user_filename = ".pydistutils.cfg"
|
user_filename = ".pydistutils.cfg"
|
||||||
else:
|
else:
|
||||||
user_filename = "pydistutils.cfg"
|
user_filename = "pydistutils.cfg"
|
||||||
user_filename = os.path.join(sys.prefix, user_filename)
|
user_filename = os.path.join(sys.prefix, user_filename)
|
||||||
if os.path.isfile(user_filename):
|
if os.path.isfile(user_filename):
|
||||||
for item in list(found):
|
for item in list(found):
|
||||||
if item.endswith('pydistutils.cfg'):
|
if item.endswith("pydistutils.cfg"):
|
||||||
found.remove(item)
|
found.remove(item)
|
||||||
found.append(user_filename)
|
found.append(user_filename)
|
||||||
return found
|
return found
|
||||||
|
|
||||||
|
|
||||||
dist.Distribution.find_config_files = find_config_files
|
dist.Distribution.find_config_files = find_config_files
|
||||||
|
|
||||||
## distutils.sysconfig patches:
|
# distutils.sysconfig patches:
|
||||||
|
|
||||||
old_get_python_inc = sysconfig.get_python_inc
|
old_get_python_inc = sysconfig.get_python_inc
|
||||||
|
|
||||||
|
|
||||||
def sysconfig_get_python_inc(plat_specific=0, prefix=None):
|
def sysconfig_get_python_inc(plat_specific=0, prefix=None):
|
||||||
if prefix is None:
|
if prefix is None:
|
||||||
prefix = sys.real_prefix
|
prefix = sys.real_prefix
|
||||||
return old_get_python_inc(plat_specific, prefix)
|
return old_get_python_inc(plat_specific, prefix)
|
||||||
|
|
||||||
|
|
||||||
sysconfig_get_python_inc.__doc__ = old_get_python_inc.__doc__
|
sysconfig_get_python_inc.__doc__ = old_get_python_inc.__doc__
|
||||||
sysconfig.get_python_inc = sysconfig_get_python_inc
|
sysconfig.get_python_inc = sysconfig_get_python_inc
|
||||||
|
|
||||||
old_get_python_lib = sysconfig.get_python_lib
|
old_get_python_lib = sysconfig.get_python_lib
|
||||||
|
|
||||||
|
|
||||||
def sysconfig_get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
|
def sysconfig_get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
|
||||||
if standard_lib and prefix is None:
|
if standard_lib and prefix is None:
|
||||||
prefix = sys.real_prefix
|
prefix = sys.real_prefix
|
||||||
return old_get_python_lib(plat_specific, standard_lib, prefix)
|
return old_get_python_lib(plat_specific, standard_lib, prefix)
|
||||||
|
|
||||||
|
|
||||||
sysconfig_get_python_lib.__doc__ = old_get_python_lib.__doc__
|
sysconfig_get_python_lib.__doc__ = old_get_python_lib.__doc__
|
||||||
sysconfig.get_python_lib = sysconfig_get_python_lib
|
sysconfig.get_python_lib = sysconfig_get_python_lib
|
||||||
|
|
||||||
old_get_config_vars = sysconfig.get_config_vars
|
old_get_config_vars = sysconfig.get_config_vars
|
||||||
|
|
||||||
|
|
||||||
def sysconfig_get_config_vars(*args):
|
def sysconfig_get_config_vars(*args):
|
||||||
real_vars = old_get_config_vars(*args)
|
real_vars = old_get_config_vars(*args)
|
||||||
if sys.platform == 'win32':
|
if sys.platform == "win32":
|
||||||
lib_dir = os.path.join(sys.real_prefix, "libs")
|
lib_dir = os.path.join(sys.real_prefix, "libs")
|
||||||
if isinstance(real_vars, dict) and 'LIBDIR' not in real_vars:
|
if isinstance(real_vars, dict) and "LIBDIR" not in real_vars:
|
||||||
real_vars['LIBDIR'] = lib_dir # asked for all
|
real_vars["LIBDIR"] = lib_dir # asked for all
|
||||||
elif isinstance(real_vars, list) and 'LIBDIR' in args:
|
elif isinstance(real_vars, list) and "LIBDIR" in args:
|
||||||
real_vars = real_vars + [lib_dir] # asked for list
|
real_vars = real_vars + [lib_dir] # asked for list
|
||||||
return real_vars
|
return real_vars
|
||||||
|
|
||||||
|
|
||||||
sysconfig_get_config_vars.__doc__ = old_get_config_vars.__doc__
|
sysconfig_get_config_vars.__doc__ = old_get_config_vars.__doc__
|
||||||
sysconfig.get_config_vars = sysconfig_get_config_vars
|
sysconfig.get_config_vars = sysconfig_get_config_vars
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user