-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
119 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
""" | ||
This CLI script is used to update the version of the package. It is used by the | ||
CI/CD pipeline to update the version of the package when a new release is made. | ||
It uses argparse to parse the command line arguments, which are the new version | ||
and the path to the package's __init__.py file. | ||
""" | ||
|
||
import argparse | ||
from pathlib import Path | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser( | ||
description="Update the version of the package." | ||
) | ||
parser.add_argument( | ||
"--version", | ||
type=str, | ||
help="The new version of the package.", | ||
required=True, | ||
) | ||
parser.add_argument( | ||
"--path", | ||
type=Path, | ||
help="The path to the package's version file.", | ||
) | ||
args = parser.parse_args() | ||
|
||
with open(args.path, "w") as f: | ||
f.write(f"__version__ = \"{args.version}\"") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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,46 @@ | ||
# This workflow will upload a Python Package using Twine when a release is created | ||
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries | ||
|
||
name: Publish Python Package | ||
|
||
on: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
bump-version-and-publish: | ||
name: Bump version and upload release to PyPI | ||
|
||
runs-on: ubuntu-latest | ||
permissions: | ||
# IMPORTANT: this permission is mandatory for trusted publishing | ||
id-token: write | ||
|
||
environment: | ||
name: pypi | ||
url: https://pypi.org/p/webllama | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Update version.py with release tag | ||
env: | ||
RELEASE_TAG: ${{ github.event.release.tag_name }} | ||
run: | | ||
python .github/scripts/python/update_version.py --version $RELEASE_TAG --path "webllama/version.py" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install setuptools wheel twine | ||
- name: Build package | ||
run: | | ||
python setup.py sdist bdist_wheel | ||
- name: Publish package distributions to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 |
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,37 @@ | ||
from setuptools import setup, find_packages | ||
|
||
package_name = "webllama" | ||
version = {} | ||
with open(f"{package_name}/version.py") as fp: | ||
exec(fp.read(), version) | ||
|
||
with open("README.md") as fp: | ||
long_description = fp.read() | ||
|
||
extras_require = { | ||
"dev": ["black"], | ||
} | ||
# Dynamically create the 'all' extra by combining all other extras | ||
extras_require["all"] = sum(extras_require.values(), []) | ||
|
||
setup( | ||
name=package_name, | ||
version=version["__version__"], | ||
author="Xing Han Lù", | ||
author_email=f"{package_name}@googlegroups.com", | ||
url=f"https://github.com/McGill-NLP/{package_name}", | ||
description="Llama-powered agents for automatic web browsing", | ||
long_description=long_description, | ||
packages=find_packages(include=[f"{package_name}*"]), | ||
package_data={}, | ||
install_requires=['scipy', 'numpy'], | ||
extras_require=extras_require, | ||
classifiers=[ | ||
"Programming Language :: Python :: 3", | ||
"License :: OSI Approved :: MIT License", | ||
"Operating System :: OS Independent", | ||
], | ||
python_requires=">=3.8", | ||
# Cast long description to markdown | ||
long_description_content_type="text/markdown", | ||
) |
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 @@ | ||
from .version import __version__ |
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 @@ | ||
__version__ = "0.0.1dev0" |