Skip to content

Commit 2badedc

Browse files
authored
fix: Support new way AnyBody 8.0.3 stores it's registry keys (#112)
* fix: Support the new way AnyBody 8.0.1 stores the registry keys * Run ruff/isort * Update version * Update docs build environment * update lock file * Add pytest to docs build environmenton * fix typo * Add anyboydcon as dependency when testing on windows
1 parent c865273 commit 2badedc

File tree

6 files changed

+6738
-1523
lines changed

6 files changed

+6738
-1523
lines changed

.github/workflows/docs.yaml

+75-31
Original file line numberDiff line numberDiff line change
@@ -14,48 +14,92 @@ concurrency:
1414
cancel-in-progress: true
1515

1616
jobs:
17-
sphinx-build:
17+
build-latest-docs:
1818
runs-on: ubuntu-latest
19-
if: "!contains(github.event.head_commit.message, '[skip ci]')"
2019

2120
steps:
22-
- uses: actions/checkout@v2
21+
- uses: actions/checkout@v4
2322

24-
- name: Install mamba
25-
uses: mamba-org/setup-micromamba@main
23+
- uses: prefix-dev/[email protected]
2624
with:
27-
environment-file: docs/environment.yml
28-
29-
- name: Build anypytools
30-
shell: bash -l {0}
31-
run: pip install .
25+
environments: docs
26+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'master' }}
27+
activate-environment: docs
3228

3329
- name: Build Documentation
34-
shell: bash -l {0}
3530
run: |
3631
set -e
3732
cd docs
38-
make html-dev
33+
sphinx-build -M html . _build -W --keep-going -a -t DEV_BUILD
3934
cd ..
40-
mkdir -p public/dev
41-
cp -rT docs/_build/html public/dev
42-
43-
- name: Build last tagged version
44-
if: github.ref == 'refs/heads/master'
45-
shell: bash -l {0}
35+
36+
- uses: actions/upload-artifact@v4
37+
with:
38+
name: dev-version
39+
path: docs/_build/html
40+
41+
42+
43+
build-tagged-docs:
44+
runs-on: ubuntu-latest
45+
46+
steps:
47+
- uses: actions/checkout@v4
48+
with:
49+
fetch-depth: 0
50+
51+
# - name: Checkout last tagged version
52+
# run: |
53+
# git checkout $(git describe --tags `git rev-list --tags --max-count=1`);
54+
55+
- uses: prefix-dev/[email protected]
56+
with:
57+
environments: docs
58+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'master' }}
59+
activate-environment: docs
60+
61+
- name: Build Documentation
4662
run: |
47-
git checkout $(git describe --tags `git rev-list --tags --max-count=1`);
4863
cd docs
49-
make clean
50-
make html
51-
cd ..
52-
cp -rT docs/_build/html public
53-
54-
- name: Deploy 🚀
55-
if: github.ref == 'refs/heads/master'
56-
uses: peaceiris/actions-gh-pages@v3
64+
sphinx-build -M html . _build -a
65+
66+
- uses: actions/upload-artifact@v4
67+
with:
68+
name: tagged-version
69+
path: docs/_build/html
70+
71+
72+
prepare-pages:
73+
needs: [build-latest-docs, build-tagged-docs]
74+
runs-on: ubuntu-latest
75+
steps:
76+
- uses: actions/download-artifact@v4
5777
with:
58-
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
59-
external_repository: AnyBody-Research-Group/anypytools-docs
60-
publish_branch: gh-pages
61-
publish_dir: ./public
78+
name: tagged-version
79+
path: public
80+
- uses: actions/download-artifact@v4
81+
with:
82+
name: dev-version
83+
path: public/dev
84+
- uses: actions/upload-pages-artifact@v3
85+
with:
86+
path: public
87+
88+
deploy:
89+
needs: prepare-pages
90+
if: github.ref == 'refs/heads/master'
91+
runs-on: ubuntu-latest
92+
permissions:
93+
pages: write
94+
id-token: write
95+
96+
environment:
97+
name: github-pages
98+
url: ${{ steps.deployment.outputs.page_url }}
99+
100+
steps:
101+
- name: Deploy to GitHub Pages
102+
id: deployment
103+
uses: actions/deploy-pages@v4
104+
105+

.github/workflows/test.yml

+11-15
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,14 @@ jobs:
2727
steps:
2828
- uses: actions/checkout@v4
2929

30-
- uses: prefix-dev/setup-pixi@v0.5.1
30+
- uses: prefix-dev/setup-pixi@v0.7.0
3131
with:
32-
post-cleanup: true
33-
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
34-
35-
- name: build
36-
run: pixi run --frozen pip install .
37-
32+
environments: test
33+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'master' }}
34+
activate-environment: test
35+
3836
- name: Test with pytest
39-
run: pixi run --frozen pytest tests
37+
run: pytest tests
4038
env:
4139
RLM_LICENSE_PASSWORD: ${{ secrets.LICENSE_PASSWORD }}
4240
RLM_LICENSE: ${{ secrets.LICENSE_SERVER }}
@@ -51,16 +49,14 @@ jobs:
5149
steps:
5250
- uses: actions/checkout@v4
5351

54-
- uses: prefix-dev/setup-pixi@v0.5.1
52+
- uses: prefix-dev/setup-pixi@v0.7.0
5553
with:
56-
post-cleanup: true
57-
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
58-
59-
- name: build
60-
run: pixi run --frozen pip install .
54+
environments: test
55+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'master' }}
56+
activate-environment: test
6157

6258
- name: test
6359
env:
6460
RLM_LICENSE_PASSWORD: ${{ secrets.LICENSE_PASSWORD }}
6561
RLM_LICENSE: ${{ secrets.LICENSE_SERVER }}
66-
run: pixi run --frozen pytest tests
62+
run: pytest tests

anypytools/__init__.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
# -*- coding: utf-8 -*-
22
"""AnyPyTools library."""
3+
import logging
34
import os
4-
import sys
55
import platform
6-
import logging
6+
import sys
77

88
if "FOR_DISABLE_CONSOLE_CTRL_HANDLER" not in os.environ:
99
os.environ["FOR_DISABLE_CONSOLE_CTRL_HANDLER"] = "1"
1010

11+
from anypytools import macro_commands
1112
from anypytools.abcutils import AnyPyProcess, execute_anybodycon
1213
from anypytools.macroutils import AnyMacro
13-
from anypytools import macro_commands
1414
from anypytools.tools import (
1515
ABOVE_NORMAL_PRIORITY_CLASS,
1616
BELOW_NORMAL_PRIORITY_CLASS,
1717
IDLE_PRIORITY_CLASS,
1818
NORMAL_PRIORITY_CLASS,
1919
)
2020

21-
2221
logger = logging.getLogger("abt.anypytools")
2322
logger.addHandler(logging.NullHandler())
2423

@@ -37,7 +36,7 @@
3736
"NORMAL_PRIORITY_CLASS",
3837
]
3938

40-
__version__ = "1.11.5"
39+
__version__ = "1.11.6"
4140

4241

4342
def print_versions():

anypytools/tools.py

+21-16
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,27 @@
66
"""
77
from __future__ import annotations
88

9-
import os
10-
import re
11-
import sys
12-
import xml
9+
import collections
1310
import copy
11+
import datetime
1412
import errno
15-
import shutil
13+
import functools
1614
import logging
17-
import textwrap
18-
import datetime
19-
import warnings
15+
import os
2016
import platform
21-
import functools
22-
import subprocess
23-
import collections
2417
import pprint
18+
import re
19+
import shutil
20+
import subprocess
21+
import sys
22+
import textwrap
23+
import warnings
24+
import xml
25+
from _thread import get_ident as _get_ident
2526
from ast import literal_eval
26-
from pathlib import Path
2727
from contextlib import suppress
2828
from dataclasses import dataclass
29-
from _thread import get_ident as _get_ident
30-
29+
from pathlib import Path
3130
from typing import Any, Iterable
3231

3332
# external imports
@@ -527,10 +526,16 @@ def _expand_short_path_name(short_path_name):
527526
def lookup_anybody_in_registry() -> str | None:
528527
import winreg
529528

529+
try:
530+
anybodykey = winreg.QueryValue(winreg.HKEY_CLASSES_ROOT, ".any")
531+
except OSError:
532+
anybodykey = "AnyBody.any"
533+
530534
keys_to_try = [
531-
"AnyBody.any\\shell\\open\\command",
535+
f"{anybodykey}\\shell\\open\\command",
532536
"AnyBody.AnyScript\\shell\\open\\command",
533537
]
538+
534539
for key in keys_to_try:
535540
try:
536541
value = winreg.QueryValue(winreg.HKEY_CLASSES_ROOT, key)
@@ -716,7 +721,7 @@ def _get_index_length(self, index_var="auto"):
716721
timevars = [var for var in self if var.endswith("Output.Abscissa.t")]
717722
if len(timevars) > 1:
718723
raise ValueError(
719-
f"Multiple time variables found. Use 'index_var' argument to indicate which to use."
724+
"Multiple time variables found. Use 'index_var' argument to indicate which to use."
720725
)
721726
if len(timevars) == 0:
722727
raise ValueError(

0 commit comments

Comments
 (0)