eprbell / rp2

Privacy-focused, free, open-source cryptocurrency tax calculator for multiple countries: it handles multiple coins/exchanges and computes long/short-term capital gains, cost bases, in/out lot relationships/fractioning, and account balances. It supports FIFO, LIFO, HIFO and it outputs in form 8949 format. It has a programmable plugin architecture
https://pypi.org/project/rp2/
Apache License 2.0
256 stars 42 forks source link

Add note about `mpdecimal` requirement on some Unix platforms #108

Closed antonok-edm closed 3 months ago

antonok-edm commented 3 months ago

https://github.com/eprbell/rp2/issues/25#issuecomment-2008647693

mpdecimal can't really be added as a dependency of RP2 since it's a system library rather than a Python package, but at least we can document it in the installation/setup instructions.

antonok-edm commented 3 months ago

Potentially, another option is to include a check like this during some initialization routine:

try:
    from _decimal import *
except ImportError:
    print(MPDECIMAL_NOT_AVAILABLE_WARNING)
    sys.exit(-1)
eprbell commented 3 months ago

Potentially, another option is to include a check like this during some initialization routine:

try:
    from _decimal import *
except ImportError:
    print(MPDECIMAL_NOT_AVAILABLE_WARNING)
    sys.exit(-1)

I think this is a good approach. It could go here: https://github.com/eprbell/rp2/blob/main/src/rp2/rp2_main.py#L70. The only changes needed are:

Then I think we no longer need the changes to the README files.

antonok-edm commented 3 months ago

updated!

I also changed the import to as _ to avoid polluting the namespace.