Skip to content

Commit

Permalink
Check pip version for the first run
Browse files Browse the repository at this point in the history
  • Loading branch information
realiti4 committed Jul 12, 2022
1 parent ff2de95 commit 4aa8bb2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions pip_upgrade/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ def __init__(self, args, config):
if len(config['restore']['last_exclude']) != 0:
self.restorable = True

# Upgrade if it is first run
if config.first_run:
self._upgrade_pip()

# Exclude editable and user defined packages
self.excluded_pkgs = [] if self.args.exclude is None else self.args.exclude
self.excluded_pkgs += self.config['conf']['exclude'].split(' ')
Expand Down Expand Up @@ -155,6 +159,10 @@ def upgrade(self):
print("A new update avaliable for pip-upgrade-tool.\nPlease manually upgrade the tool using 'python -m pip install -U pip-upgrade-tool'")
# cprint("A new update avaliable for pip-upgrade-tool.\nPlease manually upgrade the tool using 'python -m pip install -U pip-upgrade-tool'", color='yellow')

def _upgrade_pip(self):
print('Checking pip version for the first run...')
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-U', 'pip'])

def _help(self):
print("")
print("y : Continue")
Expand Down
2 changes: 2 additions & 0 deletions pip_upgrade/tools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def __init__(self):
self.home = os.path.expanduser('~')
self.name = '.pipupgrade.ini'
self.config = configparser.ConfigParser()
self.first_run = True

self._init()
self._check_validity()
Expand All @@ -33,6 +34,7 @@ def _init(self):
# Save
self._save()
else:
self.first_run = False
self._read()

def _check_validity(self):
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="pip-upgrade-tool",
version="0.7.2",
version="0.7.3",
author="Onur Cetinkol",
author_email="realiti44@gmail.com",
description="An easy tool for upgrading all of your packages while not breaking dependencies",
Expand All @@ -20,7 +20,7 @@
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires='>=3.6',
python_requires='>=3.7',
packages=["pip_upgrade", "pip_upgrade.tools"],
install_requires=["packaging"],
)

0 comments on commit 4aa8bb2

Please sign in to comment.