Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,65 @@
# aedifix

# Bootstrapping aedifix in your build

Assuming your main package is called `MyMainPacakge` and lives in `my_main_package.py`,
you may use the following snippet to create a `configure` script that automatically
bootstraps `aedifix` on first call.

```python
#!/usr/bin/env python3
from __future__ import annotations

import sys


def ensure_aedifix() -> None:
r"""Ensure aedifix is bootstrapped."""
from importlib.metadata import PackageNotFoundError, version

from packaging.version import Version

VERSION = Version("1.2.0")

try:
mod_version = Version(version("aedifix"))

if mod_version == VERSION:
return

if mod_version.is_devrelease:
# If its a "dev release" that means it's editable installed,
# meaning someone is working on aedifix. We don't care that the
# versions don't match in this case.
return

raise RuntimeError # noqa: TRY301
except (PackageNotFoundError, RuntimeError):
from subprocess import check_call

package = f"git+https://github.com/nv-legate/aedifix@{VERSION}"
check_call([sys.executable, "-m", "pip", "install", package])


ensure_aedifix()

from my_main_package import MyMainPackage # noqa: E402

from aedifix.main import basic_configure # noqa: E402


def main() -> int:
r"""Run configure.

Returns
-------
int
An integer error code, or 0 on success.
"""
return basic_configure(tuple(sys.argv[1:]), MyMainPackage)


if __name__ == "__main__":
sys.exit(main())

```
54 changes: 54 additions & 0 deletions share/aedifix/example_configure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env python3
from __future__ import annotations

import sys


def ensure_aedifix() -> None:
r"""Ensure aedifix is bootstrapped."""
from importlib.metadata import PackageNotFoundError, version

from packaging.version import Version

VERSION = Version("1.2.0")

try:
mod_version = Version(version("aedifix"))

if mod_version == VERSION:
return

if mod_version.is_devrelease:
# If its a "dev release" that means it's editable installed,
# meaning someone is working on aedifix. We don't care that the
# versions don't match in this case.
return

raise RuntimeError # noqa: TRY301
except (PackageNotFoundError, RuntimeError):
from subprocess import check_call

package = f"git+https://github.com/nv-legate/aedifix@{VERSION}"
check_call([sys.executable, "-m", "pip", "install", package])


ensure_aedifix()

from my_main_package import MyMainPackage # noqa: E402

from aedifix.main import basic_configure # noqa: E402


def main() -> int:
r"""Run configure.

Returns
-------
int
An integer error code, or 0 on success.
"""
return basic_configure(tuple(sys.argv[1:]), MyMainPackage)


if __name__ == "__main__":
sys.exit(main())
Loading