Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI test] Integrate secp256k1proto as subtree (using ugly import hack) #81

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

theStack
Copy link
Contributor

@theStack theStack commented Feb 5, 2025

This is a first approach of moving the secp256k1proto folder to an external package (living at https://github.com/theStack/secp256k1proto-playground currently, created with the uv package manager) and integrating it as git-subtree here [1]:

$ git subtree add --prefix=python/secp256k1proto --squash https://github.com/theStack/secp256k1proto-playground master

The import rename hack in the chilldkg_ref files to reflect the directory structure is ugly. Searching for alternatives currently.

[1] proposed solution 1 in https://groups.google.com/g/bitcoindev/c/HE3HSnGTpoQ

git-subtree-dir: python/secp256k1proto
git-subtree-split: 65263197f8d984107e7c8d3995fe3df02db78918
The replacements were done via

$ sed -i "s/from secp256k1proto/from secp256k1proto.src.secp256k1proto/" $(git ls-files)
@theStack theStack marked this pull request as draft February 6, 2025 00:08
@real-or-random
Copy link
Collaborator

Nice!

The import rename hack in the chilldkg_ref files to reflect the directory structure is ugly. Searching for alternatives currently.

I think you want something like this: https://github.com/BlockstreamResearch/bip-frost-dkg/tree/syspath, see https://docs.python.org/3/tutorial/modules.html#the-module-search-path for background. It's a bit low-level, but it does the job.

This makes it possible to execute these files without a package manager. Note that chilldkg_ref is still a python "package". It's just managed manually.

It may still make sense to switch to a proper package manager in the future, as long as we make sure that you can easily execute the example and the tests. I think uv makes this somewhat easy already, but it should also be possible to make it work without uv at all. Perhaps we could detect if we're running inside uv and make the sys.path modification conditional on that. Anyway, that's future stuff.

@real-or-random
Copy link
Collaborator

Ah, my branch still fails if you invoke a script which is not in the current working dir. This is the way to fix it: https://stackoverflow.com/a/8663119

Alternatively, we could simply tell the user to set the PYTHONPATH env variable, but I believe the sys.path thing is clean enough and it just works.

@theStack
Copy link
Contributor Author

theStack commented Feb 6, 2025

I think you want something like this: https://github.com/BlockstreamResearch/bip-frost-dkg/tree/syspath, see https://docs.python.org/3/tutorial/modules.html#the-module-search-path for background. It's a bit low-level, but it does the job.

Thanks, that was indeed pretty much what I was looking for (seeing it now, I remember that we use the same sys.path.insert... approach in Bitcoin Core for contrib scripts that need to access test framework modules, e.g. https://github.com/bitcoin/bitcoin/blob/d6c229d8bd4a6203a7255c140aa35c59fb20378b/contrib/signet/miner#L19).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants