-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
119 lines (105 loc) · 4 KB
/
build.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
"""
pymcuprog
Tools for programming of MCUs using Microchip CMSIS-DAP based debuggers
"""
import os
import sys
from os import getenv
from os import path
from os import chdir
from os import popen
import time
# To use a consistent encoding
from codecs import open
# Always prefer setuptools over distutils
from setuptools import find_packages
from cx_Freeze import setup, Executable
here = path.abspath(path.dirname(__file__))
chdir(here)
# Get the long description from the pypi file
# Using UTF8 and single newlines
with open(path.join(here, 'pypi.md'), 'rb') as f:
long_description = f.read().decode("utf-8").replace('\r\n', '\n')
# Set the package name:
name = 'mcuprog'
"""
Package version :
The version number follow the format major.minor.patch.build
major, minor and patch are set manually according to semantic versioning 2.0.0: https://semver.org
build is an incrementing number set by a build server
in case of installing from source, a Local Version Identifier (see PEP 440) is added
"""
# Package version setup
PACKAGE_VERSION = {
"major": 3,
"minor": 9,
"patch": 1,
# Will be replaced by build number from Jenkins. For local builds the build number is 0 and the 'snapshot' is
# added as Local Version Identifier
"build": '120',
}
version = "{}.{}.{}.{}".format(PACKAGE_VERSION['major'], PACKAGE_VERSION['minor'], PACKAGE_VERSION['patch'], PACKAGE_VERSION['build'])
print("Building {} version: {}".format(name, version))
# Create a "version.py" file in the package
fname = "pymcuprog/version.py"
with open(path.join(here, fname), 'w') as f:
f.write("\"\"\" This file was generated when {} was built \"\"\"\n".format(name))
f.write("VERSION = '{}'\n".format(version))
# The command below can fail if git command not available, or not in a git workspace folder
result = popen("git rev-parse HEAD").read()
commit_id = result.splitlines()[0] if result else "N/A"
f.write("COMMIT_ID = '{}'\n".format(commit_id))
f.write("BUILD_DATE = '{}'\n".format(time.strftime("%Y-%m-%d %H:%M:%S %z")))
# Read in requirements (dependencies) file
with open('requirements.txt') as f:
install_requires = f.read()
setup(
name=name,
version=version,
description='Tools for programming of MCUs using Microchip CMSIS-DAP based debuggers',
long_description=long_description,
long_description_content_type='text/markdown',
url='https://github.com/microchip-pic-avr-tools/pymcuprog',
license='MIT',
author='Microchip Technology',
author_email='support@microchip.com',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Topic :: Software Development :: Embedded Systems',
'License :: OSI Approved :: MIT License',
# pymcuprog does also work on Python 2.7 but it is not officially supported
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: Linux',
'Operating System :: MacOS',
],
packages=find_packages(exclude=['tests']),
# List of packages required to use this package
install_requires=install_requires,
# List of packages required to develop and test this package
extras_require={
'dev': ['pylint', 'mock', 'parameterized', 'pytest'],
},
# Include files from MANIFEST.in
include_package_data=True,
# Installable CLI entry point
entry_points={
'console_scripts': [
'pymcuprog=pymcuprog.pymcuprog:main',
],
},
executables = [
Executable(
'pymcuprog/pymcuprog.py', #can not change
base=None,
copyright='Protek Industries Co.,Ltd',
target_name="mcuprog.exe", #change target name
)],
options = {
'build_exe' : {'include_files' : ['pymcuprog/logging.yaml', 'pymcuprog/deviceinfo/devices','tools/runme.bat']},
},
)