Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find pip cross platform without environment variable #674

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions _caster.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from castervoice.lib import control
_NEXUS = control.nexus()
_NEXUS.dep.initialize()
from castervoice.lib.ctrl.dependencies import pip_path, update
from castervoice.lib.ctrl.dependencies import find_pip, update
from castervoice.lib import navigation
navigation.initialize_clipboard(_NEXUS)

Expand Down Expand Up @@ -68,6 +68,7 @@ def change_monitor():
else:
print("This command requires SikuliX to be enabled in the settings file")

pip = find_pip()

class MainRule(MergeRule):
@staticmethod
Expand All @@ -84,12 +85,13 @@ def generate_sm_ccr_choices(nexus):
choices[ccr_choice] = ccr_choice
return Choice("name2", choices)


mapping = {
# update management
"update caster":
R(DependencyUpdate([pip_path, "install", "--upgrade", "castervoice"])),
R(DependencyUpdate([pip, "install", "--upgrade", "castervoice"])),
"update dragonfly":
R(DependencyUpdate([pip_path, "install", "--upgrade", "dragonfly2"])),
R(DependencyUpdate([pip, "install", "--upgrade", "dragonfly2"])),

# hardware management
"volume <volume_mode> [<n>]":
Expand Down
22 changes: 10 additions & 12 deletions castervoice/lib/ctrl/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,23 @@
@author: synkarius
'''

import os, socket, time, pkg_resources, subprocess
import os, sys, socket, time, pkg_resources, subprocess
from pkg_resources import VersionConflict, DistributionNotFound
from subprocess import Popen
from castervoice.lib import settings

pip_path = None
update = None


def find_pip():
# Find the pip.exe script for Python 2.7. Fallback on pip.exe.
global pip_path
python_scripts = os.path.join("Python27", "Scripts")
for path in os.environ["PATH"].split(";"):
pip = os.path.join(path, "pip.exe")
if path.endswith(python_scripts) and os.path.isfile(pip):
pip_path = pip
break
# Find the pip script for Python.
python_scripts = os.path.join(sys.exec_prefix, "Scripts")
if sys.platform == "win32":
pip = os.path.join(python_scripts, "pip.exe")
return pip
if sys.platform == "linux" or "linux2":
pip = os.path.join(python_scripts, "pip")
return pip


def install_type():
Expand Down Expand Up @@ -54,7 +53,7 @@ def internet_check(host="1.1.1.1", port=53, timeout=3):

def dependency_check(command=None):
# Check for updates pip packages castervoice/dragonfly2
com = [pip_path, "search", command]
com = [find_pip(), "search", command]
startupinfo = None
global update
try:
Expand Down Expand Up @@ -132,7 +131,6 @@ class DependencyMan:
# Initializes functions
def initialize(self):
install = install_type()
find_pip()
if install is "classic":
dep_min_version()
dep_missing()
Expand Down