资源简介
可以使用pip install 直接在mac 系统上安装并且使用的igraph包
代码片段和文件信息
#!/usr/bin/env python
import atexit
import distutils.ccompiler
import glob
import os
import shutil
import subprocess
import sys
import tarfile
import tempfile
from select import select
try:
from urllib import urlretrieve
from urllib2 import Request urlopen URLError
except:
# Maybe Python 3?
from urllib.request import Request urlopen urlretrieve
from urllib.error import URLError
###########################################################################
# Global version number. Keep the format of the next line intact.
VERSION = ‘0.7.1-1‘
# Check Python‘s version info and exit early if it is too old
if sys.version_info < (2 5):
print(“This module requires Python >= 2.5“)
sys.exit(0)
###########################################################################
## Here be ugly workarounds. These must be run before setuptools
## is imported.
class Workaround(object):
“““base class for platform-specific workarounds and hacks that are
needed to get the Python interface compile with as little user
intervention as possible.“““
def required(self):
“““Returns ‘‘True‘‘ if the workaround is required on the platform
of the user and ‘‘False‘‘ otherwise.“““
raise NotImplementedError
def hack(self):
“““Installs the workaround. This method will get called if and only
if the ‘‘required()‘‘ method returns ‘‘True‘‘.
“““
raise NotImplementedError
class OSXClangAndSystemPythonWorkaround(Workaround):
“““Removes ‘‘-mno-fused-madd‘‘ from the arguments used to compile
Python extensions if the user is running OS X.“““
def customize_compiler(self compiler):
self._saved_customize_compiler(compiler)
while “-mno-fused-madd“ in compiler.compiler:
compiler.compiler.remove(“-mno-fused-madd“)
while “-mno-fused-madd“ in compiler.compiler_so:
compiler.compiler_so.remove(“-mno-fused-madd“)
while “-mno-fused-madd“ in compiler.linker_so:
compiler.linker_so.remove(“-mno-fused-madd“)
def required(self):
return sys.platform == “darwin“
def hack(self):
self.hack_for_distutils()
self.hack_for_setuptools()
def hack_for_distutils(self):
from distutils import sysconfig ccompiler
self._saved_customize_compiler = sysconfig.customize_compiler
sysconfig.customize_compiler = self.customize_compiler
ccompiler.customize_compiler = self.customize_compiler
def hack_for_setuptools(self):
if “setuptools.command.build_ext“ in sys.modules:
sys.modules[“setuptools.command.build_ext“].customize_compiler = \
self.customize_compiler
WORKAROUNDS = [
OSXClangAndSystemPythonWorkaround
]
for workaround_cls in WORKAROUNDS:
workaround = workaround_cls()
if workaround.required():
workaround.hack()
###########################################################################
try:
fr
评论
共有 条评论