本文整理匯總了Python中setuptools.setup.py方法的典型用法代碼示例。如果您正苦於以下問題:Python setup.py方法的具體用法?Python setup.py怎麽用?Python setup.py使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類setuptools.setup
的用法示例。
在下文中一共展示了setup.py方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: run
# 需要導入模塊: from setuptools import setup [as 別名]
# 或者: from setuptools.setup import py [as 別名]
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()
示例2: update_version_py
# 需要導入模塊: from setuptools import setup [as 別名]
# 或者: from setuptools.setup import py [as 別名]
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)
示例3: run
# 需要導入模塊: from setuptools import setup [as 別名]
# 或者: from setuptools.setup import py [as 別名]
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()
示例4: tar_and_copy_usr_dir
# 需要導入模塊: from setuptools import setup [as 別名]
# 或者: from setuptools.setup import py [as 別名]
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
示例5: test_build_calmjs_artifact
# 需要導入模塊: from setuptools import setup [as 別名]
# 或者: from setuptools.setup import py [as 別名]
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)
示例6: run
# 需要導入模塊: from setuptools import setup [as 別名]
# 或者: from setuptools.setup import py [as 別名]
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:
示例7: _filedefs_contains
# 需要導入模塊: from setuptools import setup [as 別名]
# 或者: from setuptools.setup import py [as 別名]
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
示例8: test_getvenv
# 需要導入模塊: from setuptools import setup [as 別名]
# 或者: from setuptools.setup import py [as 別名]
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")
示例9: test_envdir_would_delete_some_directory
# 需要導入模塊: from setuptools import setup [as 別名]
# 或者: from setuptools.setup import py [as 別名]
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
示例10: test_unknown_interpreter_and_env
# 需要導入模塊: from setuptools import setup [as 別名]
# 或者: from setuptools.setup import py [as 別名]
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"
示例11: test_unknown_interpreter
# 需要導入模塊: from setuptools import setup [as 別名]
# 或者: from setuptools.setup import py [as 別名]
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
示例12: test_skip_platform_mismatch
# 需要導入模塊: from setuptools import setup [as 別名]
# 或者: from setuptools.setup import py [as 別名]
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
示例13: test_skip_unknown_interpreter_result_json
# 需要導入模塊: from setuptools import setup [as 別名]
# 或者: from setuptools.setup import py [as 別名]
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
示例14: test_venv_special_chars_issue252
# 需要導入模塊: from setuptools import setup [as 別名]
# 或者: from setuptools.setup import py [as 別名]
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)
示例15: test_minimal_setup_py_non_functional
# 需要導入模塊: from setuptools import setup [as 別名]
# 或者: from setuptools.setup import py [as 別名]
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