-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload_to_pypi.py
executable file
·43 lines (33 loc) · 1.24 KB
/
upload_to_pypi.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
#!/usr/bin/env python3
import os
import subprocess
import sys
def update_version():
with open('setup.py', 'r') as f:
content = f.read()
import re
version_match = re.search(r'version\s*=\s*["\']([^"\']+)["\']', content)
if version_match:
version = version_match.group(1)
parts = version.split('.')
parts[-1] = str(int(parts[-1]) + 1)
new_version = '.'.join(parts)
new_content = re.sub(r'(version\s*=\s*["\'])([^"\']+)(["\'])', r'\g<1>' + new_version + r'\g<3>', content)
with open('setup.py', 'w') as f:
f.write(new_content)
return new_version
else:
raise ValueError("Version not found in setup.py")
def main():
# Versiyon numarasını güncelle
new_version = update_version()
print(f"Version updated to {new_version}")
# Eski dağıtım dosyalarını temizle
os.system('rm -rf dist build *.egg-info')
# Yeni dağıtım dosyalarını oluştur
subprocess.check_call([sys.executable, 'setup.py', 'sdist', 'bdist_wheel'])
# Twine ile PyPI'ya yükle
subprocess.check_call(['twine', 'upload', 'dist/*'])
print(f"Successfully uploaded version {new_version} to PyPI")
if __name__ == "__main__":
main()