Python setuptools.setup() Examples
The following are 30
code examples of setuptools.setup().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
setuptools
, or try the search function
.
Example #1
Source File: pundle.py From pundler with BSD 2-Clause "Simplified" License | 7 votes |
def get_info_from_setup(path): """Mock setuptools.setup(**kargs) to get package information about requirements and extras """ preserve = {} def _save_info(**setup_args): preserve['args'] = setup_args import setuptools original_setup = setuptools.setup setuptools.setup = _save_info import runpy runpy.run_path(os.path.join(path, 'setup.py'), run_name='__main__') setuptools.setup = original_setup return preserve.get('args')
Example #2
Source File: test_easy_install.py From oss-ftp with MIT License | 6 votes |
def setUp(self): self.dir = tempfile.mkdtemp() setup = os.path.join(self.dir, 'setup.py') f = open(setup, 'w') f.write(SETUP_PY) f.close() self.old_cwd = os.getcwd() os.chdir(self.dir) self.old_enable_site = site.ENABLE_USER_SITE self.old_file = easy_install_pkg.__file__ self.old_base = site.USER_BASE site.USER_BASE = tempfile.mkdtemp() self.old_site = site.USER_SITE site.USER_SITE = tempfile.mkdtemp() easy_install_pkg.__file__ = site.USER_SITE
Example #3
Source File: projectdata.py From pyroma with MIT License | 6 votes |
def __enter__(self): import distutils.core self._distutils_setup = distutils.core.setup distutils.core.setup = self.distutils_setup_replacement try: import setuptools self._setuptools_setup = setuptools.setup setuptools.setup = self.setuptools_setup_replacement except ImportError: self._setuptools_setup = None self._kw = {} return self
Example #4
Source File: test_z_cmdline.py From tox with MIT License | 6 votes |
def test_sdist_fails(cmd, initproj): initproj( "pkg123-0.7", filedefs={ "tests": {"test_hello.py": "def test_hello(): pass"}, "setup.py": """ syntax error """, "tox.ini": "", }, ) result = cmd() result.assert_fail() assert any( re.match(r".*FAIL.*could not package project.*", line) for line in result.outlines ), result.outlines
Example #5
Source File: test_z_cmdline.py From tox with MIT License | 6 votes |
def test_no_setup_py_exits(cmd, initproj): initproj( "pkg123-0.7", filedefs={ "tox.ini": """ [testenv] commands=python -c "2 + 2" """, }, ) os.remove("setup.py") result = cmd() result.assert_fail() assert any( re.match(r".*ERROR.*No pyproject.toml or setup.py file found.*", line) for line in result.outlines ), result.outlines
Example #6
Source File: test_z_cmdline.py From tox with MIT License | 6 votes |
def test_no_setup_py_exits_but_pyproject_toml_does(cmd, initproj): initproj( "pkg123-0.7", filedefs={ "tox.ini": """ [testenv] commands=python -c "2 + 2" """, }, ) os.remove("setup.py") pathlib2.Path("pyproject.toml").touch() result = cmd() result.assert_fail() assert any( re.match(r".*ERROR.*pyproject.toml file found.*", line) for line in result.outlines ), result.outlines assert any( re.match(r".*To use a PEP 517 build-backend you are required to*", line) for line in result.outlines ), result.outlines
Example #7
Source File: test_z_cmdline.py From tox with MIT License | 6 votes |
def test_package_install_fails(cmd, initproj): initproj( "pkg123-0.7", filedefs={ "tests": {"test_hello.py": "def test_hello(): pass"}, "setup.py": """ from setuptools import setup setup( name='pkg123', description='pkg123 project', version='0.7', license='MIT', platforms=['unix', 'win32'], packages=['pkg123',], install_requires=['qweqwe123'], ) """, "tox.ini": "", }, ) result = cmd() result.assert_fail() assert result.outlines[-1].startswith("ERROR: python: InvocationError for command ")
Example #8
Source File: test_z_cmdline.py From tox with MIT License | 6 votes |
def test_skip_unknown_interpreter_result_json(cmd, initproj, tmpdir): report_path = tmpdir.join("toxresult.json") initproj( "interp123-0.5", filedefs={ "tests": {"test_hello.py": "def test_hello(): pass"}, "tox.ini": """ [testenv:python] basepython=xyz_unknown_interpreter [testenv] changedir=tests """, }, ) result = cmd("--skip-missing-interpreters", "--result-json", report_path) result.assert_success() msg = "SKIPPED: python: InterpreterNotFound: xyz_unknown_interpreter" assert any(msg == line for line in result.outlines), result.outlines setup_result_from_json = json.load(report_path)["testenvs"]["python"]["setup"] for setup_step in setup_result_from_json: assert "InterpreterNotFound" in setup_step["output"] assert setup_step["retcode"] == 0
Example #9
Source File: test_z_cmdline.py From tox with MIT License | 6 votes |
def test_devenv(initproj, cmd): initproj( "example123", filedefs={ "setup.py": """\ from setuptools import setup setup(name='x') """, "tox.ini": """\ [tox] # envlist is ignored for --devenv envlist = foo,bar,baz [testenv] # --devenv implies --notest commands = python -c "exit(1)" """, }, ) result = cmd("--devenv", "venv") result.assert_success() # `--devenv` defaults to the `py` environment and a develop install assert "py develop-inst:" in result.out assert re.search("py create:.*venv", result.out)
Example #10
Source File: test_z_cmdline.py From tox with MIT License | 6 votes |
def test_devenv_does_not_allow_multiple_environments(initproj, cmd): initproj( "example123", filedefs={ "setup.py": """\ from setuptools import setup setup(name='x') """, "tox.ini": """\ [tox] envlist=foo,bar,baz """, }, ) result = cmd("--devenv", "venv", "-e", "foo,bar") result.assert_fail() assert result.err == "ERROR: --devenv requires only a single -e\n"
Example #11
Source File: test_z_cmdline.py From tox with MIT License | 6 votes |
def test_devenv_does_not_delete_project(initproj, cmd): initproj( "example123", filedefs={ "setup.py": """\ from setuptools import setup setup(name='x') """, "tox.ini": """\ [tox] envlist=foo,bar,baz """, }, ) result = cmd("--devenv", "") result.assert_fail() assert "would delete project" in result.out assert "ERROR: ConfigError: envdir must not equal toxinidir" in result.out
Example #12
Source File: test_z_cmdline.py From tox with MIT License | 6 votes |
def test_setup_prints_non_ascii(initproj, cmd): initproj( "example123", filedefs={ "setup.py": """\ import sys getattr(sys.stdout, 'buffer', sys.stdout).write(b'\\xe2\\x98\\x83\\n') import setuptools setuptools.setup(name='example123') """, "tox.ini": "", }, ) result = cmd("--notest") result.assert_success() assert "create" in result.out
Example #13
Source File: test_easy_install.py From pledgeservice with Apache License 2.0 | 6 votes |
def setUp(self): self.dir = tempfile.mkdtemp() setup = os.path.join(self.dir, 'setup.py') f = open(setup, 'w') f.write(SETUP_PY) f.close() self.old_cwd = os.getcwd() os.chdir(self.dir) self.old_enable_site = site.ENABLE_USER_SITE self.old_file = easy_install_pkg.__file__ self.old_base = site.USER_BASE site.USER_BASE = tempfile.mkdtemp() self.old_site = site.USER_SITE site.USER_SITE = tempfile.mkdtemp() easy_install_pkg.__file__ = site.USER_SITE
Example #14
Source File: test_packaging.py From shopify_python with MIT License | 6 votes |
def package_source_root(tmpdir): # type: ('py.path.LocalPath') -> 'py.path.LocalPath' root = tmpdir.join('test_packaging') root.join('setup.py').write(""" import setuptools setuptools.setup( name='test_packaging', install_requires=[ 'shopify_python' ], entry_points={ 'egg_info.writers': [ 'git_sha.txt = shopify_python.packaging:write_package_revision', ], } ) """, ensure=True) return root
Example #15
Source File: pundle.py From pundler with BSD 2-Clause "Simplified" License | 6 votes |
def parse_requirements(self): setup_info = get_info_from_setup(self.package) if setup_info is None: raise PundleException('There is no requirements.txt nor setup.py') install_requires = setup_info.get('install_requires') or [] reqs = [ CustomReq(str(req), '', source='setup.py') for req in install_requires ] requirements = dict((req.key, req) for req in reqs) # we use `feature` as environment for pundle extras_require = (setup_info.get('extras_require') or {}) for feature, feature_requires in extras_require.items(): for req_line in feature_requires: req = CustomReq(req_line, feature, source='setup.py') # if this req already in dict, then add our feature as env if req.key in requirements: requirements[req.key].add_env(feature) else: requirements[req.key] = req self.package_envs.add(feature) return requirements
Example #16
Source File: setup.py From mobly with Apache License 2.0 | 6 votes |
def main(): setuptools.setup( name='mobly', version='1.10', maintainer='Ang Li', maintainer_email='mobly-github@googlegroups.com', description='Automation framework for special end-to-end test cases', license='Apache2.0', url='https://github.com/google/mobly', download_url='https://github.com/google/mobly/tarball/1.10', packages=setuptools.find_packages(exclude=['tests']), include_package_data=False, scripts=['tools/sl4a_shell.py', 'tools/snippet_shell.py'], tests_require=[ 'mock', # Needed for supporting Python 2 because this release stopped supporting Python 2. 'pytest<5.0.0', 'pytz', ], install_requires=install_requires, cmdclass={'test': PyTest}, )
Example #17
Source File: test_integration.py From auto-alt-text-lambda-api with MIT License | 6 votes |
def all_projects(): if not REPODIR: return # Future: make this path parameterisable. excludes = set(['tempest', 'requirements']) for name in PROJECTS: name = name.strip() short_name = name.split('/')[-1] try: with open(os.path.join( REPODIR, short_name, 'setup.py'), 'rt') as f: if 'pbr' not in f.read(): continue except IOError: continue if short_name in excludes: continue yield (short_name, dict(name=name, short_name=short_name))
Example #18
Source File: make_default_setup.py From setuptools-odoo with GNU Lesser General Public License v3.0 | 6 votes |
def check_setup_dir_is_git_clean(addons_dir): cmd = ["git", "diff", "--quiet", "--exit-code", "--", "setup"] if subprocess.call(cmd, cwd=addons_dir) != 0: return False cmd = ["git", "diff", "--quiet", "--exit-code", "--cached", "--", "setup"] if subprocess.call(cmd, cwd=addons_dir) != 0: return False cmd = [ "git", "ls-files", "--other", "--exclude-standard", "--directory", "--", "setup", ] out = subprocess.check_output(cmd, cwd=addons_dir) if out: return False return True
Example #19
Source File: make_default_setup.py From setuptools-odoo with GNU Lesser General Public License v3.0 | 6 votes |
def make_default_setup_addons_dir(addons_dir, force, odoo_version_override): addons_setup_dir = os.path.join(addons_dir, "setup") if not os.path.exists(addons_setup_dir): os.mkdir(addons_setup_dir) readme_path = os.path.join(addons_setup_dir, "README") if not os.path.exists(readme_path): with open(readme_path, "w") as f: f.write(README) ignore_path = os.path.join(addons_setup_dir, IGNORE_FILENAME) if not os.path.exists(ignore_path): with open(ignore_path, "w") as f: f.write(IGNORE) ignore = _load_ignore_file(ignore_path) for addon_name in os.listdir(addons_dir): if addon_name in ignore: continue addon_dir = os.path.join(addons_dir, addon_name) if not is_installable_addon(addon_dir): continue addon_setup_dir = os.path.join(addons_setup_dir, addon_name) if not os.path.exists(addon_setup_dir): os.mkdir(addon_setup_dir) make_default_setup_addon( addon_setup_dir, addon_dir, force, odoo_version_override )
Example #20
Source File: test_upload_docs.py From pledgeservice with Apache License 2.0 | 6 votes |
def setUp(self): self.dir = tempfile.mkdtemp() setup = os.path.join(self.dir, 'setup.py') f = open(setup, 'w') f.write(SETUP_PY) f.close() self.old_cwd = os.getcwd() os.chdir(self.dir) self.upload_dir = os.path.join(self.dir, 'build') os.mkdir(self.upload_dir) # A test document. f = open(os.path.join(self.upload_dir, 'index.html'), 'w') f.write("Hello world.") f.close() # An empty folder. os.mkdir(os.path.join(self.upload_dir, 'empty')) if sys.version >= "2.6": self.old_base = site.USER_BASE site.USER_BASE = upload_docs.USER_BASE = tempfile.mkdtemp() self.old_site = site.USER_SITE site.USER_SITE = upload_docs.USER_SITE = tempfile.mkdtemp()
Example #21
Source File: test_easy_install.py From pledgeservice with Apache License 2.0 | 6 votes |
def make_trivial_sdist(dist_path, setup_py): """Create a simple sdist tarball at dist_path, containing just a setup.py, the contents of which are provided by the setup_py string. """ setup_py_file = tarfile.TarInfo(name='setup.py') try: # Python 3 (StringIO gets converted to io module) MemFile = BytesIO except AttributeError: MemFile = StringIO setup_py_bytes = MemFile(setup_py.encode('utf-8')) setup_py_file.size = len(setup_py_bytes.getvalue()) dist = tarfile.open(dist_path, 'w:gz') try: dist.addfile(setup_py_file, fileobj=setup_py_bytes) finally: dist.close()
Example #22
Source File: test_easy_install.py From pledgeservice with Apache License 2.0 | 6 votes |
def test_setup_requires(self): """Regression test for Distribute issue #318 Ensure that a package with setup_requires can be installed when setuptools is installed in the user site-packages without causing a SandboxViolation. """ test_pkg = create_setup_requires_package(self.dir) test_setup_py = os.path.join(test_pkg, 'setup.py') try: with quiet_context(): with reset_setup_stop_context(): run_setup(test_setup_py, ['install']) except SandboxViolation: self.fail('Installation caused SandboxViolation') except IndexError: # Test fails in some cases due to bugs in Python # See https://bitbucket.org/pypa/setuptools/issue/201 pass
Example #23
Source File: setup.py From cgpm with Apache License 2.0 | 6 votes |
def make_release_tree(self, base_dir, files): import os sdist.make_release_tree(self, base_dir, files) version_file = os.path.join(base_dir, 'VERSION') print('updating %s' % (version_file,)) # Write to temporary file first and rename over permanent not # just to avoid atomicity issues (not likely an issue since if # interrupted the whole sdist directory is only partially # written) but because the upstream sdist may have made a hard # link, so overwriting in place will edit the source tree. with open(version_file + '.tmp', 'wb') as f: f.write('%s\n' % (pkg_version,)) os.rename(version_file + '.tmp', version_file) # XXX These should be attributes of `setup', but helpful distutils # doesn't pass them through when it doesn't know about them a priori.
Example #24
Source File: setup.py From pygerrit2 with MIT License | 5 votes |
def _main(): setuptools.setup( packages=setuptools.find_packages(), setup_requires=["pbr"], pbr=True )
Example #25
Source File: test_packaging.py From auto-alt-text-lambda-api with MIT License | 5 votes |
def __init__(self, packages): """Creates packages from dict with defaults :param packages: a dict where the keys are the package name and a value that is a second dict that may be empty, containing keys of filenames and a string value of the contents. {'package-a': {'requirements.txt': 'string', 'setup.cfg': 'string'} """ self.packages = packages
Example #26
Source File: test_make_default_setup.py From setuptools-odoo with GNU Lesser General Public License v3.0 | 5 votes |
def test_make_default_setup_commit(tmpdir): with tmpdir.as_cwd(): subprocess.check_call(["git", "init"]) subprocess.check_call(["git", "config", "user.name", "test"]) subprocess.check_call(["git", "config", "user.email", "test@example.com"]) make_default_setup.main(["--addons-dir", ".", "--commit"]) out = subprocess.check_output(["git", "ls-files"], universal_newlines=True) assert out == textwrap.dedent( """\ setup/.setuptools-odoo-make-default-ignore setup/README """ )
Example #27
Source File: test_make_default_setup.py From setuptools-odoo with GNU Lesser General Public License v3.0 | 5 votes |
def test1(self): expected_dir = os.path.join(DATA_DIR, "setup_reusable_addons") generated_dir = os.path.join(DATA_DIR, "setup") make_default_setup.main(["--addons-dir", DATA_DIR, "-f"]) dc = filecmp.dircmp(expected_dir, generated_dir) try: self._assert_no_diff(dc) finally: shutil.rmtree(generated_dir)
Example #28
Source File: make_default_setup.py From setuptools-odoo with GNU Lesser General Public License v3.0 | 5 votes |
def make_default_setup_commit_files(addons_dir): subprocess.check_call(["git", "add", "setup"], cwd=addons_dir) commit_needed = ( subprocess.call( ["git", "diff", "--quiet", "--cached", "--exit-code", "--", "setup"], cwd=addons_dir, ) != 0 ) if commit_needed: subprocess.check_call( ["git", "commit", "-m", "[ADD] setup.py", "--", "setup"], cwd=addons_dir )
Example #29
Source File: test_z_cmdline.py From tox with MIT License | 5 votes |
def test_notoxini_noerror_in_help(initproj, cmd): initproj("examplepro", filedefs={}) result = cmd("-h") msg = "ERROR: tox config file (either pyproject.toml, tox.ini, setup.cfg) not found\n" assert result.err != msg
Example #30
Source File: setup.py From chaostoolkit-kubernetes with Apache License 2.0 | 5 votes |
def main(): """Package installation entry point.""" setuptools.setup(**setup_params)