(ctx, project_dir, env=None, arch=None)
| 565 | |
| 566 | |
| 567 | def run_setuppy_install(ctx, project_dir, env=None, arch=None): |
| 568 | env = env or {} |
| 569 | |
| 570 | with current_directory(project_dir): |
| 571 | info('got setup.py or similar, running project install. ' + |
| 572 | '(disable this behavior with --ignore-setup-py)') |
| 573 | |
| 574 | # Compute & output the constraints we will use: |
| 575 | info('Contents that will be used for constraints.txt:') |
| 576 | constraints = subprocess.check_output([ |
| 577 | join( |
| 578 | ctx.build_dir, "venv", "bin", "pip" |
| 579 | ), |
| 580 | "freeze" |
| 581 | ], env=copy.copy(env)) |
| 582 | with suppress(AttributeError): |
| 583 | constraints = constraints.decode("utf-8", "replace") |
| 584 | info(constraints) |
| 585 | |
| 586 | # Make sure all packages found are fixed in version |
| 587 | # by writing a constraint file, to avoid recipes being |
| 588 | # upgraded & reinstalled: |
| 589 | with open('._tmp_p4a_recipe_constraints.txt', 'wb') as fileh: |
| 590 | fileh.write(constraints.encode("utf-8", "replace")) |
| 591 | try: |
| 592 | |
| 593 | info('Populating venv\'s site-packages with ' |
| 594 | 'ctx.get_site_packages_dir()...') |
| 595 | |
| 596 | # Copy dist contents into site-packages for discovery. |
| 597 | # Why this is needed: |
| 598 | # --target is somewhat evil and messes with discovery of |
| 599 | # packages in PYTHONPATH if that also includes the target |
| 600 | # folder. So we need to use the regular virtualenv |
| 601 | # site-packages folder instead. |
| 602 | # Reference: |
| 603 | # https://github.com/pypa/pip/issues/6223 |
| 604 | ctx_site_packages_dir = os.path.normpath( |
| 605 | os.path.abspath(ctx.get_site_packages_dir(arch)) |
| 606 | ) |
| 607 | venv_site_packages_dir = os.path.normpath(os.path.join( |
| 608 | ctx.build_dir, "venv", "lib", [ |
| 609 | f for f in os.listdir(os.path.join( |
| 610 | ctx.build_dir, "venv", "lib" |
| 611 | )) if f.startswith("python") |
| 612 | ][0], "site-packages" |
| 613 | )) |
| 614 | copied_over_contents = [] |
| 615 | for f in os.listdir(ctx_site_packages_dir): |
| 616 | full_path = os.path.join(ctx_site_packages_dir, f) |
| 617 | if not os.path.exists(os.path.join( |
| 618 | venv_site_packages_dir, f |
| 619 | )): |
| 620 | if os.path.isdir(full_path): |
| 621 | shutil.copytree(full_path, os.path.join( |
| 622 | venv_site_packages_dir, f |
| 623 | )) |
| 624 | else: |
no test coverage detected