1# Copyright 2016 Google Inc. All rights reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15import os
16from datetime import datetime
17from setuptools import setup
18
19
20def version():
21    version = os.getenv('VERSION', None)
22    if version:
23        # Most git tags are prefixed with 'v' (example: v1.2.3) this is
24        # never desirable for artifact repositories, so we strip the
25        # leading 'v' if it's present.
26        return version[1:] if version.startswith('v') else version
27    else:
28        # Default version is an ISO8601 compiliant datetime. PyPI doesn't allow
29        # the colon ':' character in its versions, and time is required to allow
30        # for multiple publications to master in one day. This datetime string
31        # uses the "basic" ISO8601 format for both its date and time components
32        # to avoid issues with the colon character (ISO requires that date and
33        # time components of a date-time string must be uniformly basic or
34        # extended, which is why the date component does not have dashes.
35        #
36        # Publications using datetime versions should only be made from master
37        # to represent the HEAD moving forward.
38        version = datetime.utcnow().strftime('%Y%m%d%H%M%S')
39        print("VERSION environment variable not set, using datetime instead: {}"
40              .format(version))
41
42    return version
43
44setup(
45    name='flatbuffers',
46    version=version(),
47    license='Apache 2.0',
48    author='FlatBuffers Contributors',
49    author_email='me@rwinslow.com',
50    url='https://github.com/google/flatbuffers',
51    long_description=('Python runtime library for use with the Flatbuffers'
52                      'serialization format.'),
53    packages=['flatbuffers'],
54    include_package_data=True,
55    requires=[],
56    description='The FlatBuffers serialization format for Python',
57)
58