diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 5d65b547..38caad53 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.19.0 +current_version = 0.19.1 commit = True tag = True tag_name = {new_version} diff --git a/.github/workflows/check_optional_deps.yml b/.github/workflows/check_optional_deps.yml new file mode 100644 index 00000000..969fea4f --- /dev/null +++ b/.github/workflows/check_optional_deps.yml @@ -0,0 +1,38 @@ +name: Dependency check +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + dep_check: + name: dep_check + runs-on: ubuntu-latest + steps: + - name: Checkout main + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: 3.9 + + #---------------------------------------------- + # ----- install & configure poetry ----- + #---------------------------------------------- + - name: Install and configure Poetry + uses: snok/install-poetry@v1 + with: + version: 1.3.2 + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true + #---------------------------------------------- + # install your root project + #---------------------------------------------- + - name: install library + run: poetry install --only main + + - name: Check import + run: poetry run python -c "from anchorpy import Program" diff --git a/CHANGELOG.md b/CHANGELOG.md index b68ac3f0..6a4817d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [0.19.1] - 2024-02-12 + +### Fixed + +- Fix anchorpy import when no extras are included [#(136)](https://github.com/kevinheavey/anchorpy/pull/136) + ## [0.19.0] - 2024-02-12 ### Added diff --git a/pyproject.toml b/pyproject.toml index 73df2331..a06859dd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "anchorpy" -version = "0.19.0" +version = "0.19.1" description = "The Python Anchor client." readme = "README.md" repository = "https://github.com/kevinheavey/anchorpy" @@ -111,6 +111,7 @@ target-version = "py310" convention = "google" [tool.ruff.per-file-ignores] +"src/anchorpy/__init__.py" = ["F401"] "src/anchorpy/coder/*.py" = ["ARG002"] "src/anchorpy/borsh_extension.py" = ["ARG002"] "tests/**/*.py" = ["ARG001", "E501"] diff --git a/src/anchorpy/__init__.py b/src/anchorpy/__init__.py index 8478f0fd..5915e30b 100644 --- a/src/anchorpy/__init__.py +++ b/src/anchorpy/__init__.py @@ -1,4 +1,6 @@ """The Python Anchor client.""" +from contextlib import suppress as __suppress + from anchorpy_core.idl import Idl from anchorpy import error, utils @@ -16,20 +18,26 @@ from anchorpy.program.namespace.account import AccountClient, ProgramAccount from anchorpy.program.namespace.simulate import SimulateResponse from anchorpy.provider import Provider, Wallet -from anchorpy.pytest_plugin import bankrun_fixture, localnet_fixture, workspace_fixture from anchorpy.workspace import WorkspaceType, close_workspace, create_workspace -__all__ = [ +__has_pytest = False +with __suppress(ImportError): + from anchorpy.pytest_plugin import ( + bankrun_fixture, + localnet_fixture, + workspace_fixture, + ) + + __has_pytest = True + +__all_core = [ "Program", "Provider", "Context", - "bankrun_fixture", "create_workspace", "close_workspace", "Idl", - "workspace_fixture", "WorkspaceType", - "localnet_fixture", "Wallet", "Coder", "InstructionCoder", @@ -48,5 +56,15 @@ "utils", ] +__all__ = ( + [ + *__all_core, + "bankrun_fixture", + "localnet_fixture", + "workspace_fixture", + ] + if __has_pytest + else __all_core +) -__version__ = "0.19.0" +__version__ = "0.19.1"