forked from mar10/pyftpsync
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup_bdist_msi.py
135 lines (118 loc) · 4.51 KB
/
setup_bdist_msi.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env python
# NOTE: isort must not chage this import order:
# isort: skip_file
import os
import re
import sys
from setuptools import setup
from cx_Freeze import setup, Executable # noqa re-import setup
from ftpsync import __version__
# Check for Windows MSI Setup
if "bdist_msi" not in sys.argv: # or len(sys.argv) != 2:
raise RuntimeError(
"This setup.py variant is only for creating 'bdist_msi' targets: {}\n"
"Example `{} bdist_msi`".format(sys.argv, sys.argv[0])
)
org_version = __version__
# 'setup.py upload' fails on Vista, because .pypirc is searched on 'HOME' path
if "HOME" not in os.environ and "HOMEPATH" in os.environ:
os.environ.setdefault("HOME", os.environ.get("HOMEPATH", ""))
print("Initializing HOME environment variable to '{}'".format(os.environ["HOME"]))
# Since we included pywin32 extensions, cx_Freeze tries to create a
# version resource. This only supports the 'a.b.c[.d]' format.
# Our version has either the for '1.2.3' or '1.2.3-a1'
major, minor, patch = org_version.split(".", 3)
major = int(major)
minor = int(minor)
if "-" in patch:
# We have a pre-release version, e.g. '1.2.3-a1'.
# This is presumably a post-release increment after '1.2.2' release.
# It must NOT be converted to '1.2.3.1', since that would be *greater*
# than '1.2.3', which is not even released yet.
# Approach 1:
# We cannot guarantee that '1.2.2.1' is correct either, so for
# pre-releases we assume '0.0.0.0':
# major = minor = patch = alpha = 0
# Approach 2:
# '1.2.3-a1' was presumably a post-release increment after '1.2.2',
# so assume '1.2.2.1':
patch, alpha = patch.split("-", 1)
patch = int(patch)
# Remove leading letters
alpha = re.sub("^[a-zA-Z]+", "", alpha)
alpha = int(alpha)
if patch >= 1:
patch -= 1 # 1.2.3-a1 => 1.2.2.1
else:
# may be 1.2.0-a1 or 2.0.0-a1: we don't know what the previous release was
major = minor = patch = alpha = 0
else:
patch = int(patch)
alpha = 0
version = "{}.{}.{}.{}".format(major, minor, patch, alpha)
print("Version {}, using {}".format(org_version, version))
try:
readme = open("README.md", "rt").read()
except IOError:
readme = "(readme not found. Running from tox/setup.py test?)"
# NOTE: Only need to list requirements that are not discoverable by scanning
# the main package. For example due to dynamic or optional imports.
# Also, cx_Freeze may have difficulties with packages listed here, e.g. PyYAML:
# https://github.com/marcelotduarte/cx_Freeze/issues/1541
install_requires = []
setup_requires = install_requires
tests_require = []
executables = [
Executable(
script="ftpsync/pyftpsync.py",
base=None,
# base="Win32GUI",
target_name="pyftpsync.exe",
icon="docs/logo.ico",
shortcut_name="pyftpsync",
copyright="(c) 2012-2022 Martin Wendt",
# trademarks="...",
)
]
# See https://cx-freeze.readthedocs.io/en/latest/distutils.html#build-exe
build_exe_options = {
# "init_script": "Console",
"includes": install_requires,
"packages": ["keyring.backends"], # loaded dynamically
"constants": "BUILD_COPYRIGHT='(c) 2012-2022 Martin Wendt'",
}
# See https://cx-freeze.readthedocs.io/en/latest/distutils.html#bdist-msi
bdist_msi_options = {
"upgrade_code": "{8F4CA3EF-06AD-418E-A64D-B975E3CFA3F6}",
"add_to_path": True,
# "install_icon": "docs/logo.ico",
# "all_users": True,
# "summary_data": {"author": "Martin Wendt"},
}
setup(
name="pyftpsync",
version=version,
author="Martin Wendt",
author_email="[email protected]",
# copyright="(c) 2012-2022 Martin Wendt",
maintainer="Martin Wendt",
maintainer_email="[email protected]",
url="https://github.com/mar10/pyftpsync",
description="Synchronize directories using FTP(S), SFTP, or file system access.",
long_description=readme,
long_description_content_type="text/markdown",
# Not required for this build-only setup config:
classifiers=[],
keywords="python ftp ftps sftp synchronize tls tool",
license="The MIT License",
install_requires=install_requires,
setup_requires=setup_requires,
tests_require=tests_require,
packages=["ftpsync"],
zip_safe=False,
extras_require={},
# cmdclass={"test": ToxCommand, "sphinx": SphinxCommand},
entry_points={"console_scripts": ["pyftpsync=ftpsync.pyftpsync:run"]},
executables=executables,
options={"build_exe": build_exe_options, "bdist_msi": bdist_msi_options},
)