forked from iocoop/beancount
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·154 lines (134 loc) · 4.93 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/usr/bin/env python3
"""
Install script for beancount.
"""
__author__ = "Martin Blais <[email protected]>"
import os
from os import path
import runpy
import sys
import warnings
# Check if the version is sufficient.
if sys.version_info[:2] < (3,3):
raise SystemExit("ERROR: Insufficient Python version; you need v3.3 or higher.")
# Import setup().
setup_extra_kwargs = {}
from setuptools import setup, Extension
# Unused support for setuptools. Setuptools is seriously broken:
#
# * Using setuptools v15, build_ext --in-place puts the compiled Extension
# library under src/python. It needs to be under src/python/beancount/parser.
#
# * Using setuptools v18, it puts the library in the right place but invoking
# it not from pip3 or easy_install makes it complain about install_requires
# not being supported.
#
# Setuptools is broken. The only reason I was trying to use it was to support
# automatically installed dependencies. But it's so broken I'm giving up.
# Here's how to install dependencies:
#
# pip3 install python-dateutil bottle ply lxml
#
# You do this once.
# Removed code follows.
#
## try:
## # Use distutils if requested (this is use in testing).
## if 'BEANCOUNT_DISABLE_SETUPTOOLS' in os.environ:
## raise ImportError("Setuptools disabled explicitly")
##
## # Try to use setuptools first, if it is installed, because it supports
## # automatic installation of dependencies.
## from setuptools import setup, Extension
## if setuptools.__version__ < '18':
##
## setup_extra_kwargs.update(
## install_requires = ['python-dateutil', 'bottle', 'ply', 'lxml']
## )
## except ImportError:
## # If setuptools is not installed, fallback on the stdlib. This works too, it
## # just won't install the dependencies automatically.
## warnings.warn("Setuptools not installed; falling back on distutils. "
## "You will have to install dependencies explicitly.")
## from distutils.core import setup, Extension
# Make sure we can import hashsrc in order to create a binary with a checksum of
# the C source code. This checksum is used to issue a warning when loading an
# incompatible binary. (Also note that you should _NOT_ add the path of this
# file to the PYTHONPATH directly because it contains a 'parser' module and that
# overrides the stdlib 'parser' module which is used by setuptools, and causes a
# subtle bug. That's why I import this utility directly from path).
hashsrc = runpy.run_path(path.join(path.dirname(__file__),
'src/python/beancount/parser/hashsrc.py'))
hash_parser_source_files = hashsrc['hash_parser_source_files']
# Explicitly list the scripts to install.
install_scripts = [path.join('bin', x) for x in """
bean-bake
bean-check
bean-doctor
bean-report
bean-query
bean-web
bean-example
bean-format
bean-sql
treeify
upload-csv-to-google-sheet
""".split() if x and not x.startswith('#')]
# Create a setup.
# Please read: http://furius.ca/beancount/doc/install about version numbers.
setup(
name="beancount",
version='2.0b3',
description="Command-line Double-Entry Accounting",
long_description=
"""
A double-entry accounting system that uses a simple text file format
as input. A few Python scripts are used to parse the contents of the
file, for example, to serve the contents as a locally running web
server. Scripts are provided to convert from various input files into
Beancount's input format.
""",
license="GPL",
author="Martin Blais",
author_email="[email protected]",
url="http://furius.ca/beancount",
download_url="http://bitbucket.org/blais/beancount",
package_dir = {'': 'src/python',},
packages = ['beancount',
'beancount.parser',
'beancount.core',
'beancount.ops',
'beancount.plugins',
'beancount.query',
'beancount.reports',
'beancount.scripts',
'beancount.web',
'beancount.docs',
'beancount.utils'],
package_data = {
'beancount.web': ['*.ico',
'*.html',
'*.css',
'third_party/*.js'],
'beancount.reports': ['*.html'],
},
scripts=install_scripts,
ext_modules=[
Extension("beancount.parser._parser",
sources=[
"src/python/beancount/parser/lexer.c",
"src/python/beancount/parser/grammar.c",
"src/python/beancount/parser/parser.c"
],
define_macros=[('PARSER_SOURCE_HASH',
'"{}"'.format(hash_parser_source_files()))]),
],
install_requires=[
'python-dateutil',
'bottle',
'ply',
'lxml',
],
# Add optional arguments that only work with some variants of setup().
**setup_extra_kwargs
)