Merge pull request #648 from anthrotype/setuptools_scm

use setuptools_scm to manage package version and sdist file list
This commit is contained in:
Cosimo Lupo 2016-09-27 00:49:16 +01:00 committed by GitHub
commit 693ba4e126
9 changed files with 36 additions and 36 deletions

View File

@ -48,8 +48,8 @@ install:
- "python --version" - "python --version"
- "python -c \"import struct; print(struct.calcsize('P') * 8)\"" - "python -c \"import struct; print(struct.calcsize('P') * 8)\""
# upgrade pip to avoid out-of-date warnings # upgrade pip and setuptools to avoid out-of-date warnings
- "python -m pip install --disable-pip-version-check --user --upgrade pip" - "python -m pip install --disable-pip-version-check --user --upgrade pip setuptools"
- "python -m pip --version" - "python -m pip --version"
# install the dependencies to run the tests # install the dependencies to run the tests

View File

@ -11,7 +11,9 @@ matrix:
- python: 3.4 - python: 3.4
env: TOXENV=py34 env: TOXENV=py34
- python: 3.5 - python: 3.5
env: TOXENV=py35 env:
- TOXENV=py35
- BUILD_DIST=true
- python: pypy - python: pypy
env: TOXENV=pypy env: TOXENV=pypy
- language: generic - language: generic

View File

@ -17,5 +17,12 @@ if [[ "${TOXENV}" == "jython" ]]; then
jython -m pytest || true jython -m pytest || true
else else
source ~/.venv/bin/activate source ~/.venv/bin/activate
if [ "$BUILD_DIST" = true ]; then
# Travis by default only clones a 'shallow' repository with --depth=50.
# When building the distribution packages, we use git to determine the
# package version string (via setuptools_scm), hence we need to fetch
# the whole repo, and not just the last 50 commits.
git fetch --unshallow
fi
tox tox
fi fi

View File

@ -5,6 +5,4 @@ from fontTools.misc.loggingTools import configLogger
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
version = "3.0" __all__ = ["log", "configLogger"]
__all__ = ["version", "log", "configLogger"]

View File

@ -250,9 +250,13 @@ class TTFont(object):
list of tables to dump. The 'skipTables' argument may be a list of tables list of tables to dump. The 'skipTables' argument may be a list of tables
to skip, but only when the 'tables' argument is false. to skip, but only when the 'tables' argument is false.
""" """
from fontTools import version from fontTools.version import __version__
from fontTools.misc import xmlWriter from fontTools.misc import xmlWriter
# only write the MAJOR.MINOR version in the 'ttLibVersion' attribute of
# TTX files' root element (without PATCH or .dev suffixes)
version = ".".join(__version__.split('.')[:2])
if quiet is not None: if quiet is not None:
deprecateArgument("quiet", "configure logging instead") deprecateArgument("quiet", "configure logging instead")

View File

@ -1,7 +1,7 @@
"""\ """\
usage: ttx [options] inputfile1 [... inputfileN] usage: ttx [options] inputfile1 [... inputfileN]
TTX %s -- From OpenType To XML And Back TTX -- From OpenType To XML And Back
If an input file is a TrueType or OpenType font file, it will be If an input file is a TrueType or OpenType font file, it will be
dumped to an TTX file (an XML-based text format). dumped to an TTX file (an XML-based text format).
@ -12,7 +12,8 @@ usage: ttx [options] inputfile1 [... inputfileN]
never overwritten. never overwritten.
General options: General options:
-h Help: print this message -h Help: print this message.
--version: show version and exit.
-d <outputfolder> Specify a directory where the output files are -d <outputfolder> Specify a directory where the output files are
to be created. to be created.
-o <outputfile> Specify a file to write the output to. A special -o <outputfile> Specify a file to write the output to. A special
@ -93,12 +94,6 @@ import logging
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
def usage():
from fontTools import version
print(__doc__ % version)
numberAddedRE = re.compile("#\d+$") numberAddedRE = re.compile("#\d+$")
opentypeheaderRE = re.compile('''sfntVersion=['"]OTTO["']''') opentypeheaderRE = re.compile('''sfntVersion=['"]OTTO["']''')
@ -144,7 +139,11 @@ class Options(object):
for option, value in rawOptions: for option, value in rawOptions:
# general options # general options
if option == "-h": if option == "-h":
usage() print(__doc__)
sys.exit(0)
elif option == "--version":
from fontTools.version import __version__
print(__version__)
sys.exit(0) sys.exit(0)
elif option == "-d": elif option == "-d":
if not os.path.isdir(value): if not os.path.isdir(value):
@ -312,7 +311,7 @@ def guessFileType(fileName):
def parseOptions(args): def parseOptions(args):
rawOptions, files = getopt.getopt(args, "ld:o:fvqht:x:sim:z:baey:", rawOptions, files = getopt.getopt(args, "ld:o:fvqht:x:sim:z:baey:",
['unicodedata=', "recalc-timestamp", 'flavor=', ['unicodedata=', "recalc-timestamp", 'flavor=', 'version',
'with-zopfli']) 'with-zopfli'])
options = Options(rawOptions, len(files)) options = Options(rawOptions, len(files))
@ -373,8 +372,7 @@ def main(args=None):
try: try:
jobs, options = parseOptions(args) jobs, options = parseOptions(args)
except getopt.GetoptError as e: except getopt.GetoptError as e:
usage() print("%s\nERROR: %s" % (__doc__, e), file=sys.stderr)
print("ERROR:", e, file=sys.stderr)
sys.exit(2) sys.exit(2)
configLogger(level=options.logLevel) configLogger(level=options.logLevel)

4
Lib/fontTools/version.py Normal file
View File

@ -0,0 +1,4 @@
try:
__version__ = __import__('pkg_resources').require('fontTools')[0].version
except Exception:
__version__ = 'unknown'

View File

@ -1,16 +0,0 @@
include README.md
include LICENSE
include NEWS
include Snippets/*.py
include Snippets/README.md
include Doc/ttx.1
include MetaTools/*.py
include Lib/fontTools/ttLib/tables/table_API_readme.txt
include *requirements.txt
include tox.ini
include run-tests.sh
recursive-include Lib/fontTools testdata/*.ttx testdata/*.otx testdata/*.fea
recursive-include Lib/fontTools testdata/*.lwfn testdata/*.pfa testdata/*.pfb
recursive-include Lib/fontTools testdata/*.xml testdata/*.designspace

View File

@ -40,7 +40,7 @@ TrueType/OpenType fonts to and from an XML-based format.
setup( setup(
name="fonttools", name="fonttools",
version="3.1.0", use_scm_version=True,
description="Tools to manipulate font files", description="Tools to manipulate font files",
author="Just van Rossum", author="Just van Rossum",
author_email="just@letterror.com", author_email="just@letterror.com",
@ -58,6 +58,9 @@ setup(
data_files=[ data_files=[
('share/man/man1', ["Doc/ttx.1"]) ('share/man/man1', ["Doc/ttx.1"])
] if sys.platform.startswith('linux') else [], ] if sys.platform.startswith('linux') else [],
setup_requires=[
"setuptools_scm>=1.11.1",
],
entry_points={ entry_points={
'console_scripts': [ 'console_scripts': [
"ttx = fontTools.ttx:main", "ttx = fontTools.ttx:main",