Python setuptools.setup.py() Examples
The following are 30
code examples of setuptools.setup.py().
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.setup
, or try the search function
.
Example #1
Source File: setup.py From EDeN with MIT License | 7 votes |
def update_version_py(): if not os.path.isdir(".git"): print("This does not appear to be a Git repository.") return try: # p = subprocess.Popen(["git", "describe","--tags", "--always"], # stdout=subprocess.PIPE) p = subprocess.Popen("git rev-list HEAD --count".split(), stdout=subprocess.PIPE) except EnvironmentError: print("unable to run git, leaving eden/_version.py alone") return stdout = p.communicate()[0] if p.returncode != 0: print("unable to run git, leaving eden/_version.py alone") return ver = "0.3."+stdout.strip() # ver = str(int(ver,16)) # pypi doesnt like base 16 f = open("eden/_version.py", "w") f.write(VERSION_PY % ver) f.close() print("set eden/_version.py to '%s'" % ver)
Example #2
Source File: setup.py From keras_mixnets with MIT License | 7 votes |
def run(self): try: self.status('Removing previous builds...') rmtree(os.path.join(base_path, 'dist')) except OSError: pass self.status('Building Source and Wheel (universal) distribution...') os.system('{0} setup.py sdist bdist_wheel'.format(sys.executable)) self.status('Pushing git tags...') os.system('git tag v{0}'.format(get_version())) os.system('git push --tags') try: self.status('Removing build artifacts...') rmtree(os.path.join(base_path, 'build')) rmtree(os.path.join(base_path, '{}.egg-info'.format(PACKAGE_NAME))) except OSError: pass sys.exit()
Example #3
Source File: test_z_cmdline.py From tox with MIT License | 6 votes |
def test_venv_special_chars_issue252(cmd, initproj): initproj( "pkg123-0.7", filedefs={ "tests": {"test_hello.py": "def test_hello(): pass"}, "tox.ini": """ [tox] envlist = special&&1 [testenv:special&&1] changedir=tests """, }, ) result = cmd() result.assert_success() pattern = re.compile(r"special&&1 installed: .*pkg123( @ .*-|==)0\.7(\.zip)?.*") assert any(pattern.match(line) for line in result.outlines), "\n".join(result.outlines)
Example #4
Source File: cloud_mlengine.py From fine-lm with MIT License | 6 votes |
def tar_and_copy_usr_dir(usr_dir, train_dir): """Package, tar, and copy usr_dir to GCS train_dir.""" tf.logging.info("Tarring and pushing t2t_usr_dir.") usr_dir = os.path.abspath(os.path.expanduser(usr_dir)) # Copy usr dir to a temp location top_dir = os.path.join(tempfile.gettempdir(), "t2t_usr_container") tmp_usr_dir = os.path.join(top_dir, usr_dir_lib.INTERNAL_USR_DIR_PACKAGE) shutil.rmtree(top_dir, ignore_errors=True) shutil.copytree(usr_dir, tmp_usr_dir) # Insert setup.py if one does not exist top_setup_fname = os.path.join(top_dir, "setup.py") setup_file_str = get_setup_file( name="DummyUsrDirPackage", packages=get_requirements(usr_dir) ) with tf.gfile.Open(top_setup_fname, "w") as f: f.write(setup_file_str) usr_tar = _tar_and_copy(top_dir, train_dir) return usr_tar
Example #5
Source File: test_dist.py From calmjs with GNU General Public License v2.0 | 6 votes |
def test_build_calmjs_artifact(self): """ Emulate the execution of ``python setup.py egg_info``. Ensure everything is covered. """ # run the step directly to see that the command is registered, # though the actual effects cannot be tested, as the test # package is not going to be installed and there are no valid # artifact build functions defined. p = Popen( [sys.executable, 'setup.py', 'build_calmjs_artifacts'], stdout=PIPE, stderr=PIPE, cwd=self.pkg_root, ) stdout, stderr = p.communicate() stdout = stdout.decode(locale) self.assertIn('running build_calmjs_artifacts', stdout)
Example #6
Source File: setup.py From keras-utility-layer-collection with MIT License | 6 votes |
def run(self): try: self.status('Removing previous builds…') rmtree(os.path.join(here, 'dist')) except OSError: pass self.status('Building Source and Wheel (universal) distribution…') os.system('{0} setup.py sdist bdist_wheel --universal'.format(sys.executable)) self.status('Uploading the package to PyPi via Twine…') os.system('twine upload dist/*') self.status('Pushing git tags…') os.system('git tag v{0}'.format(about['__version__'])) os.system('git push --tags') sys.exit() # Where the magic happens:
Example #7
Source File: _pytestplugin.py From tox with MIT License | 6 votes |
def _filedefs_contains(base, filedefs, path): """ whether `filedefs` defines a file/folder with the given `path` `path`, if relative, will be interpreted relative to the `base` folder, and whether relative or not, must refer to either the `base` folder or one of its direct or indirect children. The base folder itself is considered created if the filedefs structure is not empty. """ unknown = object() base = py.path.local(base) path = _path_join(base, path) path_rel_parts = _path_parts(path.relto(base)) for part in path_rel_parts: if not isinstance(filedefs, dict): return False filedefs = filedefs.get(part, unknown) if filedefs is unknown: return False return path_rel_parts or path == base and filedefs
Example #8
Source File: test_z_cmdline.py From tox with MIT License | 6 votes |
def test_getvenv(self, initproj): initproj( "logexample123-0.5", filedefs={ "tests": {"test_hello.py": "def test_hello(): pass"}, "tox.ini": """ [testenv:hello] [testenv:world] """, }, ) config = parseconfig([]) session = Session(config) venv1 = session.getvenv("hello") venv2 = session.getvenv("hello") assert venv1 is venv2 venv1 = session.getvenv("world") venv2 = session.getvenv("world") assert venv1 is venv2 with pytest.raises(LookupError): session.getvenv("qwe")
Example #9
Source File: setup.py From django-rest-polymorphic with MIT License | 6 votes |
def run(self): try: self.status('Removing previous builds…') rmtree(os.path.join(here, 'dist')) except OSError: pass self.status('Building Source and Wheel (universal) distribution…') os.system('{0} setup.py sdist bdist_wheel --universal'.format( sys.executable )) self.status('Uploading the package to PyPi via Twine…') os.system('twine upload dist/*') sys.exit()
Example #10
Source File: test_z_cmdline.py From tox with MIT License | 6 votes |
def test_unknown_interpreter_and_env(cmd, initproj): initproj( "interp123-0.5", filedefs={ "tests": {"test_hello.py": "def test_hello(): pass"}, "tox.ini": """\ [testenv:python] basepython=xyz_unknown_interpreter [testenv] changedir=tests skip_install = true """, }, ) result = cmd() result.assert_fail() assert "ERROR: InterpreterNotFound: xyz_unknown_interpreter" in result.outlines result = cmd("-exyz") result.assert_fail() assert result.out == "ERROR: unknown environment 'xyz'\n"
Example #11
Source File: test_z_cmdline.py From tox with MIT License | 6 votes |
def test_unknown_interpreter(cmd, initproj): 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() result.assert_fail() assert any( "ERROR: InterpreterNotFound: xyz_unknown_interpreter" == line for line in result.outlines ), result.outlines
Example #12
Source File: test_z_cmdline.py From tox with MIT License | 6 votes |
def test_skip_platform_mismatch(cmd, initproj): initproj( "interp123-0.5", filedefs={ "tests": {"test_hello.py": "def test_hello(): pass"}, "tox.ini": """ [testenv] changedir=tests platform=x123 """, }, ) result = cmd() result.assert_success() assert any( "SKIPPED: python: platform mismatch ({!r} does not match 'x123')".format(sys.platform) == line for line in result.outlines ), result.outlines
Example #13
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 #14
Source File: test_z_cmdline.py From tox with MIT License | 6 votes |
def test_envdir_would_delete_some_directory(cmd, initproj): projdir = initproj( "example-123", filedefs={ "tox.ini": """\ [tox] [testenv:venv] envdir=example commands= """, }, ) result = cmd("-e", "venv") assert projdir.join("example/__init__.py").exists() result.assert_fail() assert "cowardly refusing to delete `envdir`" in result.out
Example #15
Source File: test_z_cmdline.py From tox with MIT License | 6 votes |
def test_minimal_setup_py_non_functional(cmd, initproj): initproj( "pkg123-0.7", filedefs={ "tests": {"test_hello.py": "def test_hello(): pass"}, "setup.py": """ import sys """, "tox.ini": "", }, ) result = cmd() result.assert_fail() assert any( re.match(r".*ERROR.*check setup.py.*", line) for line in result.outlines ), result.outlines
Example #16
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 #17
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 #18
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 #19
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 #20
Source File: test_z_cmdline.py From tox with MIT License | 6 votes |
def test_warning_emitted(cmd, initproj): initproj( "spam-0.0.1", filedefs={ "tox.ini": """ [testenv] skipsdist=True usedevelop=True """, "setup.py": """ from setuptools import setup from warnings import warn warn("I am a warning") setup(name="spam", version="0.0.1") """, }, ) cmd() result = cmd() assert "develop-inst-noop" in result.out assert "I am a warning" in result.err
Example #21
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 #22
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 #23
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 #24
Source File: setup.py From iosfw with MIT License | 6 votes |
def run(self): try: self.status('Removing previous builds…') rmtree(os.path.join(here, 'dist')) except OSError: pass self.status('Building Source and Wheel (universal) distribution…') os.system('{0} setup.py sdist bdist_wheel --universal'.format(sys.executable)) self.status('Uploading the package to PyPI via Twine…') os.system('twine upload dist/*') self.status('Pushing git tags…') os.system('git tag v{0}'.format(about['__version__'])) os.system('git push --tags') sys.exit() # Where the magic happens:
Example #25
Source File: easy_install.py From jbox with MIT License | 6 votes |
def write_script(self, script_name, contents, mode="t", blockers=()): """Write an executable file to the scripts directory""" self.delete_blockers( # clean up old .py/.pyw w/o a script [os.path.join(self.script_dir, x) for x in blockers] ) log.info("Installing %s script to %s", script_name, self.script_dir) target = os.path.join(self.script_dir, script_name) self.add_output(target) mask = current_umask() if not self.dry_run: ensure_directory(target) if os.path.exists(target): os.unlink(target) with open(target, "w" + mode) as f: f.write(contents) chmod(target, 0o777 - mask)
Example #26
Source File: easy_install.py From jbox with MIT License | 6 votes |
def unpack_and_compile(self, egg_path, destination): to_compile = [] to_chmod = [] def pf(src, dst): if dst.endswith('.py') and not src.startswith('EGG-INFO/'): to_compile.append(dst) elif dst.endswith('.dll') or dst.endswith('.so'): to_chmod.append(dst) self.unpack_progress(src, dst) return not self.dry_run and dst or None unpack_archive(egg_path, destination, pf) self.byte_compile(to_compile) if not self.dry_run: for f in to_chmod: mode = ((os.stat(f)[stat.ST_MODE]) | 0o555) & 0o7755 chmod(f, mode)
Example #27
Source File: setup.py From django-json-widget with MIT License | 5 votes |
def get_version(*file_paths): """Retrieves the version from django_json_widget/__init__.py""" filename = os.path.join(os.path.dirname(__file__), *file_paths) version_file = open(filename).read() version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M) if version_match: return version_match.group(1) raise RuntimeError('Unable to find version string.') # version = get_version("django_json_widget", "__init__.py")
Example #28
Source File: setup.py From django-mptt-comments with MIT License | 5 votes |
def get_version(*file_paths): """Retrieves the version from django_mptt_comments/__init__.py""" filename = os.path.join(os.path.dirname(__file__), *file_paths) version_file = open(filename).read() version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M) if version_match: return version_match.group(1) raise RuntimeError('Unable to find version string.')
Example #29
Source File: test_z_cmdline.py From tox with MIT License | 5 votes |
def test_envtmpdir(initproj, cmd): initproj( "foo", filedefs={ # This file first checks that envtmpdir is existent and empty. Then it # creates an empty file in that directory. The tox command is run # twice below, so this is to test whether the directory is cleared # before the second run. "check_empty_envtmpdir.py": """if True: import os from sys import argv envtmpdir = argv[1] assert os.path.exists(envtmpdir) assert os.listdir(envtmpdir) == [] open(os.path.join(envtmpdir, 'test'), 'w').close() """, "tox.ini": """ [testenv] commands=python check_empty_envtmpdir.py {envtmpdir} """, }, ) result = cmd() result.assert_success() result = cmd() result.assert_success()
Example #30
Source File: setup.py From DjangoRestMultipleModels with MIT License | 5 votes |
def get_version(package): """ Return package version as listed in `__version__` in `init.py`. """ init_py = open(os.path.join(package, '__init__.py')).read() return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1)