Skip to content

Commit 190bd6c

Browse files
committed
v0.1.1
1 parent 9811a84 commit 190bd6c

File tree

5 files changed

+116
-7
lines changed

5 files changed

+116
-7
lines changed

clusteval/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
__author__ = 'Erdogan Tasksen'
1313
__email__ = '[email protected]'
14-
__version__ = '0.1.0'
14+
__version__ = '0.1.1'
1515

1616

1717
# module level doc-string

make_clean.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
echo "Cleaning previous builds first.."
2+
rm -rf dist
3+
rm -rf build
4+
rm -rf hnet.egg-info

make_new_build.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@ rm -rf dist
33
rm -rf build
44
rm -rf clusteval.egg-info
55

6-
read -p "Making source build after pressing [Enter].."
7-
echo "Making new build.."
6+
echo "Making new wheel.."
87
echo ""
98
python setup.py bdist_wheel
109
echo ""
11-
read -p "Making source build after pressing [Enter].."
12-
echo
10+
11+
echo "Making source build .."
12+
echo ""
1313
python setup.py sdist
1414
echo ""
15+
1516
read -p "Press [Enter] to install the pip package..."
16-
pip install -U dist/clusteval-0.1.0-py3-none-any.whl
17+
pip install -U dist/clusteval-0.1.1-py3-none-any.whl
1718
echo ""
19+
1820
read -p ">twine upload dist/* TO UPLOAD TO PYPI..."
1921
echo ""
22+
2023
read -p "Press [Enter] key to close window..."

make_new_release.py

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
"""Make new release on github and pypi.
2+
3+
Description
4+
-----------
5+
A new release is created by taking the underneath steps:
6+
1. List all files in current directory and exclude all except the directory-of-interest
7+
2. Extract the version from the __init__.py file
8+
3. Remove old build directories such as dist, build and x.egg-info
9+
4. Git pull
10+
5. Get latest version from github
11+
6. Check if the current version is newer then github lates--version.
12+
a. Make new wheel, build and install package
13+
b. Set tag to newest version and push to git
14+
c. Upload to pypi (credentials required)
15+
"""
16+
17+
import os
18+
import re
19+
import numpy as np
20+
import urllib.request
21+
import yaml
22+
import shutil
23+
from packaging import version
24+
yaml.warnings({'YAMLLoadWarning': False})
25+
# GITHUB
26+
GITHUBNAME = 'erdogant'
27+
TWINE_PATH = 'C://Users/Erdogan/AppData/Roaming/Python/Python36/Scripts/twine.exe upload dist/*'
28+
29+
30+
# %% Main function
31+
if __name__ == '__main__':
32+
# Clean screen
33+
os.system('cls')
34+
# List all files in dir
35+
filesindir = np.array(list(map(lambda x: x.lower(), np.array(os.listdir()))))
36+
# Remove all the known not relevant files and dirs
37+
exclude = np.array(['__pycache__','_version','make_new_release.py','get_release_github.sh','setup.py','get_version.py','readme.md','.git','.gitignore','build','dist','docs','license','make_new_build.sh','make_new_realease.sh','manifest.in','requirements.txt','setup.cfg','test.py']) # noqa
38+
getfile = filesindir[np.isin(filesindir, exclude)==False][0] # noqa
39+
# This must be the dir of interest
40+
INIT_FILE = getfile + "/__init__.py"
41+
print('Working on package: [%s]' %(getfile))
42+
43+
# Find version now
44+
if os.path.isfile(INIT_FILE):
45+
# Extract version from __init__.py
46+
getversion = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", open(INIT_FILE, "rt").read(), re.M)
47+
if getversion:
48+
# Remove build directories
49+
print('Removing local build directories..')
50+
if os.path.isdir('dist'): shutil.rmtree('dist')
51+
if os.path.isdir('build'): shutil.rmtree('build')
52+
if os.path.isdir(getfile + '.egg-info'): shutil.rmtree(getfile + '.egg-info')
53+
54+
# Pull latest from github
55+
print('git pull')
56+
os.system('git pull')
57+
58+
# Get version number
59+
current_version = getversion.group(1)
60+
# This is the current version described in our __init__.py file
61+
print('Current version: %s' %(current_version))
62+
# Get latest version of github release
63+
github_url = 'https://api.github.com/repos/' + GITHUBNAME + '/' + getfile + '/releases/latest'
64+
github_page = urllib.request.urlopen(github_url)
65+
github_data = github_page.read()
66+
github_version = yaml.load(github_data)['tag_name']
67+
print('Github version: %s' %(github_version))
68+
print('Github version requested from: %s' %(github_url))
69+
70+
# Continue with the process of building a new version if the current version is really newer then the one on github!
71+
VERSION_OK = version.parse(current_version)>version.parse(github_version)
72+
if VERSION_OK:
73+
# Make new build
74+
print('Making new wheel..')
75+
os.system('python setup.py bdist_wheel')
76+
# Make new build
77+
print('Making source build..')
78+
os.system('python setup.py sdist')
79+
# Make new build
80+
print('Installing new wheel..')
81+
os.system('pip install -U dist/' + getfile + '-' + current_version + '-py3-none-any.whl')
82+
# git commit
83+
print('git add->commit->push')
84+
os.system('git add .')
85+
# os.system('git commit -m v'+current_version)
86+
# os.system('git push')
87+
# Set tag for this version
88+
print('Set new version tag: %s' %(current_version))
89+
os.system('git tag -a v' + current_version + ' -m "' + current_version + '"')
90+
os.system('git push origin --tags')
91+
print('Upload to pypi..')
92+
os.system(TWINE_PATH)
93+
else:
94+
print('Not released! You need to increase your version: [%s]' %(INIT_FILE))
95+
96+
# f = open("_version", "w")
97+
# f.write(new_version)
98+
# f.close()
99+
else:
100+
raise RuntimeError("Unable to find version string in %s." % (INIT_FILE,))
101+
else:
102+
print('Oh noo File not found: %s' %(INIT_FILE))

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
with open("README.md", "r") as fh:
1414
long_description = fh.read()
1515
setuptools.setup(
16-
install_requires=['matplotlib','numpy','pandas','tqdm','seaborn','hdbscan'],
16+
install_requires=['matplotlib','numpy','pandas','tqdm','seaborn'],
1717
python_requires='>=3',
1818
name='clusteval',
1919
version=new_version,

0 commit comments

Comments
 (0)