-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* improvements to the publish script * move scripts * initial script that builds the package * adjustments on the docs * test pypi workflow * add hour and minute to version * black * ruff * duplicate file * moving files instead * build throught the script instead * update nox file * integration tests workflow * change workflow * fix dev_install * fix in sed cmd * testing the platform only * commenting out the publishing * fix run commands * improvements to the publish script and doc * fix publish script * updating the script and the workflow * feature/v4-pypi nightly (#5589) * init * Update nightly.py * cleanup * init file * not referencing dev_utils * updating obb platform key * revert * Increase warmup time * project name on pyproject and adding the --pre flag on readme * moving to the build folder * fix noxfile * reflecting the moves on the import statements * fix pyproject path * ruff * fix paths * fix super typo * update workflows * moving the pypi terminal files into its folder --------- Co-authored-by: teh_coderer <[email protected]> Co-authored-by: Igor Radovanovic <[email protected]> Co-authored-by: Theodore Aptekarev <[email protected]>
- Loading branch information
1 parent
8e6967b
commit 3b8004c
Showing
17 changed files
with
273 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: Deploy the OpenBB Platform and the OpenBBTerminal to Test PyPI | ||
|
||
on: | ||
push: | ||
branches: | ||
- feature/v4-pypi | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
deploy-test-pypi: | ||
name: Build and publish 📦 to TestPyPI | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup Python 3.9 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.9" | ||
|
||
- name: Install pypa/build | ||
run: >- | ||
python -m | ||
pip install | ||
build | ||
--user | ||
- name: OpenBBTerminal - Update version in pyproject.toml and Edit docs | ||
run: | | ||
sed -i 's/name = ".*"/name = "openbb-terminal-nightly"/' pyproject.toml | ||
sed -i "3s/version = \"\(.*\)\"/version = \"\1.dev$(date +%Y%m%d%H%M)\"/" pyproject.toml | ||
sed -i 's|pip install openbb-terminal|pip install openbb-terminal-nightly|g' ./website/pypi.md | ||
- name: OpenBBTerminal - Build a binary wheel and a source tarball | ||
run: >- | ||
python -m | ||
build | ||
--sdist | ||
--wheel | ||
--outdir dist/ | ||
. | ||
- name: OpenBBTerminal - Publish distribution 📦 to Test PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
packages-dir: dist/ | ||
password: ${{ secrets.TEST_PYPI_API_TOKEN_OBB_TERMINAL_NIGHTLY }} | ||
repository-url: https://test.pypi.org/legacy/ | ||
|
||
- name: OpenBB Platform - Update version in pyproject.toml and Edit docs | ||
run: | | ||
sed -i 's/name = ".*"/name = "openbb-nightly"/' openbb_platform/pyproject.toml | ||
sed -i "3s/version = \"\(.*\)\"/version = \"\1.dev$(date +%Y%m%d%H%M)\"/" openbb_platform/pyproject.toml | ||
- name: OpenBB Platform - Create the dinamically generated wheel | ||
run: | | ||
python -m pip install poetry toml | ||
python build/pypi/openbb_platform/nightly.py | ||
- name: OpenBB Platform - Publish distribution 📦 to Test PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
packages-dir: openbb_platform/dist/ | ||
password: ${{ secrets.TEST_PYPI_API_TOKEN_OBB_PLATFORM_NIGHTLY }} | ||
repository-url: https://test.pypi.org/legacy/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import subprocess | ||
import sys | ||
from pathlib import Path | ||
from typing import Any, Dict | ||
|
||
import toml | ||
|
||
PLATFORM_PATH = Path(__file__).parent.parent.parent.parent.resolve() / "openbb_platform" | ||
PYPROJECT = PLATFORM_PATH / "pyproject.toml" | ||
|
||
SUB_PACKAGES = {} | ||
DEPENDENCIES: Dict[str, Any] = {} | ||
PLUGINS = {"openbb_core_extension": {}, "openbb_provider_extension": {}} | ||
CMD = [sys.executable, "-m", "poetry", "build"] | ||
|
||
|
||
PYPROJECT_TOML = toml.load(PYPROJECT) | ||
POETRY_DICT: Dict[str, dict] = PYPROJECT_TOML["tool"]["poetry"] | ||
POETRY_DICT.pop("extras", None) | ||
|
||
|
||
original_pyproject = PYPROJECT.read_text() | ||
|
||
|
||
def gather_metadata(sub_path: str): | ||
"""Gather metadata from the pyproject.toml files. | ||
Parameters | ||
---------- | ||
sub_path : str | ||
The path to the sub packages. | ||
""" | ||
for path in PLATFORM_PATH.rglob(f"{sub_path}/**/pyproject.toml"): | ||
pyproject_toml = toml.load(path) | ||
poetry_dict: Dict[str, dict] = pyproject_toml["tool"]["poetry"] | ||
package_name = poetry_dict["packages"][0]["include"] | ||
|
||
for extension in list(PLUGINS.keys()): | ||
PLUGINS[extension].update(poetry_dict.get("plugins", {}).get(extension, {})) | ||
|
||
DEPENDENCIES.update(pyproject_toml["tool"]["poetry"]["dependencies"]) | ||
SUB_PACKAGES[package_name] = path.relative_to(PLATFORM_PATH).parent.as_posix() | ||
|
||
|
||
def build(): | ||
"""Build the Platform package.""" | ||
for sub_path in ["platform", "providers", "extensions"]: | ||
gather_metadata(sub_path) | ||
|
||
# need to pop these from the dependencies | ||
DEPENDENCIES.pop("openbb-core", None) | ||
DEPENDENCIES.pop("openbb-provider", None) | ||
|
||
# add the sub packages | ||
for package_name, path in SUB_PACKAGES.items(): | ||
POETRY_DICT["packages"].append({"include": package_name, "from": f"./{path}"}) | ||
|
||
# add the plugins extensions | ||
for extension, plugins in PLUGINS.items(): | ||
POETRY_DICT.setdefault("plugins", {}).setdefault(extension, {}).update(plugins) | ||
|
||
# update the dependencies and platform poetry dict | ||
POETRY_DICT["dependencies"] = DEPENDENCIES | ||
PYPROJECT_TOML["tool"]["poetry"] = POETRY_DICT | ||
|
||
temp_pyproject = toml.dumps(PYPROJECT_TOML) | ||
|
||
try: | ||
with open(PYPROJECT, "w", encoding="utf-8", newline="\n") as f: | ||
f.write(temp_pyproject) | ||
|
||
subprocess.run(CMD, cwd=PLATFORM_PATH, check=True) # noqa: S603,PLW1510 | ||
except (Exception, KeyboardInterrupt) as e: | ||
print(e) # noqa: T201 | ||
print("Restoring pyproject.toml") # noqa: T201 | ||
|
||
# we restore the original pyproject.toml | ||
with open(PYPROJECT, "w", encoding="utf-8", newline="\n") as f: | ||
f.write(original_pyproject) | ||
|
||
|
||
if __name__ == "__main__": | ||
build() |
20 changes: 10 additions & 10 deletions
20
openbb_platform/poetry_update.py → build/pypi/openbb_platform/poetry_update.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import subprocess | ||
import sys | ||
from pathlib import Path | ||
|
||
PLATFORM_PATH = Path(__file__).parent.resolve() / "openbb_platform" | ||
|
||
SUB_PACKAGES = ["platform/provider", "platform/core", "extensions", "providers"] | ||
|
||
CMD = [sys.executable, "-m", "poetry"] | ||
VERSION_BUMP_CMD = ["version", "prerelease"] | ||
PUBLISH_CMD = ["publish", "--build"] | ||
|
||
|
||
def run_cmds(directory: Path): | ||
"""Run the commands for publishing""" | ||
print(f"Publishing: {directory.name}") # noqa: T201 | ||
|
||
subprocess.run(CMD + VERSION_BUMP_CMD, cwd=directory, check=True) # noqa: S603 | ||
subprocess.run(CMD + PUBLISH_CMD, cwd=directory, check=True) # noqa: S603 | ||
|
||
|
||
def publish(): | ||
"""Publish the Platform to PyPi""" | ||
for sub_path in SUB_PACKAGES: | ||
for path in PLATFORM_PATH.rglob(f"{sub_path}/**/pyproject.toml"): | ||
run_cmds(path.parent) | ||
|
||
# openbb | ||
run_cmds(PLATFORM_PATH) | ||
|
||
|
||
if __name__ == "__main__": | ||
raise Exception( | ||
"If you're ar running this script for the first time," | ||
"ensure you have changed `VERSION` on System Settings " | ||
"before you publish the `openbb-core` package to Pypi." | ||
) | ||
|
||
publish() |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.