Skip to content

Commit 95b59cf

Browse files
committed
disable unicode at build time using --no-unicode option to setup.py
1 parent acf7fae commit 95b59cf

7 files changed

Lines changed: 57 additions & 4 deletions

File tree

quantities.egg-info/SOURCES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
setup.py
22
quantities/__init__.py
3+
quantities/config.py
34
quantities/decorators.py
45
quantities/dimensionality.py
56
quantities/markup.py

quantities/config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# THIS FILE IS AUTOMATICALLY GENERATED AT BUILD TIME
2+
# ANY CHANGES MADE HERE WILL BE LOST
3+
# PASS --no-unicode FLAG TO setup.py TO DISABLE UNICODE
4+
5+
USE_UNICODE = True

quantities/dimensionality.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
import numpy
99

10-
from .markup import USE_UNICODE, format_units, format_units_unicode
10+
from .config import USE_UNICODE
11+
from .markup import format_units, format_units_unicode
1112
from .registry import unit_registry
1213

1314

quantities/markup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# -*- coding: utf-8 -*-
22
"""
33
"""
4+
from __future__ import absolute_import
45

56
import operator
67

7-
USE_UNICODE = True
8+
from .config import USE_UNICODE
89

910
def superscript(val):
1011
# TODO: use a regexp:

quantities/unitquantity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
import numpy
66

7+
from .config import USE_UNICODE
78
from .dimensionality import Dimensionality
8-
from .markup import USE_UNICODE
99
from .quantity import Quantity
1010
from .registry import unit_registry
1111

quantities/units/compound.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"""
33
from __future__ import absolute_import
44

5-
from ..markup import USE_UNICODE, superscript
5+
from ..config import USE_UNICODE
6+
from ..markup import superscript
67
from ..unitquantity import UnitQuantity
78
from ..registry import unit_registry
89

setup.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,37 @@
1+
#!/usr/bin/env python
2+
3+
#+
4+
#
5+
# This file is part of quantities, a python package for handling physical
6+
# quantities based on numpy.
7+
#
8+
# Copyright (C) 2009 Darren Dale
9+
# http://packages.python.org/quantities
10+
# License: BSD (See doc/users/license.rst for full license)
11+
#
12+
# $Date$
13+
#
14+
#-
15+
16+
"""
17+
setup script for the quantities package
18+
19+
options:
20+
21+
* Unicode
22+
23+
Units are presented using unicode by default, but this can be problematic
24+
on some platforms like windows. Unicode can be disabled, and units
25+
presented as simple ASCII text by passing the "--no-unicode" flag to the
26+
setup script::
27+
28+
python setup.py build --no-unicode
29+
"""
30+
131
from __future__ import with_statement
232

33+
import sys
34+
335
try:
436
from setuptools import setup
537
except ImportError:
@@ -22,6 +54,18 @@
2254
d = "{'value': %s, 'precision': %s, 'units': '%s'}"%(val, prec, unit)
2355
f.write("physical_constants['%s'] = %s\n"%(name, d))
2456

57+
USE_UNICODE = True
58+
for arg in sys.argv[:]:
59+
if arg.find('--no-unicode') == 0:
60+
USE_UNICODE = False
61+
sys.argv.remove(arg)
62+
with file('quantities/config.py', 'w') as f:
63+
64+
f.write('# THIS FILE IS AUTOMATICALLY GENERATED AT BUILD TIME\n')
65+
f.write('# ANY CHANGES MADE HERE WILL BE LOST\n')
66+
f.write('# PASS --no-unicode FLAG TO setup.py TO DISABLE UNICODE\n\n')
67+
f.write('USE_UNICODE = %s'% USE_UNICODE)
68+
2569
desc = 'Support for physical quantities based on the popular numpy library'
2670
long_desc = "Quantities is designed to handle arithmetic and conversions of \
2771
physical quantities, which have a magnitude, dimensionality specified by \

0 commit comments

Comments
 (0)