-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
189 changed files
with
3,981 additions
and
5,170 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,68 @@ | ||
# | ||
# This workflow rebuilds documentation and stores the resulting patch as a | ||
# workflow artifact. We can then download the artifact, apply the patch, and | ||
# then push the changes. | ||
# | ||
# It's possible to do all this locally on a developer's machine, but it's not | ||
# trivial, because it requires many pre-requisites. | ||
# | ||
name: Rebuild documentation | ||
on: workflow_dispatch | ||
jobs: | ||
docs: | ||
name: Rebuild documentation | ||
timeout-minutes: 180 | ||
runs-on: ubuntu-20.04 | ||
defaults: | ||
run: | ||
shell: bash | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup up Python ${{ matrix.python }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
# | ||
# We use Py3.8 here for historical reasons. | ||
# | ||
python-version: "3.8" | ||
|
||
- name: Update pip | ||
run: python -m pip install -U pip | ||
|
||
- name: Install apt packages for LaTeX rendering | ||
run: | | ||
sudo apt-get -yq update | ||
sudo apt-get -yq remove texlive-binaries --purge | ||
sudo apt-get -yq --no-install-suggests --no-install-recommends --force-yes install dvipng texlive-latex-base texlive-latex-extra texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended latexmk | ||
sudo apt-get -yq install build-essential python3.8-dev | ||
- name: Install gensim and its dependencies | ||
run: pip install -e .[docs] | ||
|
||
- name: Build documentation | ||
run: | | ||
python setup.py build_ext --inplace | ||
make -C docs/src clean html | ||
- name: Check changes to prebuilt docs | ||
run: | | ||
git config user.email "noreply@github.com" | ||
git config user.name "Gensim Docs Build" | ||
if ! git diff --quiet @ ; then | ||
git add . | ||
branch="$GITHUB_HEAD_REF ($GITHUB_REF_NAME)" | ||
git commit -m "Import rebuilt documentation for branch $branch" | ||
git format-patch @^ | ||
git bundle create prebuilt-docs-changes.bundle @^...@ | ||
git reset --mixed @^ | ||
git diff --exit-code --stat @ | ||
fi | ||
- name: Upload prebuilt docs changes | ||
if: always() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: prebuilt-docs-changes | ||
path: | | ||
*.patch | ||
*.bundle |
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,35 @@ | ||
"""Install a wheel for the current platform.""" | ||
import os | ||
import platform | ||
import subprocess | ||
import sys | ||
|
||
|
||
def main(): | ||
subdir = sys.argv[1] | ||
vi = sys.version_info | ||
|
||
if platform.system() in ('Linux', 'Darwin'): | ||
arch = 'x86_64' | ||
else: | ||
arch = 'amd64' | ||
|
||
want = f'-cp{vi.major}{vi.minor}-' | ||
suffix = f'_{arch}.whl' | ||
|
||
files = sorted(os.listdir(subdir)) | ||
for f in files: | ||
if want in f and f.endswith(suffix): | ||
command = [sys.executable, '-m', 'pip', 'install', os.path.join(subdir, f)] | ||
subprocess.check_call(command) | ||
return 0 | ||
|
||
print(f'no matches for {want} / {suffix} in {subdir}:') | ||
print('\n'.join(files)) | ||
|
||
return 1 | ||
|
||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(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,76 @@ | ||
#!/usr/bin/env python | ||
"""Test a Gensim wheel stored on S3. | ||
Downloads the wheel, installs it into a fresh working environment, and then runs gensim tests. | ||
usage: | ||
python test_wheel.py <url> $(which python3.10) | ||
where the URL comes from http://gensim-wheels.s3-website-us-east-1.amazonaws.com/ | ||
""" | ||
|
||
import argparse | ||
import io | ||
import os | ||
import subprocess | ||
import tempfile | ||
import urllib.parse | ||
import urllib.request | ||
import shutil | ||
import sys | ||
|
||
curr_dir = os.path.dirname(os.path.abspath(__file__)) | ||
|
||
|
||
def run(*command, **kwargs): | ||
print("-" * 70, file=sys.stderr) | ||
print(" ".join(command), file=sys.stderr) | ||
print("-" * 70, file=sys.stderr) | ||
subprocess.check_call(command, **kwargs) | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("wheel_path", help="The location of the wheel. May be a URL or local path") | ||
parser.add_argument("python", help="Which python binary to use to test the wheel") | ||
parser.add_argument("--gensim-path", default=os.path.expanduser("~/git/gensim"), help="Where the gensim repo lives") | ||
parser.add_argument("--keep", action="store_true", help="Do not delete the sandbox after testing") | ||
parser.add_argument("--test", default="test", help="Specify which tests to run") | ||
args = parser.parse_args() | ||
|
||
_, python_version = subprocess.check_output([args.python, "--version"]).decode().strip().split(" ", 1) | ||
|
||
try: | ||
tmpdir = tempfile.mkdtemp(prefix=f"test_wheel-py{python_version}-") | ||
|
||
tmp_test_path = os.path.join(tmpdir, "test") | ||
shutil.copytree(os.path.join(args.gensim_path, "gensim/test"), tmp_test_path) | ||
|
||
if args.wheel_path.startswith("http://") or args.wheel_path.startswith("https://"): | ||
parsed = urllib.parse.urlparse(args.wheel_path) | ||
filename = parsed.path.split('/')[-1] | ||
wheel_path = os.path.join(tmpdir, filename) | ||
urllib.request.urlretrieve(args.wheel_path, wheel_path) | ||
else: | ||
wheel_path = args.wheel_path | ||
|
||
env_path = os.path.join(tmpdir, "env") | ||
run("virtualenv", "-p", args.python, env_path) | ||
|
||
python_exe = os.path.join(tmpdir, "env/bin/python") | ||
run(python_exe, "-m", "pip", "install", wheel_path) | ||
run(python_exe, "-m", "pip", "install", "mock", "pytest", "testfixtures") | ||
|
||
pytest_exe = os.path.join(tmpdir, "env/bin/pytest") | ||
run(pytest_exe, "-vvv", args.test, "--durations", "0", cwd=tmpdir) | ||
finally: | ||
if args.keep: | ||
print(f"keeping {tmpdir}, remove it yourself when done") | ||
else: | ||
shutil.rmtree(tmpdir) | ||
|
||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.