|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
| 15 | +import os |
| 16 | +from datetime import datetime |
15 | 17 | from setuptools import setup |
16 | 18 |
|
| 19 | + |
| 20 | +def 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 | + |
17 | 44 | setup( |
18 | 45 | name='flatbuffers', |
19 | | - version='2015.05.14.0', |
| 46 | + version=version(), |
20 | 47 | license='Apache 2.0', |
21 | 48 | author='FlatBuffers Contributors', |
22 | 49 | author_email='me@rwinslow.com', |
|
0 commit comments