mbonig / state-machine

a CDK construct for Step Functions State Machines that allows for easy integration with Workflow Studio
MIT License
40 stars 4 forks source link

Python Package unable to import `mbonig.state_machine` #37

Closed TonySherman closed 9 months ago

TonySherman commented 9 months ago

After upgrading the python aws-cdk-lib and mbonig.state-machine, I am unable to import mbonig.state_machine

I get the following error:

Python 3.10.7 (main, Dec 26 2022, 22:28:38) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import mbonig.state_machine
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'mbonig.state_machine'

I installed only mbonig.state-machine in a clean venv with pip install mbonig.state-machine. The following packages are installed as a result:

Package                           Version
--------------------------------- --------
attrs                             23.2.0
aws-cdk.asset-awscli-v1           2.2.201
aws-cdk.asset-kubectl-v20         2.1.2
aws-cdk.asset-node-proxy-agent-v6 2.0.1
aws-cdk-lib                       2.118.0
cattrs                            23.2.3
constructs                        10.3.0
exceptiongroup                    1.2.0
importlib-resources               6.1.1
jsii                              1.93.0
mbonig.state-machine              0.0.32
pip                               22.2.2
projen                            0.71.163
publication                       0.0.3
python-dateutil                   2.8.2
setuptools                        63.2.0
six                               1.16.0
typeguard                         2.13.3
typing_extensions                 4.9.0
mikejgray commented 9 months ago

For whatever reason, JSII is outputting Python modules that use non-compliant naming schemes. Ideally that should be fixed, but here's a workaround:

import importlib
mbonig_state_machine = importlib.import_module("mbonig.state-machine")

You'll have access to everything in the library by referencing mbonig_state_machine.

mbonig commented 9 months ago

I've pushed an update that should fixing the naming. Can you try again with version 0.0.10?

TonySherman commented 9 months ago

Thanks for the quick response!

Updated to mbonig.state-machine 0.0.33 from PyPI and things are working again! Just noting that the import name is now mbonig_state_machine rather than mbonig.state_machine. Easy to switch that. Just noting it here for visibility.