1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577
|
import os, sys, shutil, unittest, tempfile, tarfile, warnings
from wheel.bdist_wheel import get_abi_tag, get_platform
from packaging.tags import interpreter_name, interpreter_version
sys.path.insert(0, "src")
import common
pyver_major = "py%d" % sys.version_info[0]
pyver = "py%d.%d" % sys.version_info[:2]
# For binary wheels with native code
impl, impl_ver = interpreter_name(), interpreter_version()
abi = get_abi_tag()
try:
plat = get_platform(None)
except TypeError: # wheel < 0.34
plat = get_platform()
class _Invocations(common.Common):
def setUp(self):
if False:
# when debugging, put the generated files in a predictable place
self.testdir = os.path.abspath("t")
if os.path.exists(self.testdir):
return
os.mkdir(self.testdir)
else:
self.testdir = tempfile.mkdtemp()
os.mkdir(self.subpath("cache"))
os.mkdir(self.subpath("cache", "setuptools"))
self.gitdir = None
self.projdir = None
def make_venv(self, mode):
if not os.path.exists(self.subpath("venvs")):
os.mkdir(self.subpath("venvs"))
venv_dir = self.subpath(os.path.join("venvs", mode))
# python3 on OS-X uses a funky two-part executable and an environment
# variable to communicate between them. If this variable is still set
# by the time a virtualenv's 'pip' or 'python' is run, and if that
# command spawns another sys.executable underneath it, that second
# child may use the wrong python, and can install things into the
# real system library instead of the virtualenv. Invoking
# virtualenv.create_environment() clears this as a side-effect, but
# to make things safe I'll just clear this now. See
# https://github.com/pypa/virtualenv/issues/322 and
# https://bugs.python.org/issue22490 for some hints. I tried
# switching to 'venv' on py3, but only py3.4 includes pip, and even
# then it's an ancient version.
os.environ.pop("__PYVENV_LAUNCHER__", None)
# virtualenv causes DeprecationWarning/ResourceWarning on py3
with warnings.catch_warnings():
warnings.simplefilter("ignore")
self.python('-m', 'virtualenv', venv_dir, workdir=self.testdir)
self.run_in_venv(venv_dir, venv_dir,
'pip', 'install', '-U',
'pip', 'wheel', 'packaging')
return venv_dir
def get_venv_bin(self, venv, command):
if sys.platform == "win32":
return os.path.join(venv, "Scripts", command)
return os.path.join(venv, "bin", command)
def run_in_venv(self, venv, workdir, command, *args, use_python=False):
bin_args = [self.get_venv_bin(venv, command)]
pybin = self.get_venv_bin(venv, "python")
if command == "pip":
bin_args = [pybin, "-m", "pip"]
args = ["--isolated", "--no-cache-dir"] + list(args)
elif command == "rundemo" and use_python:
bin_args = [pybin] + bin_args
return self.command(*bin_args, *args, workdir=workdir)
def check_in_venv(self, venv, use_python=False):
out = self.run_in_venv(venv, venv, "rundemo", use_python=use_python)
v = dict(line.split(":", 1) for line in out.splitlines())
self.assertEqual(v["version"], "2.0")
return v
def check_in_venv_withlib(self, venv):
v = self.check_in_venv(venv)
self.assertEqual(v["demolib"], "1.0")
# "demolib" has a version of 1.0 and is built with setuptools
# "demoapp2-setuptools" is v2.0, uses setuptools, and depends on demolib
# repos and unpacked git-archive tarballs come in two flavors: normal (in
# which the setup.py/setup.cfg/versioneer.py files live in the root of
# the source tree), and "subproject" (where they live in a subdirectory).
# sdists are always "normal" (although they might have come from either
# normal or subproject -style source trees), and wheels/eggs don't have
# these files at all.
# TODO: git-archive subproject-flavor
def make_demolib_sdist(self):
# create an sdist of demolib-1.0 . for the *lib*, we only use the
# tarball, never the repo.
demolib_sdist = self.subpath("cache", "demolib-1.0.tar")
if os.path.exists(demolib_sdist):
return demolib_sdist
libdir = self.subpath("build-demolib")
shutil.copytree("test/demolib", libdir)
shutil.copy("versioneer.py", libdir)
self.git("init", workdir=libdir)
self.python("versioneer.py", "setup", workdir=libdir)
self.git("add", "--all", workdir=libdir)
self.git("commit", "-m", "comment", workdir=libdir)
self.git("tag", "demolib-1.0", workdir=libdir)
self.python("setup.py", "sdist", "--format=tar", workdir=libdir)
created = os.path.join(libdir, "dist", "demolib-1.0.tar")
self.assertTrue(os.path.exists(created))
shutil.copyfile(created, demolib_sdist)
return demolib_sdist
def make_linkdir(self):
# create/populate a fake pypi directory for use with --find-links
linkdir = self.subpath("linkdir")
if os.path.exists(linkdir):
return linkdir
os.mkdir(linkdir)
demolib_sdist = self.make_demolib_sdist()
shutil.copy(demolib_sdist, linkdir)
return linkdir
def make_empty_indexdir(self):
indexdir = self.subpath("indexdir")
if os.path.exists(indexdir):
return indexdir
os.mkdir(indexdir)
return indexdir
def make_setuptools_repo(self):
# create a clean repo of demoapp2-setuptools at 2.0
repodir = self.subpath("demoapp2-setuptools-repo")
if os.path.exists(repodir):
shutil.rmtree(repodir)
shutil.copytree("test/demoapp2-setuptools", repodir)
shutil.copy("versioneer.py", repodir)
self.git("init", workdir=repodir)
self.python("versioneer.py", "setup", workdir=repodir)
self.git("add", "--all", workdir=repodir)
self.git("commit", "-m", "comment", workdir=repodir)
self.git("tag", "demoapp2-2.0", workdir=repodir)
return repodir
def make_setuptools_extension_unpacked(self):
sdist = self.make_setuptools_extension_sdist()
unpack_into = self.subpath("demoappext-setuptools-unpacked")
if os.path.exists(unpack_into):
shutil.rmtree(unpack_into)
os.mkdir(unpack_into)
with tarfile.TarFile(sdist) as t:
t.extractall(path=unpack_into)
unpacked = os.path.join(unpack_into, "demoappext-2.0")
self.assertTrue(os.path.exists(unpacked))
return unpacked
def make_setuptools_extension_sdist(self):
# create an sdist tarball of demoappext-setuptools at 2.0
demoappext_setuptools_sdist = self.subpath("cache", "setuptools",
"demoappext-2.0.tar")
if os.path.exists(demoappext_setuptools_sdist):
return demoappext_setuptools_sdist
repodir = self.make_setuptools_extension_repo()
self.python("setup.py", "sdist", "--format=tar", workdir=repodir)
created = os.path.join(repodir, "dist", "demoappext-2.0.tar")
self.assertTrue(os.path.exists(created), created)
shutil.copyfile(created, demoappext_setuptools_sdist)
return demoappext_setuptools_sdist
def make_setuptools_extension_repo(self):
# create a clean repo of demoappext-setuptools at 2.0
repodir = self.subpath("demoappext-setuptools-repo")
if os.path.exists(repodir):
shutil.rmtree(repodir)
# import ipdb; ipdb.set_trace()
shutil.copytree("test/demoappext-setuptools", repodir)
shutil.copy("versioneer.py", repodir)
self.git("init", workdir=repodir)
self.python("versioneer.py", "setup", workdir=repodir)
self.git("add", "--all", workdir=repodir)
self.git("commit", "-m", "comment", workdir=repodir)
self.git("tag", "demoappext-2.0", workdir=repodir)
return repodir
def make_setuptools_repo_subproject(self):
# create a clean repo of demoapp2-setuptools at 2.0
repodir = self.subpath("demoapp2-setuptools-repo-subproject")
if os.path.exists(repodir):
shutil.rmtree(repodir)
shutil.copytree("test/demoapp2-setuptools-subproject", repodir)
projectdir = os.path.join(repodir, "subproject")
shutil.copy("versioneer.py", projectdir)
self.git("init", workdir=repodir)
self.python("versioneer.py", "setup", workdir=projectdir)
self.git("add", "--all", workdir=repodir)
self.git("commit", "-m", "comment", workdir=repodir)
self.git("tag", "demoapp2-2.0", workdir=repodir)
return projectdir
def make_setuptools_sdist(self):
# create an sdist tarball of demoapp2-setuptools at 2.0
demoapp2_setuptools_sdist = self.subpath("cache", "setuptools",
"demoapp2-2.0.tar")
if os.path.exists(demoapp2_setuptools_sdist):
return demoapp2_setuptools_sdist
repodir = self.make_setuptools_repo()
self.python("setup.py", "sdist", "--format=tar", workdir=repodir)
created = os.path.join(repodir, "dist", "demoapp2-2.0.tar")
self.assertTrue(os.path.exists(created), created)
shutil.copyfile(created, demoapp2_setuptools_sdist)
return demoapp2_setuptools_sdist
def make_setuptools_sdist_subproject(self):
demoapp2_setuptools_sdist = self.subpath("cache", "setuptools",
"demoapp2-subproject-2.0.tar")
if os.path.exists(demoapp2_setuptools_sdist):
return demoapp2_setuptools_sdist
projectdir = self.make_setuptools_repo_subproject()
self.python("setup.py", "sdist", "--format=tar", workdir=projectdir)
created = os.path.join(projectdir, "dist", "demoapp2-2.0.tar")
self.assertTrue(os.path.exists(created), created)
shutil.copyfile(created, demoapp2_setuptools_sdist)
return demoapp2_setuptools_sdist
def make_setuptools_unpacked(self):
sdist = self.make_setuptools_sdist()
unpack_into = self.subpath("demoapp2-setuptools-unpacked")
if os.path.exists(unpack_into):
shutil.rmtree(unpack_into)
os.mkdir(unpack_into)
with tarfile.TarFile(sdist) as t:
t.extractall(path=unpack_into)
unpacked = os.path.join(unpack_into, "demoapp2-2.0")
self.assertTrue(os.path.exists(unpacked))
return unpacked
def make_setuptools_subproject_unpacked(self):
sdist = self.make_setuptools_sdist_subproject()
unpack_into = self.subpath("demoapp2-setuptools-unpacked-subproject")
if os.path.exists(unpack_into):
shutil.rmtree(unpack_into)
os.mkdir(unpack_into)
with tarfile.TarFile(sdist) as t:
t.extractall(path=unpack_into)
unpacked = os.path.join(unpack_into, "demoapp2-2.0")
self.assertTrue(os.path.exists(unpacked))
return unpacked
def make_setuptools_egg(self):
# create an egg of demoapp2-setuptools at 2.0
demoapp2_setuptools_egg = self.subpath("cache", "setuptools",
"demoapp2-2.0-%s.egg" % pyver)
if os.path.exists(demoapp2_setuptools_egg):
return demoapp2_setuptools_egg
repodir = self.make_setuptools_repo()
self.python("setup.py", "bdist_egg", workdir=repodir)
created = os.path.join(repodir, "dist", "demoapp2-2.0-%s.egg" % pyver)
self.assertTrue(os.path.exists(created), created)
shutil.copyfile(created, demoapp2_setuptools_egg)
return demoapp2_setuptools_egg
def make_setuptools_wheel_with_setup_py(self):
# create an wheel of demoapp2-setuptools at 2.0
wheelname = "demoapp2-2.0-%s-none-any.whl" % pyver_major
demoapp2_setuptools_wheel = self.subpath("cache", "setuptools",
wheelname)
if os.path.exists(demoapp2_setuptools_wheel):
# there are two ways to make this .whl, and we need to exercise
# both, so don't actually cache the results
os.unlink(demoapp2_setuptools_wheel)
repodir = self.make_setuptools_repo()
self.python("setup.py", "bdist_wheel", workdir=repodir)
created = os.path.join(repodir, "dist", wheelname)
self.assertTrue(os.path.exists(created), created)
shutil.copyfile(created, demoapp2_setuptools_wheel)
return demoapp2_setuptools_wheel
def make_setuptools_wheel_with_pip(self):
# create an wheel of demoapp2-setuptools at 2.0
wheelname = "demoapp2-2.0-%s-none-any.whl" % pyver_major
demoapp2_setuptools_wheel = self.subpath("cache", "setuptools",
wheelname)
if os.path.exists(demoapp2_setuptools_wheel):
# there are two ways to make this .whl, and we need to exercise
# both, so don't actually cache the results
os.unlink(demoapp2_setuptools_wheel)
linkdir = self.make_linkdir()
repodir = self.make_setuptools_repo()
venv = self.make_venv("make-setuptools-wheel-with-pip")
self.run_in_venv(venv, repodir,
"pip", "wheel", "--wheel-dir", "wheelhouse",
"--no-index", "--find-links", linkdir,
".")
created = os.path.join(repodir, "wheelhouse", wheelname)
self.assertTrue(os.path.exists(created), created)
shutil.copyfile(created, demoapp2_setuptools_wheel)
return demoapp2_setuptools_wheel
def make_binary_wheelname(self, app):
return "%s-2.0-%s-%s-%s.whl" % (app,
"".join([impl, impl_ver]), abi,
plat.replace("-", "_").replace(".", "_")
)
class SetuptoolsRepo(_Invocations, unittest.TestCase):
def test_install(self):
repodir = self.make_setuptools_repo()
demolib = self.make_demolib_sdist()
venv = self.make_venv("setuptools-repo-install")
# "setup.py install" doesn't take --no-index or --find-links, so we
# pre-install the dependency
self.run_in_venv(venv, venv, "pip", "install", demolib)
self.run_in_venv(venv, repodir, "python", "setup.py", "install")
self.check_in_venv_withlib(venv)
def test_install_subproject(self):
projectdir = self.make_setuptools_repo_subproject()
demolib = self.make_demolib_sdist()
venv = self.make_venv("setuptools-repo-install-subproject")
# "setup.py install" doesn't take --no-index or --find-links, so we
# pre-install the dependency
self.run_in_venv(venv, venv, "pip", "install", demolib)
self.run_in_venv(venv, projectdir, "python", "setup.py", "install")
self.check_in_venv_withlib(venv)
def test_develop(self):
linkdir = self.make_linkdir()
indexdir = self.make_empty_indexdir()
repodir = self.make_setuptools_repo()
venv = self.make_venv("setuptools-repo-develop")
# "setup.py develop" takes --find-links and --index-url but not
# --no-index
self.run_in_venv(venv, repodir,
"python", "setup.py", "develop",
"--index-url", indexdir, "--find-links", linkdir,
)
self.check_in_venv_withlib(venv)
def test_develop_subproject(self):
linkdir = self.make_linkdir()
indexdir = self.make_empty_indexdir()
projectdir = self.make_setuptools_repo_subproject()
venv = self.make_venv("setuptools-repo-develop-subproject")
# "setup.py develop" takes --find-links and --index-url but not
# --no-index
self.run_in_venv(venv, projectdir,
"python", "setup.py", "develop",
"--index-url", indexdir, "--find-links", linkdir,
)
self.check_in_venv_withlib(venv)
def test_egg(self):
self.make_setuptools_egg() # asserts version as a side-effect
def test_pip_wheel(self):
self.make_setuptools_wheel_with_pip()
# asserts version as a side-effect
def test_bdist_wheel(self):
self.make_setuptools_wheel_with_setup_py()
# asserts version as a side-effect
def test_sdist(self):
sdist = self.make_setuptools_sdist() # asserts version as a side-effect
# make sure we used setuptools/sdist, not distutils/sdist
with tarfile.TarFile(sdist) as t:
self.assertIn("demoapp2-2.0/src/demoapp2.egg-info/PKG-INFO", t.getnames())
def test_sdist_subproject(self):
sdist = self.make_setuptools_sdist_subproject()
# make sure we used setuptools/sdist, not distutils/sdist
with tarfile.TarFile(sdist) as t:
self.assertIn("demoapp2-2.0/src/demoapp2.egg-info/PKG-INFO", t.getnames())
def test_pip_install(self):
linkdir = self.make_linkdir()
repodir = self.make_setuptools_repo()
venv = self.make_venv("setuptools-repo-pip-install")
self.run_in_venv(venv, repodir, "pip", "install", ".",
"--no-index", "--find-links", linkdir)
self.check_in_venv_withlib(venv)
def test_pip_install_subproject(self):
linkdir = self.make_linkdir()
projectdir = self.make_setuptools_repo_subproject()
venv = self.make_venv("setuptools-repo-pip-install-subproject")
self.run_in_venv(venv, projectdir, "pip", "install", ".",
"--no-index", "--find-links", linkdir)
self.check_in_venv_withlib(venv)
def test_pip_install_from_afar(self):
linkdir = self.make_linkdir()
repodir = self.make_setuptools_repo()
venv = self.make_venv("setuptools-repo-pip-install-from-afar")
self.run_in_venv(venv, venv, "pip", "install", repodir,
"--no-index", "--find-links", linkdir)
self.check_in_venv_withlib(venv)
def test_pip_install_from_afar_subproject(self):
linkdir = self.make_linkdir()
projectdir = self.make_setuptools_repo_subproject()
venv = self.make_venv("setuptools-repo-pip-install-from-afar-subproject")
self.run_in_venv(venv, venv, "pip", "install", projectdir,
"--no-index", "--find-links", linkdir)
self.check_in_venv_withlib(venv)
def test_pip_install_editable(self):
linkdir = self.make_linkdir()
repodir = self.make_setuptools_repo()
venv = self.make_venv("setuptools-repo-pip-install-editable")
self.run_in_venv(venv, repodir, "pip", "install", "--editable", ".",
"--no-index", "--find-links", linkdir)
self.check_in_venv_withlib(venv)
def test_pip_install_editable_subproject(self):
linkdir = self.make_linkdir()
projectdir = self.make_setuptools_repo_subproject()
venv = self.make_venv("setuptools-repo-pip-install-editable-subproject")
self.run_in_venv(venv, projectdir, "pip", "install", "--editable", ".",
"--no-index", "--find-links", linkdir)
self.check_in_venv_withlib(venv)
class SetuptoolsSdist(_Invocations, unittest.TestCase):
def test_pip_install(self):
linkdir = self.make_linkdir()
sdist = self.make_setuptools_sdist()
venv = self.make_venv("setuptools-sdist-pip-install")
self.run_in_venv(venv, venv,
"pip", "install",
"--no-index", "--find-links", linkdir,
sdist)
self.check_in_venv_withlib(venv)
def test_pip_install_subproject(self):
linkdir = self.make_linkdir()
sdist = self.make_setuptools_sdist_subproject()
venv = self.make_venv("setuptools-sdist-pip-install-subproject")
self.run_in_venv(venv, venv,
"pip", "install",
"--no-index", "--find-links", linkdir,
sdist)
self.check_in_venv_withlib(venv)
class SetuptoolsWheel(_Invocations, unittest.TestCase):
def test_pip_install(self):
linkdir = self.make_linkdir()
wheel = self.make_setuptools_wheel_with_setup_py()
venv = self.make_venv("setuptools-wheel-pip-install")
self.run_in_venv(venv, venv,
"pip", "install",
"--no-index", "--find-links", linkdir,
wheel)
self.check_in_venv_withlib(venv)
class SetuptoolsUnpacked(_Invocations, unittest.TestCase):
def test_install(self):
unpacked = self.make_setuptools_unpacked()
demolib = self.make_demolib_sdist()
venv = self.make_venv("setuptools-unpacked-install")
# "setup.py install" doesn't take --no-index or --find-links, so we
# pre-install the dependency
self.run_in_venv(venv, venv, "pip", "install", demolib)
self.run_in_venv(venv, unpacked,
"python", "setup.py", "install")
self.check_in_venv_withlib(venv)
def test_install_subproject(self):
unpacked = self.make_setuptools_subproject_unpacked()
demolib = self.make_demolib_sdist()
venv = self.make_venv("setuptools-subproject-unpacked-install")
# "setup.py install" doesn't take --no-index or --find-links, so we
# pre-install the dependency
self.run_in_venv(venv, venv, "pip", "install", demolib)
self.run_in_venv(venv, unpacked,
"python", "setup.py", "install")
self.check_in_venv_withlib(venv)
def test_wheel(self):
unpacked = self.make_setuptools_unpacked()
self.python("setup.py", "bdist_wheel", workdir=unpacked)
wheelname = "demoapp2-2.0-%s-none-any.whl" % pyver_major
wheel = os.path.join(unpacked, "dist", wheelname)
self.assertTrue(os.path.exists(wheel))
def test_pip_wheel(self):
unpacked = self.make_setuptools_unpacked()
linkdir = self.make_linkdir()
wheelname = "demoapp2-2.0-%s-none-any.whl" % pyver_major
venv = self.make_venv("setuptools-unpacked-pip-wheel")
self.run_in_venv(venv, unpacked,
"pip", "wheel", "--wheel-dir", "wheelhouse",
"--no-index", "--find-links", linkdir,
".")
created = os.path.join(unpacked, "wheelhouse", wheelname)
self.assertTrue(os.path.exists(created), created)
def test_pip_install(self):
linkdir = self.make_linkdir()
repodir = self.make_setuptools_unpacked()
venv = self.make_venv("setuptools-unpacked-pip-install")
self.run_in_venv(venv, repodir, "pip", "install", ".",
"--no-index", "--find-links", linkdir)
self.check_in_venv_withlib(venv)
def test_pip_install_subproject(self):
linkdir = self.make_linkdir()
unpacked = self.make_setuptools_subproject_unpacked()
venv = self.make_venv("setuptools-subproject-unpacked-pip-install")
self.run_in_venv(venv, unpacked, "pip", "install", ".",
"--no-index", "--find-links", linkdir)
self.check_in_venv_withlib(venv)
def test_pip_install_from_afar(self):
linkdir = self.make_linkdir()
repodir = self.make_setuptools_unpacked()
venv = self.make_venv("setuptools-unpacked-pip-install-from-afar")
self.run_in_venv(venv, venv, "pip", "install", repodir,
"--no-index", "--find-links", linkdir)
self.check_in_venv_withlib(venv)
def test_extension_wheel_setuptools(self):
# create an wheel of demoappext-setuptools at 2.0
wheelname = self.make_binary_wheelname('demoappext')
demoappext_setuptools_wheel = self.subpath("cache", "setuptools",
wheelname)
if os.path.exists(demoappext_setuptools_wheel):
# there are two ways to make this .whl, and we need to exercise
# both, so don't actually cache the results
os.unlink(demoappext_setuptools_wheel)
repodir = self.make_setuptools_extension_repo()
self.python("setup.py", "bdist_wheel", workdir=repodir)
created = os.path.join(repodir, "dist", wheelname)
self.assertTrue(os.path.exists(created), created)
def test_extension_inplace(self):
# build extensions in place. No wheel package
unpacked = self.make_setuptools_extension_unpacked()
venv = self.make_venv("setuptools-unpacked-pip-wheel-extension")
self.run_in_venv(venv, unpacked,
"python", "setup.py", "build_ext", "-i")
# No wheel package is created, _version.py should exist in
# module dir only
version_file = os.path.join(unpacked, "demo", "_version.py")
self.assertTrue(os.path.exists(version_file))
def test_extension_wheel_pip(self):
# create an wheel of demoappext-setuptools at 2.0 with pip
wheelname = self.make_binary_wheelname('demoappext')
demoappext_setuptools_wheel = self.subpath("cache", "setuptools",
wheelname)
if os.path.exists(demoappext_setuptools_wheel):
# there are two ways to make this .whl, and we need to exercise
# both, so don't actually cache the results
os.unlink(demoappext_setuptools_wheel)
unpacked = self.make_setuptools_extension_unpacked()
linkdir = self.make_linkdir()
venv = self.make_venv("setuptools-unpacked-pip-wheel-extension")
self.run_in_venv(venv, unpacked,
"pip", "wheel", "--wheel-dir", "wheelhouse",
"--no-index", "--find-links", linkdir,
".")
created = os.path.join(unpacked, "wheelhouse", wheelname)
self.assertTrue(os.path.exists(created), created)
if __name__ == '__main__':
unittest.main()
|