def get_requirements(path): try: from pip.download import PipSession parsed_file = parse_requirements(path, session=PipSession()) except (ImportError, TypeError): parsed_file = parse_requirements(path) return [str(ir.req) for ir in parsed_file]
def downloaded_reqs_from_path(path, argv): """Return a list of DownloadedReqs representing the requirements parsed out of a given requirements file. :arg path: The path to the requirements file :arg argv: The commandline args, starting after the subcommand """ finder = package_finder(argv) def downloaded_reqs(parsed_reqs): """Just avoid repeating this list comp.""" return [DownloadedReq(req, argv, finder) for req in parsed_reqs] try: return downloaded_reqs(parse_requirements( path, options=EmptyOptions(), finder=finder)) except TypeError: # session is a required kwarg as of pip 6.0 and will raise # a TypeError if missing. It needs to be a PipSession instance, # but in older versions we can't import it from pip.download # (nor do we need it at all) so we only import it in this except block from pip.download import PipSession return downloaded_reqs(parse_requirements( path, options=EmptyOptions(), session=PipSession(), finder=finder))
def test_simple(self): prefix = 'prefix' version = 'version' source_dir = 'source dir' names = ['requirements.txt'] requirements = [ req.InstallRequirement.from_line('some-package>1'), req.InstallRequirement.from_line('other-package'), ] self.mox.StubOutWithMock(deps, 'get_requirement_filenames') deps.get_requirement_filenames( where=source_dir, only=None, group=prefix, version=version).AndReturn(names) self.mox.StubOutWithMock(req, 'parse_requirements') req.parse_requirements( 'requirements.txt', options=mox.IgnoreArg()).AndReturn(requirements) self.mox.StubOutWithMock(os.path, 'exists') os.path.exists('requirements.txt').AndReturn(True) self.mox.ReplayAll() reqs = deps.find_requirements(source_dir, group=prefix, version=version) self.mox.VerifyAll() self.assertEqual(['some-package>1', 'other-package'], reqs)
def get_requirements(filename): try: reqs = list(parse_requirements(filename)) except TypeError: reqs = list(parse_requirements(filename, session=uuid.uuid1())) return [str(r.req) for r in reqs]
def get_requirements(source): try: install_reqs = parse_requirements(source, session=uuid.uuid1()) except TypeError: # Older version of pip. install_reqs = parse_requirements(source) return set([str(ir.req) for ir in install_reqs])
def populate_requirement_set(requirement_set, args, options, finder, session, name, wheel_cache): """ Marshal cmd line args into a requirement set. """ for filename in options.constraints: for req in parse_requirements( filename, constraint=True, finder=finder, options=options, session=session, wheel_cache=wheel_cache): requirement_set.add_requirement(req) for req in args: requirement_set.add_requirement( InstallRequirement.from_line( req, None, isolated=options.isolated_mode, wheel_cache=wheel_cache ) ) for req in options.editables: requirement_set.add_requirement( InstallRequirement.from_editable( req, default_vcs=options.default_vcs, isolated=options.isolated_mode, wheel_cache=wheel_cache ) ) found_req_in_file = False for filename in options.requirements: for req in parse_requirements( filename, finder=finder, options=options, session=session, wheel_cache=wheel_cache): found_req_in_file = True requirement_set.add_requirement(req) # If --require-hashes was a line in a requirements file, tell # RequirementSet about it: requirement_set.require_hashes = options.require_hashes if not (args or options.editables or found_req_in_file): opts = {'name': name} if options.find_links: msg = ('You must give at least one requirement to ' '%(name)s (maybe you meant "pip %(name)s ' '%(links)s"?)' % dict(opts, links=' '.join(options.find_links))) else: msg = ('You must give at least one requirement ' 'to %(name)s (see "pip help %(name)s")' % opts) logger.warning(msg)
def _parse_requirements(path, finder): try: # list() so the generator that is parse_requirements() actually runs # far enough to report a TypeError return list(parse_requirements(path, options=EmptyOptions(), finder=finder)) except TypeError: # session is a required kwarg as of pip 6.0 and will raise # a TypeError if missing. It needs to be a PipSession instance, # but in older versions we can't import it from pip.download # (nor do we need it at all) so we only import it in this except block from pip.download import PipSession return list(parse_requirements(path, options=EmptyOptions(), session=PipSession(), finder=finder))
def parse_reqs(reqs_file): """ parse the requirements """ options = Option("--workaround") options.skip_requirements_regex = None # Hack for old pip versions: Versions greater than 1.x # have a required parameter "sessions" in parse_requierements if pip.__version__.startswith("1."): install_reqs = parse_requirements(reqs_file, options=options) else: from pip.download import PipSession # pylint:disable=E0611 options.isolated_mode = False install_reqs = parse_requirements(reqs_file, options=options, session=PipSession) # pylint:disable=E1123 return [str(ir.req) for ir in install_reqs]
def get_requirements(source): try: install_reqs = parse_requirements(source, session=uuid.uuid1()) except TypeError: # Older version of pip. install_reqs = parse_requirements(source) required = set([str(ir.req) for ir in install_reqs]) # Temp situation: transition from PIL to Pillow, add a hook so people can # skip installing Pillow. if os.path.exists('/tmp/PHOTOLOGUE_NO_PILLOW'): required = [item for item in required if not item.startswith('Pillow')] return required
def get_install_requirements(fname): ReqOpts = collections.namedtuple('ReqOpts', [ 'skip_requirements_regex', 'default_vcs', 'isolated_mode', ]) opts = ReqOpts(None, 'git', False) params = {'options': opts} requires = [] dependency_links = [] pip_version = StrictVersion(pip.__version__) session_support_since = StrictVersion('1.5.0') if pip_version >= session_support_since: from pip.download import PipSession session = PipSession() params.update({'session': session}) for ir in parse_requirements(fname, **params): if ir is not None: if ir.url is not None: dependency_links.append(str(ir.url)) if ir.req is not None: requires.append(str(ir.req)) return requires, dependency_links
def parse(self, reqs_filepath): ext_reqs, loc_reqs = [], [] for raw_req in parse_requirements(reqs_filepath, session=self.session): ext_subreqs, loc_subreqs = self._process_requirement(raw_req) ext_reqs.extend(ext_subreqs) loc_reqs.extend(loc_subreqs) return ext_reqs, loc_reqs
def load_pip_requirements(fp): reqs, deps = [], [] for r in parse_requirements(fp, session=PipSession()): if r.url is not None: deps.append(str(r.url)) reqs.append(str(r.req)) return reqs, deps
def get_requirements(): reqs = [] for filename in ["requirements-base.txt", "requirements-dashboard.txt", "requirements-setuptools.txt"]: # parse_requirements() returns generator of pip.req.InstallRequirement objects install_reqs = parse_requirements(filename) reqs += [str(ir.req) for ir in install_reqs] return reqs
def main(): with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as f: long_description = f.read() install_reqs = parse_requirements(os.path.join(os.path.dirname(__file__), 'requirements.txt')) setup( name='czchen-dl', version='0.0.0', author='ChangZhuo Chen (陳昌倬)', author_email='*****@*****.**', url='https://github.com/czchen/czchen-dl.git', description='czchen downloader', long_description=long_description, packages=[ 'czchendl' ], install_reqs=install_reqs, entry_points={ 'console_scripts': [ 'czchen-dl = czchendl.console:main', ], }, classifiers=[ 'Development Status :: 1 - Planning', 'Environment :: Console', 'License :: OST Approved :: MIT License', 'Operating System :: OS Independent', 'Programming Language :: Python :: 3 :: Only', 'Programming Language :: Python :: 3.4', ] )
def test_no_pip_freeze_mishaps(self): # See https://caremad.io/2013/07/setup-vs-requirement/ # We are trying to stop: # - 'pip freeze' leaking things we don't actually depend on into # requirements.txt (think pip-tools etc) # - Removing a dependency from requirements but not its own # dependencies - for example, if we removed django-redis we might # want to remove redis requirements = parse_requirements('requirements.txt', session=self.requests.Session()) packages_a = set(p.name for p in requirements) - self.ignore setup_py = pkg_resources.require('ten-self-service[test,docs]') packages_b = set(p.project_name for p in setup_py) - self.ignore # Separate assertions so that we can easily see whats wrong - checking # equality would work but wouldn't tell us what was wrong # Check for packages in setup.py but not requirements.txt # If you are adding a new dep, you might need to 'pip freeze' # If you are removing a dep, you forgot to remove it from setup.py self.assertEqual(packages_b - packages_a, set()) # Check for packages in requirements.txt but not setup.py # If you are adding a new dep, add the *direct dependency* to setup.py. # E.g. if you added django-redis to a project you would end up # adding django-redis to setup.py and django-redis and redis to # requirements.txt # If you are removing a dep, you forgot to remove it from requirements self.assertEqual(packages_a - packages_b, set())
def parse_requirements(requirements_files=None): """ Parses requirements files and returns a list of requirements. Returned list would be like:: ['foo', 'bar>=X.X', ...] :param requirements_files: List of requirements files. The default is ['requirements.txt', 'tools/pip-requires']. :return: List of requirements. """ requirements_files = requirements_files or [ 'requirements.txt', 'tools/pip-requires', ] requirements = [] for f in requirements_files: if not os.path.isfile(f): continue for r in pip_req.parse_requirements(f, session=PipSession()): requirements.append(str(r.req)) return requirements
def requirements(): """ :return: """ install_reqs = parse_requirements('requirements.txt') return [str(req.req) for req in install_reqs]
def handle_noargs(self, **options): if options["requirements"]: req_files = options["requirements"] elif os.path.exists("requirements.txt"): req_files = ["requirements.txt"] elif os.path.exists("requirements"): req_files = ["requirements/{0}".format(f) for f in os.listdir("requirements") if os.path.isfile(os.path.join("requirements", f)) and f.lower().endswith(".txt")] else: sys.exit("requirements not found") self.reqs = {} for filename in req_files: class Object(object): pass mockoptions = Object() mockoptions.default_vcs = "git" mockoptions.skip_requirements_regex = None for req in parse_requirements(filename, options=mockoptions): self.reqs[req.name] = { "pip_req": req, "url": req.url, } if options["github_api_token"]: self.github_api_token = options["github_api_token"] elif os.environ.get("GITHUB_API_TOKEN"): self.github_api_token = os.environ.get("GITHUB_API_TOKEN") else: self.github_api_token = None # only 50 requests per hour self.check_pypi() self.check_github() self.check_other()
def main(): python_version = sys.version_info if python_version < (2, 6): print ("This library requires Python version >=2.6, " "You have version %d.%d" % python_version[:2]) sys.exit(1) setup( name='pyhgvs', version='0.9.4', description='HGVS name parsing and formatting', long_description=description, author='Matt Rasmussen', author_email='*****@*****.**', packages=['pyhgvs', 'pyhgvs.tests'], include_package_data=True, package_data={ '': ['requirements-dev.txt'], }, scripts=[], install_requires=['pip>=1.2'], tests_require=[str(line.req) for line in parse_requirements('requirements-dev.txt', session=PipSession())], )
def parse_reqs(reqs_file): ''' parse the requirements ''' options = Option("--workaround") options.skip_requirements_regex = None options.isolated_mode = True install_reqs = parse_requirements(reqs_file, options=options, session=PipSession()) return [str(ir.req) for ir in install_reqs]
def get_install_requirements(): ReqOpts = collections.namedtuple( 'ReqOpts', ['skip_requirements_regex', 'default_vcs', 'isolated_mode'] ) opts = ReqOpts(None, 'git', False) requires = [] dependency_links = [] req_args = ['requirements.txt'] req_kwargs = {'options': opts} pip_version_info = _version_tuple(pip.__version__) if pip_version_info >= (6, 0): from pip.download import PipSession session = PipSession() req_kwargs['session'] = session for ir in parse_requirements(*req_args, **req_kwargs): if ir is not None: if pip_version_info >= (6, 0): if ir.link is not None: dependency_links.append(str(ir.url)) else: if ir.url is not None: dependency_links.append(str(ir.url)) if ir.req is not None: requires.append(str(ir.req)) return requires, dependency_links
def get_requires(rname='requirements.txt'): this_dir = os.path.realpath(os.path.dirname(__file__)) fname = os.path.join(this_dir, rname) reqs = parse_requirements(fname) res = [str(ir.req) for ir in reqs] return res
def run(self, options, args): with self._build_session(options) as session: format_control = pip.index.FormatControl(set(), set()) wheel_cache = WheelCache(options.cache_dir, format_control) requirement_set = RequirementSet( build_dir=None, src_dir=None, download_dir=None, isolated=options.isolated_mode, session=session, wheel_cache=wheel_cache, ) for name in args: requirement_set.add_requirement( InstallRequirement.from_line( name, isolated=options.isolated_mode, wheel_cache=wheel_cache ) ) for filename in options.requirements: for req in parse_requirements( filename, options=options, session=session, wheel_cache=wheel_cache): requirement_set.add_requirement(req) if not requirement_set.has_requirements: raise InstallationError( 'You must give at least one requirement to %(name)s (see ' '"pip help %(name)s")' % dict(name=self.name) ) requirement_set.uninstall(auto_confirm=options.yes)
def parse_file(self, file): """Parse single file.""" try: file_dir = os.path.dirname(file) if os.path.exists(file_dir): os.chdir(file_dir) try: if has_pipsession: return req.parse_requirements(file, options=self, finder=self, session=PipSession()) else: return req.parse_requirements(file, options=self, finder=self) finally: os.chdir(self.buildout['buildout']['directory']) except SystemExit: raise RuntimeError("Can't parse {0}".format(file))
def find_requirements(where=None, group=None, only=None, version=None): """Generates requirements based on given prefix and version. It works similar to find_packages function. It accepts where argument and yields install requiremnets. Note that this function will not search for requirement files recursively - it expects that all files are in the same directory. Args: where: a directory where requirement files resides group: a configuration prefix, like 'devel', ['prod', 'stage'] only: the same as group, but will ommit base requiremnets version: what version of python to use, current by default Returns: a list of requiremnets """ class FakeOptions(object): skip_requirements_regex = None default_vcs = '' reqs = [] for filename in get_requirement_filenames(where=where, group=group, only=only, version=version): if os.path.exists(filename): for install_req in req.parse_requirements(filename, options=FakeOptions()): reqs.append(str(install_req.req)) return reqs
def main(): args = parse_arguments() # show some output pip_log.logger.consumers.extend([(pip_log.logger.level_for_integer(3), sys.stdout)]) finder = index.PackageFinder([], [], use_mirrors=True) reqs = pip_req.parse_requirements(args.x_file, finder=finder, options=args) tmpdir = tempfile.mkdtemp(prefix='cheese') try: for d in ("build", "src"): os.mkdir(os.path.join(tmpdir, d)) req_set = pip_req.RequirementSet( build_dir=os.path.join(tmpdir, "build"), src_dir=os.path.join(tmpdir, "src"), download_dir=args.x_download) req_set.ignore_installed = True for req in reqs: req_set.add_requirement(req) req_set.prepare_files(finder) # exit if user only wanted the downloads if args.x_download: return # upload all packages for req in req_set.successfully_downloaded: build_dir = req.build_location(req_set.build_dir) upload_project(args.x_chishop, build_dir) finally: shutil.rmtree(tmpdir) pass
def build_wheels(command, wheelhouse, files): print command, wheelhouse, files if not os.path.isdir(wheelhouse): print('Wheelhouse %s not found.' % wheelhouse) return 0 for filename in files: if not os.path.isfile(filename): print('Requirements file not found: %s' % filename) return 1 for req in list(parse_requirements(filename, session=object())): reqname = req.name specs = req.req.specs if len(specs) != 1: print('Skipping wheel, multiple requirements for %s' % reqname) op, version = specs[0] if op != '==': print('Skipping wheel, non-exact requirement for %s' % reqname) pattern = os.path.join(wheelhouse, '%s-%s-*.whl' % (reqname, version)) found = glob(pattern) if found: print ('Skipping build, wheel already exists: %s' % found) continue os.system('%s %s==%s' % (command, reqname, version)) return 0
def run(self, options, args): super(UninstallCommand, self).run(options, args) if not options.remove_uninstalled: return with self._build_session(options) as session: requirement_set = RequirementSet( build_dir=None, src_dir=None, download_dir=None, isolated=options.isolated_mode, session=session, ) for name in args: requirement_set.add_requirement( InstallRequirement.from_line( name, isolated=options.isolated_mode ) ) for filename in options.requirements: for req in parse_requirements( filename, options=options, session=session): requirement_set.add_requirement(req) if not requirement_set.has_requirements: return here = os.getcwd() requirements_file = os.path.abspath(os.path.join(here, options.save_file)) requirements = self._parse_requirements(requirement_set.requirements.values()) self._update_requirements_file(requirements_file, remove_requirements=requirements, session=session)
def get_requirements(req_specs, requirement_files=None): """ Get set of requirements from pip-like input arguments Parameters ---------- req_specs : sequence sequence of requirement specifiers, maybe with versions requirement_files : None or sequence, optional sequence of filenames or URLs with requirements Returns ------- requirement_set : RequiremenSet instance Pip requirements set """ if requirement_files is None: requirement_files = [] session = PipSession() requirement_set = RequirementSet( build_dir=None, src_dir=None, download_dir=None, session=session, ) for name in req_specs: requirement_set.add_requirement( InstallRequirement.from_line(name)) for filename in requirement_files: for req in parse_requirements(filename, session=session): requirement_set.add_requirement(req) return requirement_set
def run_setup(): here = os.path.abspath(os.path.dirname(__file__)) README = open(os.path.join(here, 'Readme.md')).read() version = '0.1' install_reqs = parse_requirements(os.path.join(here, 'requirements.txt'), session=False) reqs = [str(ir.req) for ir in install_reqs] setup(name='sql_kernel', version=version, description="SQL Kernel for Jupyter", long_description=README, classifiers=[ 'Development Status :: 3 - Alpha', 'Environment :: Console', 'License :: OSI Approved :: MIT License', 'Topic :: Database', 'Topic :: Database :: Front-Ends', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 2', ], keywords='database jupyter sqlalchemy ipython dbms', author='Robin Aly', author_email='*****@*****.**', url='bitbucket.org/alyr/sql_kernel', license='MIT', packages=find_packages('src'), package_dir = {'': 'src'}, include_package_data=True, zip_safe=False, install_requires=reqs, )
import pip from setuptools import setup, find_packages from pip.req import parse_requirements import skeppa if sys.argv[-1] == "publish": os.system("python setup.py sdist upload") sys.exit() package_exclude = ("tests*", "examples*") packages = find_packages(exclude=package_exclude) # Handle requirements requires = parse_requirements("requirements/install.txt", session=pip.download.PipSession()) install_requires = [str(ir.req) for ir in requires] # requires = parse_requirements("requirements/tests.txt", # session=pip.download.PipSession()) # tests_require = [str(ir.req) for ir in requires] # Convert markdown to rst try: from pypandoc import convert long_description = convert("README.md", "rst") except: long_description = "" setup( name="skeppa",
'License :: OSI Approved :: MIT License', 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Topic :: Software Development :: Libraries :: Python Modules', ], keywords='irc bot helga', author='Shaun Duncan', author_email='*****@*****.**', url='https://github.com/shaunduncan/helga', license='MIT', packages=find_packages(), install_requires=[ str(req.req) for req in parse_requirements('requirements.txt') ], tests_require=[ 'freezegun', 'mock', 'pretend', 'tox', 'pytest', ], cmdclass={'test': PyTest}, entry_points=dict( helga_plugins=[ 'dubstep = helga.plugins.dubstep:dubstep', 'facts = helga.plugins.facts:facts', 'giphy = helga.plugins.giphy:giphy', 'help = helga.plugins.help:help',
from setuptools import setup, find_packages from pip.req import parse_requirements import uuid # parse_requirements() returns generator of pip.req.InstallRequirement objects install_reqs = parse_requirements('requirements.txt', session=uuid.uuid1()) # reqs is a list of requirement # e.g. ['django==1.5.1', 'mezzanine==1.4.6'] reqs = [str(ir.req) for ir in install_reqs] version = '1.0' setup( name='routerGen', version=version, py_modules=[''], packages=find_packages(), install_requires=reqs, include_package_data=True, description = 'generate cisco configs for your lab', author = 'Francesco Marangione', author_email = '*****@*****.**', url = 'https://github.com/mft3000/routerGen', # use the URL to the github repo download_url = 'https://github.com/mft3000/routerGen/tarball/%s' % version, keywords = ['lab', 'Cisco', 'networking'], classifiers = [], )
from setuptools import setup from pip.req import parse_requirements import sys, os sys.path.append("wutu/") sys.path.append("wutu/compiler/") install_reqs = list(parse_requirements("requirements.txt", session={})) def version(): import version return version.get_version() setup(name="wutu", version=version(), description="A minimalistic python-angular framework", author="Šarūnas Navickas", author_email="*****@*****.**", url="https://github.com/zaibacu/wutu", license="MIT", packages=["wutu", "wutu.compiler"], install_requires=[str(ir.req) for ir in install_reqs], test_suite="nose.collector", tests_require=["nose"])
def get_requirements(): install_reqs = parse_requirements('requirements.txt', session='tf-layers') return [str(ir.req) for ir in install_reqs]
# -*- coding: utf-8 -*- from setuptools import setup, find_packages from pip.req import parse_requirements import re, ast # get version from __version__ variable in transport_management_system/__init__.py _version_re = re.compile(r'__version__\s+=\s+(.*)') with open('transport_management_system/__init__.py', 'rb') as f: version = str( ast.literal_eval( _version_re.search(f.read().decode('utf-8')).group(1))) requirements = parse_requirements("requirements.txt", session="") setup(name='transport_management_system', version=version, description='Provide transportation solution for your business need.', author='Vishal Dhayagude', author_email='*****@*****.**', packages=find_packages(), zip_safe=False, include_package_data=True, install_requires=[str(ir.req) for ir in requirements], dependency_links=[str(ir._link) for ir in requirements if ir._link])
import os from setuptools import setup, find_packages from pip.req import parse_requirements from pip.download import PipSession install_reqs = parse_requirements("requirements.txt", session=PipSession()) reqs = [str(ir.req) for ir in install_reqs] setup(name="gpspy3", version="0.1.0", packages=find_packages(), author="", author_email="", description=(""), license="", keywords="", url="", install_requires=reqs)
with open("VERSION.txt", "r") as f: version = f.read().strip() """ 作为一个合格的模块,应该要有版本号哦。 """ setup( name='scrapy_suger', # 模块名称 version=version, # 安装框架后的版本号 description='A mini spider framework, like Scrapy', # 描述 packages=find_packages(exclude=[]), # 不排除任何文件 author='amourbrus', author_email='*****@*****.**', license='Apache License v2', # 遵循的Linux软件发行协议 package_data={'': ['*.*']}, # 获取任意文件名任意后缀的文件 url='#', install_requires=[ str(ir.req) for ir in parse_requirements("requirements.txt", session=False) ], #所需的运行环境,读取requirements文件,自动安装运行环境 zip_safe=False, # 表示在Windows中可以正常卸载 classifiers=[ 'Programming Language :: Python', 'Operating System :: Microsoft :: Windows', 'Operating System :: Unix', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', ], )
def cli(verbose, dry_run, pre, rebuild, find_links, index_url, extra_index_url, client_cert, trusted_host, header, index, emit_trusted_host, annotate, upgrade, upgrade_packages, output_file, allow_unsafe, generate_hashes, src_files, max_rounds): """Compiles requirements.txt from requirements.in specs.""" log.verbose = verbose if len(src_files) == 0: if os.path.exists(DEFAULT_REQUIREMENTS_FILE): src_files = (DEFAULT_REQUIREMENTS_FILE, ) elif os.path.exists('setup.py'): src_files = ('setup.py', ) if not output_file: output_file = 'requirements.txt' else: raise click.BadParameter(("If you do not specify an input file, " "the default is {} or setup.py" ).format(DEFAULT_REQUIREMENTS_FILE)) if len(src_files) == 1 and src_files[0] == '-': if not output_file: raise click.BadParameter( '--output-file is required if input is from stdin') if len(src_files) > 1 and not output_file: raise click.BadParameter( '--output-file is required if two or more input files are given.') if output_file: dst_file = output_file else: base_name = src_files[0].rsplit('.', 1)[0] dst_file = base_name + '.txt' if upgrade and upgrade_packages: raise click.BadParameter( 'Only one of --upgrade or --upgrade-package can be provided as an argument.' ) ### # Setup ### pip_command = get_pip_command() pip_args = [] if find_links: for link in find_links: pip_args.extend(['-f', link]) if index_url: pip_args.extend(['-i', index_url]) if extra_index_url: for extra_index in extra_index_url: pip_args.extend(['--extra-index-url', extra_index]) if client_cert: pip_args.extend(['--client-cert', client_cert]) if pre: pip_args.extend(['--pre']) if trusted_host: for host in trusted_host: pip_args.extend(['--trusted-host', host]) pip_options, _ = pip_command.parse_args(pip_args) session = pip_command._build_session(pip_options) repository = PyPIRepository(pip_options, session) # Pre-parse the inline package upgrade specs: they should take precedence # over the stuff in the requirements files upgrade_packages = [ InstallRequirement.from_line(pkg) for pkg in upgrade_packages ] # Proxy with a LocalRequirementsRepository if --upgrade is not specified # (= default invocation) if not (upgrade or upgrade_packages) and os.path.exists(dst_file): ireqs = parse_requirements(dst_file, finder=repository.finder, session=repository.session, options=pip_options) existing_pins = { key_from_req(ireq.req): ireq for ireq in ireqs if is_pinned_requirement(ireq) } repository = LocalRequirementsRepository(existing_pins, repository) log.debug('Using indexes:') # remove duplicate index urls before processing repository.finder.index_urls = list(dedup(repository.finder.index_urls)) for index_url in repository.finder.index_urls: log.debug(' {}'.format(index_url)) if repository.finder.find_links: log.debug('') log.debug('Configuration:') for find_link in repository.finder.find_links: log.debug(' -f {}'.format(find_link)) ### # Parsing/collecting initial requirements ### constraints = [] for src_file in src_files: is_setup_file = os.path.basename(src_file) == 'setup.py' if is_setup_file or src_file == '-': # pip requires filenames and not files. Since we want to support # piping from stdin, we need to briefly save the input from stdin # to a temporary file and have pip read that. also used for # reading requirements from install_requires in setup.py. tmpfile = tempfile.NamedTemporaryFile(mode='wt', delete=False) if is_setup_file: from distutils.core import run_setup dist = run_setup(src_file) tmpfile.write('\n'.join(dist.install_requires)) else: tmpfile.write(sys.stdin.read()) tmpfile.flush() constraints.extend( parse_requirements(tmpfile.name, finder=repository.finder, session=repository.session, options=pip_options)) else: constraints.extend( parse_requirements(src_file, finder=repository.finder, session=repository.session, options=pip_options)) # Check the given base set of constraints first Resolver.check_constraints(constraints) try: resolver = Resolver(constraints, repository, prereleases=pre, clear_caches=rebuild, allow_unsafe=allow_unsafe) results = resolver.resolve(max_rounds=max_rounds) if generate_hashes: hashes = resolver.resolve_hashes(results) else: hashes = None except PipToolsError as e: log.error(str(e)) sys.exit(2) log.debug('') ## # Output ## # Compute reverse dependency annotations statically, from the # dependency cache that the resolver has populated by now. # # TODO (1a): reverse deps for any editable package are lost # what SHOULD happen is that they are cached in memory, just # not persisted to disk! # # TODO (1b): perhaps it's easiest if the dependency cache has an API # that could take InstallRequirements directly, like: # # cache.set(ireq, ...) # # then, when ireq is editable, it would store in # # editables[egg_name][link_without_fragment] = deps # editables['pip-tools']['git+...ols.git@future'] = {'click>=3.0', 'six'} # # otherwise: # # self[as_name_version_tuple(ireq)] = {'click>=3.0', 'six'} # reverse_dependencies = None if annotate: reverse_dependencies = resolver.reverse_dependencies(results) writer = OutputWriter(src_files, dst_file, dry_run=dry_run, emit_header=header, emit_index=index, emit_trusted_host=emit_trusted_host, annotate=annotate, generate_hashes=generate_hashes, default_index_url=repository.DEFAULT_INDEX_URL, index_urls=repository.finder.index_urls, trusted_hosts=pip_options.trusted_hosts, format_control=repository.finder.format_control) writer.write(results=results, reverse_dependencies=reverse_dependencies, primary_packages={ key_from_req(ireq.req) for ireq in constraints if not ireq.constraint }, markers={ key_from_req(ireq.req): ireq.markers for ireq in constraints if ireq.markers }, hashes=hashes) if dry_run: log.warning('Dry-run, so nothing updated.')
import pip.download from pip.req import parse_requirements from setuptools import setup setup(name='ansible-toolkit', version='1.3.2', description='The missing Ansible tools', url='http://github.com/dellis23/ansible-toolkit', author='Daniel Ellis', author_email='*****@*****.**', license='GPLv3', install_requires=[ str(pkg.req) for pkg in parse_requirements('requirements.txt', session=pip.download.PipSession()) ], tests_require=[ str(pkg.req) for pkg in parse_requirements('test-requirements.txt', session=pip.download.PipSession()) ], packages=['ansible_toolkit'], scripts=[ 'bin/atk-git-diff', 'bin/atk-show-vars', 'bin/atk-show-template', 'bin/atk-vault', ])
#!/usr/bin/env python from setuptools import setup from pip.req import parse_requirements import os package_root = os.path.abspath(os.path.dirname(__file__)) requirements_txt = os.path.join(package_root, 'requirements.txt') requires = [ str(r.req) for r in parse_requirements(requirements_txt, session=False) ] setup( name='linebot', version='0.3.2', packages=['linebot'], install_requires=requires, author='Satoshi SUZUKI', author_email='*****@*****.**', description=('A client library for LINE BOT'), license='MIT', url='https://github.com/studio3104/line-bot-sdk-python', )
#!/usr/bin/env python from setuptools import setup from pip.req import parse_requirements install_reqs = parse_requirements("requirements.txt", session=False) reqs = [str(ir.req) for ir in install_reqs] classifiers = [ 'Development Status :: 2 - Pre-Alpha', 'Environment :: Console', 'Operating System :: OS Independent', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 3', 'Topic :: Communications :: Chat' ] setup( name='groupmebot', version='0.0.2', packages=['groupmebot'], url='https://github.com/clayscode/GroupMeBot', author='', author_email='', install_requires=reqs, classifiers=classifiers, description="Interactive client for GroupMe messaging system", keywords='groupme messaging client console interactive', entry_points={'console_scripts': ['groupmebot=groupmebot.__main__:main']})
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF # # THE POSSIBILITY OF SUCH DAMAGE. # # ----------------------------------------------------------------------------# import os import pip import sys from pip.req import parse_requirements from setuptools import setup, find_packages requirements = [str(requirement.req) for requirement in parse_requirements( 'requirements.txt', session=pip.download.PipSession())] # Python Version check if not sys.version_info[0] == 2: sys.exit('Python 3 is not supported') # Python 2.7.9 sub-version check if sys.version_info[1] <= 7 and sys.version_info[2] < 9: sys.exit('Python 2.7.9+ versions are only supported') # Get the long description from the README file with open('README.md') as f: long_description = f.read() setup( name='liota',
import os import uuid from setuptools import setup, find_packages try: from pip.req import parse_requirements except ImportError: raise ImportError('You should install pip') REQUIREMENTS = [ str(ir.req) for ir in parse_requirements(os.path.join( os.path.dirname(__file__), 'requirements.txt'), session=uuid.uuid1()) ] setup(name='chineseMarkov', version='0.1.3', description='Chinese Sentence Generator', long_description=open('README.md').read(), author='Kimice', author_email='*****@*****.**', url='https://github.com/Kimice/ChineseMarkov', license='GPLv3', packages=find_packages(exclude=[ 'test', ]), install_requires=REQUIREMENTS)
def check_dependencies(): """Check installed requirements vs. specified requirements This prints out a list of dependencies where the version installed is not the same as the one specified in the requirements files. It also exits immediately. At some point we might want to change it from doing that, but not today. If you want to skip this check, set SKIP_CHECK=1 in your environment. .. Note:: This only works for packaged requirements. It does not work for requirements downloaded in a tarball from github. Those requirements get put in the "unsatisfyable" requirements list and this will tell you how many there are. Generally we should minimize those requirements as much as possible. """ # Import this here because not all environments have pip. from pip.req import parse_requirements from pip.download import PipSession req_path = path('requirements') req_files = [os.path.join(req_path, fn) for fn in os.listdir(req_path)] reqs = list( chain(*(parse_requirements( path, options=EmptyOptions(), session=PipSession()) for path in req_files))) unsatisfied_reqs = [] unsatisfyable_reqs = [] for req in reqs: if req.url and 'github.com' in req.url: unsatisfyable_reqs.append(req) continue req.check_if_exists() if not req.satisfied_by: unsatisfied_reqs.append(req) if unsatisfyable_reqs: print 'There are %d requirements that cannot be checked.' % ( len(unsatisfyable_reqs)) if unsatisfied_reqs: print 'The following requirements are not satsifed:' print '' for req in unsatisfied_reqs: print 'UNSATISFIED:', req.req print '' print 'Update your virtual environment by doing:' print '' print ' ./peep.sh install -r requirements/requirements.txt' print '' print 'or run with SKIP_CHECK=1 .' sys.exit(1)
def get_requirements(cls, file='requirements.txt'): from pip.req import parse_requirements return list(parse_requirements(file))
here = os.path.abspath(os.path.dirname(__file__)) try: with open(os.path.join(here, '../README.md')) as f: README = f.read() with open(os.path.join(here, '../CHANGES.md')) as f: CHANGES = f.read() except: README = '' CHANGES = '' reqs = './requirements.txt' if len(sys.argv) > 1 and sys.argv[1] in ['develop', 'test']: reqs = './requirements-dev.txt' install_reqs = parse_requirements(os.path.join(here, reqs)) setup( name='ebs-snapshots', version=version.VERSION, description='Automates creation and removal of Amazon EBS snapshots', author='Clever', author_email='*****@*****.**', url='https://github.com/Clever/ebs-snapshots/', long_description=README + '\n\n' + CHANGES, packages=find_packages(exclude=['*.tests']), install_requires=[str(ir.req) for ir in install_reqs], setup_requires=['nose>=1.0'], test_suite='test', )
import os from pip.req import parse_requirements from setuptools import setup, find_packages from cert_issuer import __version__ here = os.path.abspath(os.path.dirname(__file__)) install_reqs = parse_requirements('requirements.txt', session=False) reqs = [str(ir.req) for ir in install_reqs] with open(os.path.join(here, 'README.md')) as fp: long_description = fp.read() setup( name='cert-issuer', version=__version__, url='https://github.com/blockchain-certificates/cert-issuer', license='MIT', author='Blockcerts', author_email='*****@*****.**', description='Issues blockchain certificates using the Bitcoin blockchain', long_description=long_description, packages=find_packages(), include_package_data=True, install_requires=reqs, entry_points={ 'console_scripts': [ 'cert-issuer = cert_issuer.__main__:cert_issuer_main', ] })
from setuptools import setup from pip.req import parse_requirements # pip requirements parsing code taken from http://stackoverflow.com/a/16624700 # parse_requirements() returns generator of pip.req.InstallRequirement objects install_reqs = parse_requirements('requirements.txt') # reqs is a list of requirement # e.g. ['django==1.5.1', 'mezzanine==1.4.6'] reqs = [str(ir.req) for ir in install_reqs] setup(name='finder', version='0.1dev', long_description=open('README.md').read(), install_requires=reqs)
from setuptools import setup import sys import os from pip.req import parse_requirements PACKAGE_DIR = {'': 'machmail'} README = open("README.md").read() LICENSE = open("LICENSE").read() AUTHOR_EMAIL = '*****@*****.**' REQ = os.path.dirname(os.path.realpath(__file__)) + "/requirements.txt" install_reqs = parse_requirements(REQ, session=False) # reqs is a list of requirement # e.g. ['django==1.5.1', 'mezzanine==1.4.6'] reqs = [str(ir.req) for ir in install_reqs] def get_version(dir, package_name): """Get version string from package in non-module sub-dir. """ path = './{}'.format(dir) sys.path.insert(0, path) version = __import__(package_name).__version__ return version # setup function setup( name='machmail', # package metadata
def parse_reqs(filename): """Parse setup requirements from a requirements.txt file.""" install_reqs = parse_requirements(filename, session=False) return [str(ir.req) for ir in install_reqs]
from setuptools import setup, find_packages from setuptools.command.test import test as TestCommand import sys import uuid from jirafs import __version__ as version_string requirements_path = os.path.join( os.path.dirname(__file__), 'requirements.txt', ) try: from pip.req import parse_requirements requirements = [ str(req.req) for req in parse_requirements(requirements_path, session=uuid.uuid1()) ] except ImportError: requirements = [] with open(requirements_path, 'r') as in_: requirements = [ req for req in in_.readlines() if not req.startswith('-') and not req.startswith('#') ] class Tox(TestCommand): def finalize_options(self): TestCommand.finalize_options(self) self.test_args = [] self.test_suite = True
#!/usr/bin/env python3.7 import os from setuptools import setup, find_packages from pip.req import parse_requirements setup_dir = os.path.dirname(os.path.realpath(__file__)) path_req = os.path.join(setup_dir, 'requirements.txt') install_reqs = parse_requirements(path_req, session=False) reqs = [str(ir.req) for ir in install_reqs] setup(name='MrMime', author='sLoPPydrive', description='Pokemon GO client library mimicing the original app', version='0.9.0', url='https://github.com/SenorKarlos/MrMime', download_url="https://github.com/SenorKarlos/MrMime/releases", packages=find_packages(), install_requires=reqs)
# See the License for the specific language governing permissions and # limitations under the License. from pip.download import PipSession from pip.req import parse_requirements from setuptools import setup, find_packages from os import path here = path.abspath(path.dirname(__file__)) with open(path.join(here, 'README.rst')) as f: readme = f.read() requirements = [ str(ir.req) for ir in parse_requirements('requirements.txt', session=PipSession()) ] test_requirements = [ str(ir.req) for ir in parse_requirements('requirements_test.txt', session=PipSession()) ] setup(name='deeptracy_core', version='0.0.34', author='BBVA', url="https://github.com/BBVA/deeptracy-core", description='Deeptracy Dependency Checker', long_description=readme, packages=find_packages(), keywords='deeptracy core',
#!/usr/bin/env python import json import sys from pip.req import parse_requirements from pip.download import PipSession from pip._vendor import pkg_resources from pip._vendor.six import print_ requirements = [pkg_resources.Requirement.parse(str(req.req)) for req in parse_requirements(sys.argv[1], session=PipSession()) if req.req != None] transform = lambda dist: { 'name': dist.project_name, 'version': dist.version, 'location': dist.location, 'dependencies': list(map(lambda dependency: dependency.project_name, dist.requires())), } packages = [transform(dist) for dist in pkg_resources.working_set.resolve(requirements)] print_(json.dumps(packages))
try: from setuptools import setup, Command except ImportError: from distutils.core import setup import sys import uuid from pip.req import parse_requirements ldclient_version = '5.0.3' # parse_requirements() returns generator of pip.req.InstallRequirement objects install_reqs = parse_requirements('requirements.txt', session=uuid.uuid1()) python26_reqs = parse_requirements('python2.6-requirements.txt', session=uuid.uuid1()) test_reqs = parse_requirements('test-requirements.txt', session=uuid.uuid1()) redis_reqs = parse_requirements('redis-requirements.txt', session=uuid.uuid1()) # reqs is a list of requirement # e.g. ['django==1.5.1', 'mezzanine==1.4.6'] reqs = [str(ir.req) for ir in install_reqs] python26reqs = [str(ir.req) for ir in python26_reqs] testreqs = [str(ir.req) for ir in test_reqs] redisreqs = [str(ir.req) for ir in redis_reqs] class PyTest(Command): user_options = [] def initialize_options(self):
# Precise has an old version of pip that lacks PipSession. PipSession = None from pip.req import parse_requirements from setuptools import setup, find_packages if PipSession is not None: pip_session = PipSession() kwargs = dict(session=pip_session) else: # The parse_requirements in the precise version of pip is broken # and requires options.skip_requirements_regex to be present. from collections import namedtuple options = namedtuple('Options', 'skip_requirements_regex') kwargs = dict(options=options(skip_requirements_regex=None)) requirements = parse_requirements("requirements.txt", **kwargs) test_requirements = parse_requirements("test-requirements.txt", **kwargs) install_requires = [str(req.req) for req in requirements] tests_require = [str(req.req) for req in test_requirements] setup( name='jujugui', version='2.0.3', description='jujugui', classifiers=[ "Programming Language :: Python", "Framework :: Pyramid", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", ], author='Juju UI Engineering Team',
#!/usr/bin/env python from pip.req import parse_requirements from setuptools import setup, find_packages install_reqs = parse_requirements('requirements.txt', session='hack') setup(name='trf', version='0.1', description='A tool to calculate text readability features', author='Akihiko Watanabe, Soichiro Murakami, and Akira Miyazawa', author_email='{watanabe, murakami}@lr.pi.titech.ac.jp, [email protected]', url='https://github.com/aistairc/trf', packages=find_packages("trf"), install_requires=install_reqs) # package_data={'', ['']},
from distutils.core import setup from setuptools import find_packages from pip.req import parse_requirements PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'README.rst')) as readme: README = readme.read() # allow setup.py to be run from any path os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) # parse_requirements() returns generator of pip.req.InstallRequirement objects install_requirements = parse_requirements(os.path.join(PROJECT_ROOT, 'requirements.txt'), session=uuid.uuid1()) # e.g. ['django', 'google-api-python-client'] requirements = [str(ir.req) for ir in install_requirements] setup( name='django-autotranslate', version='1.0.1', packages=find_packages(), install_requires=requirements, include_package_data=True, license='MIT License', description='A simple Django app to automatically translate the pot (`.po`) files generated by django\'s ' 'makemessages command using google translate.', long_description=README, url='https://github.com/ankitpopli1891/django-autotranslate/',
from pip.req import parse_requirements from pip.download import PipSession setup( name='vprof', version='0.2', packages=['vprof'], description="Visual profiler for Python", url='http://github.com/nvdv/vprof', license='BSD', author='nvdv', include_package_data=True, keywords=['debugging', 'profiling'], entry_points={'console_scripts': ['vprof = vprof.__main__:main']}, classifiers=[ 'Development Status :: 3 - Alpha', 'Environment :: Web Environment', 'Intended Audience :: Developers', 'Programming Language :: Python', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.5', 'Topic :: Software Development', ], install_requires=[ str(req.req) for req in parse_requirements('requirements.txt', session=PipSession()) ], )