def get_modules_version(python_path): """ return a dictionary { module:version } @param python_path path to python @return dictionary """ if sys.platform.startswith("win"): prog = os.path.join(python_path, "Scripts", "pip.exe") if not os.path.exists(prog): prog = get_pip_program(exe=python_path) else: prog = get_pip_program(exe=python_path) cmd = prog + " list" from pip import __version__ if int(__version__.split(".")[0]) >= 9: cmd += " --format=legacy" try: out, err = run_cmd(cmd, wait=True, fLOG=None, change_path=python_path) except Exception as e: raise Exception("unable to run: {0}".format(cmd)) from e if err is not None and len(err) > 0: if len(err.split("\n")) > 3 or \ "You should consider upgrading via the 'pip install --upgrade pip' command." not in err: raise Exception( "unable to run, #lines {0}\nERR-8:\n{1}\nOUT:\n{2}".format( len(err.split("\n")), err, out)) lines = out.split("\n") res = {} for line in lines: if "(" in line: spl = line.split() if len(spl) == 2: a = spl[0] b = spl[1].strip(" \n\r") res[a] = b.strip("()") al = a.lower() if al != a: res[al] = res[a] return res
def get_modules_version(python_path): """ return a dictionary { module:version } @param python_path path to python @return dictionary """ if sys.platform.startswith("win"): prog = os.path.join(python_path, "Scripts", "pip.exe") if not os.path.exists(prog): prog = get_pip_program(exe=python_path) else: prog = get_pip_program(exe=python_path) cmd = prog + " list" from pip import __version__ if int(__version__.split(".")[0]) >= 9: cmd += " --format=legacy" try: out, err = run_cmd(cmd, wait=True, fLOG=None, change_path=python_path) except Exception as e: raise Exception("unable to run: {0}".format(cmd)) from e if err is not None and len(err) > 0: if len(err.split("\n")) > 3 or \ "You should consider upgrading via the 'pip install --upgrade pip' command." not in err: raise Exception("unable to run, #lines {0}\nERR:\n{1}\nOUT:\n{2}".format( len(err.split("\n")), err, out)) lines = out.split("\n") res = {} for line in lines: if "(" in line: spl = line.split() if len(spl) == 2: a = spl[0] b = spl[1].strip(" \n\r") res[a] = b.strip("()") al = a.lower() if al != a: res[al] = res[a] return res
# The master toctree document. master_doc = 'index' # General information about the project. project = 'pip' copyright = '2008-2012, The pip developers' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. try: from pip import __version__ # The short X.Y version. version = '.'.join(__version__.split('.')[:2]) # The full version, including alpha/beta/rc tags. release = __version__ except ImportError: version = release = 'dev' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. today_fmt = '%B %d, %Y'
import importlib import threading from functools import partial import logging from apscheduler.schedulers.background import BackgroundScheduler from interruptingcow import timeout from pytz import utc from workers_queue import _WORKERS_QUEUE import logger from pip import __version__ as pip_version if int(pip_version.split('.')[0]) >= 10: from pip._internal import main as pip_main else: from pip import main as pip_main _LOGGER = logger.get(__name__) class WorkersManager: class Command: def __init__(self, callback, timeout, args=(), options=dict()): self._callback = callback self._timeout = timeout self._args = args self._options = options self._source = '{}.{}'.format(callback.__self__.__class__.__name__ if hasattr(callback, '__self__') else callback.__module__, callback.__name__) def execute(self):
# The master toctree document. master_doc = 'index' # General information about the project. project = 'pip' copyright = '2008-2014, PyPA' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. try: from pip import __version__ # The short X.Y version. version = '.'.join(__version__.split('.')[:2]) # The full version, including alpha/beta/rc tags. release = __version__ except ImportError: version = release = 'dev' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. today_fmt = '%B %d, %Y'
import setuptools import sys # install requirements for mixed precision training if "amp" in sys.argv: sys.argv.remove("amp") from pip import __version__ as PIP_VERSION PIP_MAJOR, PIP_MINOR = [int(v) for v in PIP_VERSION.split(".")[:2]] if PIP_MAJOR <= 9: raise RuntimeError( "Current version of pip is not compatible with `apex`," "you may need to install `apex` manually.") elif 10 <= PIP_MAJOR <= 19 and PIP_MINOR < 3: from pip._internal import main as pipmain else: from pip._internal.main import main as pipmain pipmain([ "install", "git+https://github.com/NVIDIA/apex", "-v", "--no-cache-dir", "--global-option=--cpp_ext", "--global-option=--cuda_ext", ]) with open("README.md", "r") as f: long_description = f.read()
# October 2018, Lewis Gaul """ Test the package requirements are installed. """ import pathlib from typing import List import pkg_resources from pip import __version__ as pip_version_str pip_version = float(".".join(pip_version_str.split(".")[:2])) def parse_requirements(path) -> List[str]: assert pip_version >= 19 from pip._internal.req import parse_requirements try: from pip._internal.download import PipSession except ImportError: from pip._internal.network.session import PipSession reqs = parse_requirements(str(path), session=PipSession()) try: return [r.requirement for r in reqs] except AttributeError: return [str(r.req) for r in reqs]
import os from setuptools import find_packages, setup from glob import glob from os.path import basename from os.path import splitext from pip import __version__ as pip_version major_version = int(pip_version.split('.')[0]) if major_version >= 20: from pip._internal.req import parse_requirements requirement_attr = 'requirement' elif 10 <= major_version < 20: from pip._internal.req import parse_requirements requirement_attr = 'req' else: from pip.req import parse_requirements requirement_attr = 'req' reqs_path = os.path.join(os.path.dirname(__file__), 'src/requirements.txt') # parse_requirements() returns generator of pip.req.InstallRequirement objects install_reqs = parse_requirements(reqs_path, session='hack') # reqs is a list of requirement # e.g. ['django==1.5.1', 'mezzanine==1.4.6'] reqs = [str(getattr(ir, requirement_attr)) for ir in install_reqs] setup( name='review-gator', version='0.2', install_requires=reqs,
import pprint import re from subprocess import PIPE, Popen import sys from pip import __version__ as pip_version from pip.download import PipSession from pip.req import parse_requirements setup_py_template = """ from setuptools import setup setup(**{0}) """ PY3 = sys.version_info[0] == 3 PIP_VERSION = tuple(map(int, pip_version.split("."))) PIP_PEP503_ENFORCED = PY3 and (PIP_VERSION >= (8, 1, 1)) def get_git_repo_dir(): """ Get the directory of the current git project Returns: str: The top level directory of the current git project """ repo_dir, err = Popen(['git', 'rev-parse', '--show-toplevel'], stdin=PIPE, stderr=PIPE, stdout=PIPE).communicate() repo_dir = repo_dir.strip()
import inspect import threading from functools import partial from apscheduler.schedulers.background import BackgroundScheduler from interruptingcow import timeout from pytz import utc from const import DEFAULT_COMMAND_TIMEOUT from exceptions import WorkerTimeoutError from workers_queue import _WORKERS_QUEUE import logger from pip import __version__ as pip_version if int(pip_version.split(".")[0]) >= 10: from pip._internal import main as pip_main else: from pip import main as pip_main _LOGGER = logger.get(__name__) class WorkersManager: class Command: def __init__(self, callback, timeout, args=(), options=dict()): self._callback = callback self._timeout = timeout self._args = args self._options = options self._source = "{}.{}".format(