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 -c \"import struct; print(struct.calcsize('P') * 8)\""
# upgrade pip to avoid out-of-date warnings
- "python -m pip install --disable-pip-version-check --user --upgrade pip"
# upgrade pip and setuptools to avoid out-of-date warnings
- "python -m pip install --disable-pip-version-check --user --upgrade pip setuptools"
- "python -m pip --version"
# install the dependencies to run the tests

View File

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

View File

@ -17,5 +17,12 @@ if [[ "${TOXENV}" == "jython" ]]; then
jython -m pytest || true
else
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
fi

View File

@ -5,6 +5,4 @@ from fontTools.misc.loggingTools import configLogger
log = logging.getLogger(__name__)
version = "3.0"
__all__ = ["version", "log", "configLogger"]
__all__ = ["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
to skip, but only when the 'tables' argument is false.
"""
from fontTools import version
from fontTools.version import __version__
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:
deprecateArgument("quiet", "configure logging instead")

View File

@ -1,7 +1,7 @@
"""\
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
dumped to an TTX file (an XML-based text format).
@ -12,7 +12,8 @@ usage: ttx [options] inputfile1 [... inputfileN]
never overwritten.
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
to be created.
-o <outputfile> Specify a file to write the output to. A special
@ -93,12 +94,6 @@ import logging
log = logging.getLogger(__name__)
def usage():
from fontTools import version
print(__doc__ % version)
numberAddedRE = re.compile("#\d+$")
opentypeheaderRE = re.compile('''sfntVersion=['"]OTTO["']''')
@ -144,7 +139,11 @@ class Options(object):
for option, value in rawOptions:
# general options
if option == "-h":
usage()
print(__doc__)
sys.exit(0)
elif option == "--version":
from fontTools.version import __version__
print(__version__)
sys.exit(0)
elif option == "-d":
if not os.path.isdir(value):
@ -312,7 +311,7 @@ def guessFileType(fileName):
def parseOptions(args):
rawOptions, files = getopt.getopt(args, "ld:o:fvqht:x:sim:z:baey:",
['unicodedata=', "recalc-timestamp", 'flavor=',
['unicodedata=', "recalc-timestamp", 'flavor=', 'version',
'with-zopfli'])
options = Options(rawOptions, len(files))
@ -373,8 +372,7 @@ def main(args=None):
try:
jobs, options = parseOptions(args)
except getopt.GetoptError as e:
usage()
print("ERROR:", e, file=sys.stderr)
print("%s\nERROR: %s" % (__doc__, e), file=sys.stderr)
sys.exit(2)
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(
name="fonttools",
version="3.1.0",
use_scm_version=True,
description="Tools to manipulate font files",
author="Just van Rossum",
author_email="just@letterror.com",
@ -58,6 +58,9 @@ setup(
data_files=[
('share/man/man1', ["Doc/ttx.1"])
] if sys.platform.startswith('linux') else [],
setup_requires=[
"setuptools_scm>=1.11.1",
],
entry_points={
'console_scripts': [
"ttx = fontTools.ttx:main",