Skip to content
This repository has been archived by the owner on Apr 16, 2019. It is now read-only.

Commit

Permalink
Use lib3to2 automatically when installing from Python 2.x.
Browse files Browse the repository at this point in the history
  • Loading branch information
EnigmaCurry committed Mar 24, 2011
1 parent a5130e4 commit c25c0ff
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 22 deletions.
22 changes: 10 additions & 12 deletions blogofile/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ def do_help(args):

if "none" in args.command:
parser.print_help()
print("\nSee 'blogofile help COMMAND' for more information"
" on a specific command.")
print("\nSee 'blogofile help COMMAND' for more information"+\
" on a specific command.")
else:
# Where did the subparser help text go? Let's get it back.
# Certainly there is a better way to retrieve the helptext than this...
Expand All @@ -215,11 +215,10 @@ def do_help(args):

# Print help for each subcommand requested.
for subcommand in args.command:
print("{0} - {1}".format(
subcommand, helptext[subcommand]), file=sys.stderr)
sys.stderr.write("{0} - {1}\n".format(subcommand, helptext[subcommand]))
parser = subparsers.choices[subcommand]
parser.print_help()
print("\n", file=sys.stderr)
sys.stderr.write("\n")
#Perform any extra help tasks:
if hasattr(parser, "extra_help"):
parser.extra_help()
Expand All @@ -230,7 +229,7 @@ def config_init(args):
# We already changed to the directory specified with --src-dir
config.init("_config.py")
except config.ConfigNotFoundException:
print("No configuration found in source dir: {0}".format(args.src_dir), file=sys.stderr)
sys.stderr.write("No configuration found in source dir: {0}\n".format(args.src_dir))
parser.exit(1, "Want to make a new site? Try `blogofile init`\n")


Expand Down Expand Up @@ -274,8 +273,8 @@ def do_debug():
from IPython.Shell import IPShellEmbed
bf.ipshell = IPShellEmbed()
elif os.environ['BLOGOFILE_DEBUG'] != "0":
print("Running in debug mode, waiting for debugger to connect. "
"Password is set to 'blogofile'")
print("Running in debug mode, waiting for debugger to connect. "+\
"Password is set to 'blogofile'")
import rpdb2
rpdb2.start_embedded_debugger("blogofile")
except KeyError:
Expand All @@ -285,12 +284,11 @@ def do_info(args):
"""Print some information about the Blogofile installation and the current site"""
print(("This is Blogofile (version {0}) -- http://www.blogofile.com".\
format(__version__)))
print("")
print("You are using {0} {1} from {2}".format(
platform.python_implementation(),platform.python_version(),
sys.executable))
### Show _config.py paths
print(("Default config file: {0}".format(config.default_config_path())))
print("(Override these default settings in your own _config.py, don't edit "
"the file above.)")
print("")
if os.path.isfile("_config.py"):
print(("Found site _config.py: {0}".format(os.path.abspath("_config.py"))))
else:
Expand Down
48 changes: 38 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,52 @@
from setuptools import setup, find_packages
import sys
import os
import os.path
import glob

def setup_python2():
#Blogofile is written for Python 3.
#But we can also experimentally support Python 2 with lib3to2.
from lib3to2 import main as three2two
from distutils import dir_util
import shutil
import shlex
tmp_root = os.path.join("build","py2_src")
tmp_src = os.path.join(tmp_root,"blogofile")
try:
shutil.rmtree(tmp_src)
except OSError:
pass #ignore if the directory doesn't exist.
shutil.copytree("blogofile",tmp_src)
three2two.main("lib3to2.fixes",shlex.split("-w {0}".format(tmp_src)))
return tmp_root

if sys.version_info <= (3,):
src_root = setup_python2()
sys.path.insert(0,src_root)
else:
src_root = os.curdir

import blogofile
from blogofile.site_init import zip_site_init

zip_site_init()

setup(name='Blogofile',

setup(name="Blogofile",
version=blogofile.__version__,
description='A static website compiler and blog engine',
author='Ryan McGuire',
author_email='ryan@enigmacurry.com',
url='http://www.blogofile.com',
license='MIT',
description="A static website compiler and blog engine",
author="Ryan McGuire",
author_email="ryan@enigmacurry.com",
url="http://www.blogofile.com",
license="MIT",
src_root=src_root,
packages=["blogofile", "blogofile/site_init"],
package_data = {"blogofile/site_init": ["*.zip"]},
install_requires =['mako',
'pytz',
'pyyaml',
'docutils'],
install_requires =["mako",
"pytz",
"pyyaml",
"docutils"],
entry_points="""
[console_scripts]
blogofile = blogofile.main:main
Expand Down

0 comments on commit c25c0ff

Please sign in to comment.