user56197: I need a python script to verify, in an air gapped system, that my 24-word (or 12-word) mnemonic seed indeed generates the xpub that my wallet is showing me.
Is there a simple script that does that, having minimal dependencies?
UPDATE:
based on the answer below using https://github.com/trezor/python-mnemonic, I did
def main() -> None:
    import sys
    m = Mnemonic("english")
    seed = Mnemonic.to_seed("my 12 words")
    pubkey = Mnemonic.to_hd_master_key(seed)
    print(pubkey)

but I get
xprv...

and no pubkey.
How do I get the master pub key?

user100690: Yes, I'd say the simplest way is to use python bip39 implementation of trezor, this one file should be enough with methods:
to_seed - to convert list of the words into seed and
to_hd_master_key - to generate master xpub/xpriv
It doesn't support further derivations (which require a bit more dependencies), for which I'd suggest using bip32 library.

user98139: The following code using the python-bip32 lib can show this information.
from bip32 import BIP32, HARDENED_INDEX

bip32 = BIP32.from_seed(bytes.fromhex("01"))

# get master xpriv and xpub
master_xpriv = bip32.get_master_xpriv()
master_xpub = bip32.get_master_xpub()

print("master_xpriv: " + master_xpriv)
print("master_xpub: " + master_xpub)

# get from specif path 
xpriv_from_path = bip32.get_xpriv_from_path("m/84'/0'/0'/0/1")
xpub_from_path = bip32.get_xpub_from_path("m/84'/0'/0'/0/1")

print("xpriv_from_path: " + xpriv_from_path)
print("xpub_from_path: " + xpub_from_path)


user76567: Using this library which is a pure python library with no dependencies (disclaimer: I am the author)
>>> from cryptotools import Xprv

>>> xprv = Xprv.from_mnemonic('assist excess fox blossom trouble cry must segment arrive stereo weather april pudding tuna change')

>>> xpub = xprv.to_xpub()

>>> xpub.encode()
'xpub661MyMwAqRbcGSaJ8ymCnwWbZzUgRB9XSAGoAvJc92oorJqzfyTPNQCEzqetVjofVs6DjXEPgR62vGP8UsSL4HFXLcRHdBbcDZ7DgyZea59'


56197: <p>I need a python script to verify, in an air gapped system, that my 24-word (or 12-word) mnemonic seed indeed generates the xpub that my wallet is showing me.</p>
<p>Is there a simple script that does that, having minimal dependencies?</p>
<p><strong>UPDATE:</strong></p>
<p>based on the answer below using <a href="https://github.com/trezor/python-mnemonic" rel="nofollow noreferrer">https://github.com/trezor/python-mnemonic</a>, I did</p>
<pre><code>def main() -&gt; None:
    import sys
    m = Mnemonic(&quot;english&quot;)
    seed = Mnemonic.to_seed(&quot;my 12 words&quot;)
    pubkey = Mnemonic.to_hd_master_key(seed)
    print(pubkey)
</code></pre>
<p>but I get</p>
<pre><code>xprv...
</code></pre>
<p>and no pubkey.</p>
<p>How do I get the master pub key?</p>
 100690: <p>Yes, I'd say the simplest way is to use python bip39 implementation of trezor, this <a href="https://github.com/trezor/python-mnemonic/blob/master/mnemonic/mnemonic.py" rel="nofollow noreferrer">one file</a> should be enough with methods:</p>
<p><code>to_seed</code> - to convert list of the words into seed and</p>
<p><code>to_hd_master_key</code> - to generate master xpub/xpriv</p>
<p>It doesn't support further derivations (which require a bit more dependencies), for which I'd suggest using <a href="https://github.com/darosior/python-bip32/blob/master/bip32/bip32.py" rel="nofollow noreferrer">bip32</a> library.</p>
 98139: <p>The following code using the <a href="https://github.com/darosior/python-bip32" rel="nofollow noreferrer">python-bip32</a> lib can show this information.</p>
<pre><code>from bip32 import BIP32, HARDENED_INDEX

bip32 = BIP32.from_seed(bytes.fromhex(&quot;01&quot;))

# get master xpriv and xpub
master_xpriv = bip32.get_master_xpriv()
master_xpub = bip32.get_master_xpub()

print(&quot;master_xpriv: &quot; + master_xpriv)
print(&quot;master_xpub: &quot; + master_xpub)

# get from specif path 
xpriv_from_path = bip32.get_xpriv_from_path(&quot;m/84'/0'/0'/0/1&quot;)
xpub_from_path = bip32.get_xpub_from_path(&quot;m/84'/0'/0'/0/1&quot;)

print(&quot;xpriv_from_path: &quot; + xpriv_from_path)
print(&quot;xpub_from_path: &quot; + xpub_from_path)
</code></pre>
 76567: <p>Using <a href="https://github.com/mcdallas/cryptotools" rel="nofollow noreferrer">this</a> library which is a pure python library with no dependencies (disclaimer: I am the author)</p>
<pre><code>&gt;&gt;&gt; from cryptotools import Xprv

&gt;&gt;&gt; xprv = Xprv.from_mnemonic('assist excess fox blossom trouble cry must segment arrive stereo weather april pudding tuna change')

&gt;&gt;&gt; xpub = xprv.to_xpub()

&gt;&gt;&gt; xpub.encode()
'xpub661MyMwAqRbcGSaJ8ymCnwWbZzUgRB9XSAGoAvJc92oorJqzfyTPNQCEzqetVjofVs6DjXEPgR62vGP8UsSL4HFXLcRHdBbcDZ7DgyZea59'
</code></pre>
