-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathupload.py
66 lines (55 loc) · 1.71 KB
/
upload.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
#!/usr/bin/env python3
import sys, os, datetime
# --------------
name = "pybaiduphoto"
scripts = []
description = "A simple API to interact with baidu-photo"
# --------------
python = sys.executable
filepath = os.path.realpath(__file__)
projpath = os.path.dirname(filepath)
dist = os.path.join(projpath, "dist")
sys.path.append(os.environ["PYLIB"])
from butlerapi import butlerapi, APIfromRequest
setupcontext = """
import setuptools
#from setuptools import setup
setuptools.setup(
name='{name}',
scripts={scripts} ,
version='{version}',
author='Hengyue Li',
author_email='305069590@qq.com',
packages=setuptools.find_packages(),
license='LICENSE.md',
description='{description}',
long_description=open('README.md',encoding="utf8").read(),
long_description_content_type="text/markdown",
install_requires={install_requires},
python_requires='>=3.6',
url = "https://github.com/HengyueLi/baiduphoto",
)
""".format(
name=name,
scripts=str(scripts),
version=datetime.datetime.now().strftime("%Y.%m.%d.%H%M"),
description=description,
install_requires=[
i for i in open("requirements.txt").read().split("\n") if len(i) > 1
],
)
os.system("rm -rf {}/*".format(dist))
os.system("rm -rf setup.py")
with open("setup.py", "w") as f:
f.write(setupcontext)
os.system("{} setup.py sdist".format(python))
# ---------------------------------------
# upload with username&password
info = butlerapi().getPassword(Class="default", item="pypi")
command = "twine upload dist/* -u {username} -p {password}".format(
username="__token__",
password=info["token"],
)
os.system(command)
# ---------------------------------------
os.system("rm -rf dist setup.py *egg-info*")