Skip to content

Commit b656437

Browse files
author
Your Name
committed
add a working build script
1 parent 2f24827 commit b656437

File tree

1 file changed

+129
-0
lines changed

1 file changed

+129
-0
lines changed

setup.py

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
# Note: To use the 'upload' functionality of this file, you must:
5+
# $ pipenv install twine --dev
6+
7+
import io
8+
import os
9+
import sys
10+
from shutil import rmtree
11+
12+
from setuptools import find_packages, setup, Command
13+
14+
# Package meta-data.
15+
NAME = 'swm-android'
16+
DESCRIPTION = 'Android window manager using Scrcpy on PC'
17+
URL = 'https://github.com/james4ever0/swm'
18+
EMAIL = 'randomvoidmail@foxmail.com'
19+
AUTHOR = 'James Brown'
20+
REQUIRES_PYTHON = '>=3.6.0'
21+
VERSION = '0.0.2'
22+
23+
# What packages are required for this module to be executed?
24+
REQUIRED = open('requirements.txt').read().split('\n')
25+
26+
# What packages are optional?
27+
EXTRAS = {
28+
# 'fancy feature': ['django'],
29+
}
30+
31+
# The rest you shouldn't have to touch too much :)
32+
# ------------------------------------------------
33+
# Except, perhaps the License and Trove Classifiers!
34+
# If you do change the License, remember to change the Trove Classifier for that!
35+
36+
here = os.path.abspath(os.path.dirname(__file__))
37+
38+
# Import the README and use it as the long-description.
39+
# Note: this will only work if 'README.md' is present in your MANIFEST.in file!
40+
try:
41+
with io.open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
42+
long_description = '\n' + f.read()
43+
except FileNotFoundError:
44+
long_description = DESCRIPTION
45+
46+
# Load the package's __version__.py module as a dictionary.
47+
about = {}
48+
if not VERSION:
49+
project_slug = "swm"
50+
with open(os.path.join(here, project_slug, '__version__.py')) as f:
51+
exec(f.read(), about)
52+
else:
53+
about['__version__'] = VERSION
54+
55+
56+
class UploadCommand(Command):
57+
"""Support setup.py upload."""
58+
59+
description = 'Build and publish the package.'
60+
user_options = []
61+
62+
@staticmethod
63+
def status(s):
64+
"""Prints things in bold."""
65+
print('\033[1m{0}\033[0m'.format(s))
66+
67+
def initialize_options(self):
68+
pass
69+
70+
def finalize_options(self):
71+
pass
72+
73+
def run(self):
74+
try:
75+
self.status('Removing previous builds…')
76+
rmtree(os.path.join(here, 'dist'))
77+
rmtree(os.path.join(here, 'build'))
78+
except OSError:
79+
pass
80+
81+
self.status('Building Source and Wheel (universal) distribution…')
82+
os.system('{0} setup.py sdist bdist_wheel --universal'.format(sys.executable))
83+
84+
self.status('Uploading the package to PyPI via Twine…')
85+
os.system('twine upload dist/*')
86+
87+
# self.status('Pushing git tags…')
88+
# os.system('git tag v{0}'.format(about['__version__']))
89+
# os.system('git push --tags')
90+
91+
sys.exit()
92+
93+
94+
# Where the magic happens:
95+
setup(
96+
name=NAME,
97+
version=about['__version__'],
98+
description=DESCRIPTION,
99+
long_description=long_description,
100+
long_description_content_type='text/markdown',
101+
author=AUTHOR,
102+
author_email=EMAIL,
103+
python_requires=REQUIRES_PYTHON,
104+
url=URL,
105+
packages=find_packages(exclude=["tests", "*.tests", "*.tests.*", "tests.*"]),
106+
# If your package is a single module, use this instead of 'packages':
107+
# py_modules=['swm'],
108+
entry_points={
109+
'console_scripts': ['swm=swm:cli.main'],
110+
},
111+
install_requires=REQUIRED,
112+
extras_require=EXTRAS,
113+
include_package_data=True,
114+
license='MIT',
115+
classifiers=[
116+
# Trove classifiers
117+
# Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers
118+
'License :: OSI Approved :: MIT License',
119+
'Programming Language :: Python',
120+
'Programming Language :: Python :: 3',
121+
'Programming Language :: Python :: 3.6',
122+
'Programming Language :: Python :: Implementation :: CPython',
123+
'Programming Language :: Python :: Implementation :: PyPy'
124+
],
125+
# $ setup.py publish support.
126+
cmdclass={
127+
'upload': UploadCommand,
128+
},
129+
)

0 commit comments

Comments
 (0)