forked from EnigmaCurry/blogofile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
103 lines (95 loc) · 3.29 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
from setuptools import setup, find_packages, Command
from setuptools.command.install import install as SetuptoolsInstaller
from distutils.command.sdist import sdist as _sdist
import sys
import os
import os.path
import glob
import subprocess
import shutil
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_src = "src_py2"
try:
shutil.rmtree(tmp_src)
except OSError:
pass #ignore if the directory doesn't exist.
shutil.copytree("blogofile",os.path.join(tmp_src,"blogofile"))
three2two.main("lib3to2.fixes",shlex.split("-w {0}".format(tmp_src)))
return tmp_src
dependencies = ["mako",
"jinja2",
"markdown",
"textile",
"pytz",
"pyyaml",
"pygments",
"docutils"]
dependency_links = []
if sys.version_info < (3,):
sys.path.insert(0,"src_py2")
src_root = os.path.join("src_py2","blogofile")
try:
import blogofile
except ImportError:
print("-"*80)
print("Python 3.x is required to develop and build Blogofile.")
print("Python 2.x versions of Blogofile can be installed with "
"a stable tarball\nfrom PyPI. e.g. 'easy_install blogofile'\n")
print("Alternatively, you can build your own tarball with "
"'python3 setup.py sdist'.")
print("This will require Python 3 and 3to2, and will produce a tarball "
"that can be\ninstalled in either Python 2 or 3.")
print("-"*80)
sys.exit(1)
if sys.version_info < (2,7):
dependencies.append("ordereddict")
else:
dependencies.remove("markdown")
dependencies.append("markdown>=2.0.3-py3k")
dependencies.remove("textile")
dependencies.append("textile>=2.1.4-py3k")
dependency_links.append("http://github.com/EnigmaCurry/python-markdown-py3k/tarball/2.0.3#egg=markdown-2.0.3-py3k")
dependency_links.append("http://github.com/EnigmaCurry/textile-py3k/tarball/2.1.4#egg=textile-2.1.4-py3k")
src_root = "blogofile"
import blogofile
blogofile.zip_site_init()
class sdist(_sdist):
"Custom sdist that takes care of 3to2 details"
def run(self):
setup_python2()
_sdist.run(self)
shutil.rmtree("src_py2")
class Test(Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
import tox
tox.cmdline()
os.chdir(os.path.split(os.path.abspath(__file__))[0])
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",
packages=["blogofile", "blogofile.site_init"],
package_dir = {"blogofile": src_root},
package_data = {"blogofile.site_init": ["*.zip"]},
install_requires = dependencies,
dependency_links = dependency_links,
cmdclass = {"test":Test,"sdist":sdist},
entry_points="""
[console_scripts]
blogofile = blogofile.main:main
"""
)