Skip to content

Commit 39abd2e

Browse files
committed
update setup
1 parent 4e3ffa1 commit 39abd2e

File tree

1 file changed

+52
-25
lines changed

1 file changed

+52
-25
lines changed

setup.py

Lines changed: 52 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,66 @@
11
from __future__ import unicode_literals
22

33
import os
4-
import io
4+
import sys
5+
from shutil import rmtree
56

6-
from setuptools import setup
7-
8-
9-
def list_dir(dir):
10-
result = [dir]
11-
for file in os.listdir(dir):
12-
if os.path.isdir(os.path.join(dir, file)):
13-
result.extend(list_dir(os.path.join(dir, file)))
14-
return result
15-
16-
17-
def read(*parts):
18-
filename = os.path.join(os.path.abspath(os.path.dirname(__file__)), *parts)
19-
20-
with io.open(filename, encoding='utf-8', mode='rt') as fp:
21-
return fp.read()
7+
from setuptools import setup, Command
228

239

2410
NAME = "anti_header"
25-
PACKAGES = list_dir('anti_header')
2611
DESCRIPTION = "fake chrome, firefox, opera browser header anti header"
27-
# LONG_DESCRIPTION = read('README.md')
28-
LONG_DESCRIPTION = ''
29-
URL = "https://github.com/ihandmine/anti-header.git"
12+
URL = "https://github.com/ihandmine/anti-header"
3013
AUTHOR = "handmine"
3114
AUTHOR_EMAIL = "handmine@outlook.com"
32-
VERSION = "0.0.4"
15+
VERSION = "0.0.5"
3316
LICENSE = "MIT"
17+
REQUIRES_PYTHON = ">=3.7.0"
18+
19+
20+
here = os.path.abspath(os.path.dirname(__file__))
21+
with open(f"{here}/README.md", encoding='utf-8') as f:
22+
long_description = f.read()
23+
24+
25+
class UploadCommand(Command):
26+
"""Support setup.py upload."""
27+
28+
description = "Build and publish the package."
29+
user_options = []
30+
31+
@staticmethod
32+
def status(s):
33+
"""Prints things in bold."""
34+
print("\033[1m{0}\033[0m".format(s))
35+
36+
def initialize_options(self):
37+
pass
38+
39+
def finalize_options(self):
40+
pass
41+
42+
def run(self):
43+
try:
44+
self.status("Removing previous builds...")
45+
rmtree(os.path.join(here, "dist"))
46+
except OSError:
47+
pass
48+
49+
self.status("Building Source and Wheel distribution...")
50+
os.system("{0} setup.py sdist bdist_wheel".format(sys.executable))
51+
52+
self.status("Uploading the package to PyPI via Twine...")
53+
os.system("twine upload dist/*")
54+
55+
sys.exit()
56+
3457

3558
setup(
3659
name=NAME,
3760
version=VERSION,
3861
description=DESCRIPTION,
39-
long_description=LONG_DESCRIPTION,
62+
long_description=long_description,
63+
long_description_content_type='text/markdown',
4064
classifiers=[
4165
'License :: OSI Approved :: MIT License',
4266
'Programming Language :: Python',
@@ -47,9 +71,11 @@ def read(*parts):
4771
author=AUTHOR,
4872
author_email=AUTHOR_EMAIL,
4973
license=LICENSE,
50-
packages=PACKAGES,
74+
packages=[NAME],
75+
package_dir={NAME: NAME},
76+
python_requires=REQUIRES_PYTHON,
5177
include_package_data=True,
52-
zip_safe=True,
78+
zip_safe=False,
5379
install_requires=[
5480
"anti-useragent",
5581
],
@@ -58,4 +84,5 @@ def read(*parts):
5884
'fake', 'fake header', 'browser', 'spider header',
5985
'anti', 'anti header', 'scrapy header'
6086
],
87+
cmdclass={"upload": UploadCommand},
6188
)

0 commit comments

Comments
 (0)