I work offline from remote location about 2000m above the sea level. There
is no internet connection here, so I can not use tracker online. I need a
Python editor here, and I have Spyder checkout. The problem is that my
installation has only Python3. I've tried using 2to3 from setup.py
(attached), but it fails when I execute:
$ sudo python3 setup.py install
stderr.log and stdout.log are attached. Is it the intended behavior?
It is also hard find "Porting Python 2 Code to Python 3" article, because
it is not referenced from "Porting to Python 3.x" chapters.
--
--
anatoly t.
# -*- coding: utf-8 -*-
#
# Copyright © 2009-2010 Pierre Raybaut
# Licensed under the terms of the MIT License
# (see spyderlib/__init__.py for details)
"""
Spyder
==
The Scientific PYthon Development EnviRonment
"""
from distutils.core import setup
from distutils.command.build import build
try: # Python 3
from distutils.command.build_py import build_py_2to3 as build_py
except ImportError: # Python 2
from distutils.command.build_py import build_py
import os
import os.path as osp
import sys
try:
from sphinx import setup_command as sphinx_setup_command
except ImportError:
sphinx_setup_command = False
sys.stderr.write("Sphinx not installed. Documentation won't be built.\n")
def get_package_data(name, extlist):
"""Return data files for package *name* with extensions in *extlist*"""
flist = []
# Workaround to replace os.path.relpath (not available until Python 2.6):
offset = len(name)+len(os.pathsep)
for dirpath, _dirnames, filenames in os.walk(name):
for fname in filenames:
if not fname.startswith('.') and osp.splitext(fname)[1] in extlist:
flist.append(osp.join(dirpath, fname)[offset:])
return flist
def get_subpackages(name):
"""Return subpackages of package *name*"""
splist = []
for dirpath, _dirnames, _filenames in os.walk(name):
if osp.isfile(osp.join(dirpath, '__init__.py')):
splist.append(".".join(dirpath.split(os.sep)))
return splist
# for 2to3
cmdclass = {'build_py':build_py}
# Sphinx build (documentation)
if sphinx_setup_command:
class MyBuild(build):
def has_doc(self):
setup_dir = os.path.dirname(os.path.abspath(__file__))
return os.path.isdir(os.path.join(setup_dir, 'doc'))
sub_commands = build.sub_commands + [('build_doc', has_doc)]
class MyBuildDoc(sphinx_setup_command.BuildDoc):
def run(self):
build = self.get_finalized_command('build')
sys.path.insert(0, os.path.abspath(build.build_lib))
dirname = self.distribution.get_command_obj('build').build_purelib
self.builder_target_dir = osp.join(dirname, 'spyderlib', 'doc')
try:
setup_command.BuildDoc.run(self)
except UnicodeDecodeError:
sys.stderr.write( "ERROR: unable to build documentation "\
"because Sphinx do not handle source path "\
"with non-ASCII characters. Please try to "\
"move the source package to another location "\
"(path with *only* ASCII characters).\n")
sys.path.pop(0)
cmdclass.update( {'build': MyBuild, 'build_doc': MyBuildDoc} )
NAME = 'spyder'
LIBNAME = 'spyderlib'
from spyderlib import __version__, __project_url__
def get_packages():
"""Return package list"""
packages = get_subpackages(LIBNAME)+get_subpackages('spyderplugins')
if os.name == 'nt':
# Adding pyflakes and rope to the package if available in the
# repository (this is not conventional but Spyder really need
# those tools and there is not decent package manager on
# Windows platforms, so...)
for name in ('rope', 'pyflakes'):
if osp.isdir(name):
packages += get_subpackages(name)
return packages
setup(name=NAME,
version=__version__,
description='Scientific PYthon Development EnviRonment',
long_description=\
"""The spyderlib library includes Spyder, a free open-source Python
development environment providing MATLAB-like features in a simple
and light-weighted software.
It also provides ready-to-use pure-Python widgets to your PyQt4 or
PySide application: source code editor with syntax highlighting and
code introspection/analysis features, NumPy array editor, dictionary
editor, Python console, etc.""",
download_url='%s/files/%s-%s.zip' % (__project_url__, NAME, __version__),
author="Pierre Raybaut",
url=__project_url__,
license='MIT',
keywords='PyQt4 PySide editor shell console widgets IDE',
platforms=['any'],
packages=get_packages(),
package_data={LIBNAME:
get_package_data(LIBNAME, ('.mo', '.svg', '.png', '.css',
'.html', '.js')),