資源簡介
python的gensim最新包,windows下安裝python setup.py install
代碼片段和文件信息
#!python
“““Bootstrap?setuptools?installation
If?you?want?to?use?setuptools?in?your?package‘s?setup.py?just?include?this
file?in?the?same?directory?with?it?and?add?this?to?the?top?of?your?setup.py::
????from?ez_setup?import?use_setuptools
????use_setuptools()
If?you?want?to?require?a?specific?version?of?setuptools?set?a?download
mirror?or?use?an?alternate?download?directory?you?can?do?so?by?supplying
the?appropriate?options?to?‘‘use_setuptools()‘‘.
This?file?can?also?be?run?as?a?script?to?install?or?upgrade?setuptools.
“““
import?os
import?shutil
import?sys
import?tempfile
import?tarfile
import?optparse
import?subprocess
import?platform
from?distutils?import?log
try:
????from?site?import?USER_SITE
except?ImportError:
????USER_SITE?=?None
DEFAULT_VERSION?=?“1.3.2“
DEFAULT_URL?=?“https://pypi.python.org/packages/source/s/setuptools/“
def?_python_cmd(*args):
????args?=?(sys.executable)?+?args
????return?subprocess.call(args)?==?0
def?_check_call_py24(cmd?*args?**kwargs):
????res?=?subprocess.call(cmd?*args?**kwargs)
????class?CalledProcessError(Exception):
????????pass
????if?not?res?==?0:
????????msg?=?“Command?‘%s‘?return?non-zero?exit?status?%d“?%?(cmd?res)
????????raise?CalledProcessError(msg)
vars(subprocess).setdefault(‘check_call‘?_check_call_py24)
def?_install(tarball?install_args=()):
????#?extracting?the?tarball
????tmpdir?=?tempfile.mkdtemp()
????log.warn(‘Extracting?in?%s‘?tmpdir)
????old_wd?=?os.getcwd()
????try:
????????os.chdir(tmpdir)
????????tar?=?tarfile.open(tarball)
????????_extractall(tar)
????????tar.close()
????????#?going?in?the?directory
????????subdir?=?os.path.join(tmpdir?os.listdir(tmpdir)[0])
????????os.chdir(subdir)
????????log.warn(‘Now?working?in?%s‘?subdir)
????????#?installing
????????log.warn(‘Installing?Setuptools‘)
????????if?not?_python_cmd(‘setup.py‘?‘install‘?*install_args):
????????????log.warn(‘Something?went?wrong?during?the?installation.‘)
????????????log.warn(‘See?the?error?message?above.‘)
????????????#?exitcode?will?be?2
????????????return?2
????finally:
????????os.chdir(old_wd)
????????shutil.rmtree(tmpdir)
def?_build_egg(egg?tarball?to_dir):
????#?extracting?the?tarball
????tmpdir?=?tempfile.mkdtemp()
????log.warn(‘Extracting?in?%s‘?tmpdir)
????old_wd?=?os.getcwd()
????try:
????????os.chdir(tmpdir)
????????tar?=?tarfile.open(tarball)
????????_extractall(tar)
????????tar.close()
????????#?going?in?the?directory
????????subdir?=?os.path.join(tmpdir?os.listdir(tmpdir)[0])
????????os.chdir(subdir)
????????log.warn(‘Now?working?in?%s‘?subdir)
????????#?building?an?egg
????????log.warn(‘Building?a?Setuptools?egg?in?%s‘?to_dir)
????????_python_cmd(‘setup.py‘?‘-q‘?‘bdist_egg‘?‘--dist-dir‘?to_dir)
????finally:
????????os.chdir(old_wd)
????????shutil.rmtree(tmpdir)
????#?returning?the?result
????log.warn(egg)
????if?not?os.path.exists(egg):
????????raise?IOError(‘Could?not?build?the?egg.‘)
def?_do_download(version?download_base?to_dir?download_delay):
????
評論
共有 條評論