ipfs-node 0.1.8__tar.gz → 0.1.11__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/LICENSE +4 -7
  2. ipfs_node-0.1.11/LICENSE-CC0 +121 -0
  3. {ipfs_node-0.1.8/src/ipfs_node.egg-info → ipfs_node-0.1.11}/PKG-INFO +73 -7
  4. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/README.md +61 -4
  5. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/setup.py +19 -29
  6. {ipfs_node-0.1.8 → ipfs_node-0.1.11/src/ipfs_node.egg-info}/PKG-INFO +73 -7
  7. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/src/ipfs_node.egg-info/SOURCES.txt +5 -1
  8. ipfs_node-0.1.8/src/libkubo/libkubo_android_arm64.so → ipfs_node-0.1.11/src/libkubo/libkubo_linux_arm64.so +0 -0
  9. ipfs_node-0.1.11/src/libkubo/libkubo_linux_x86_64.h +237 -0
  10. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/src/libkubo/libkubo_linux_x86_64.so +0 -0
  11. ipfs_node-0.1.11/src/libkubo/libkubo_loader.py +88 -0
  12. ipfs_node-0.1.11/src/libkubo/libkubo_windows_x86_64.dll +0 -0
  13. ipfs_node-0.1.11/src/libkubo/libkubo_windows_x86_64.h +237 -0
  14. ipfs_node-0.1.8/src/libkubo/libkubo_loader.py +0 -45
  15. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/INSTALL.md +0 -0
  16. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/MANIFEST.in +0 -0
  17. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/examples/basic_usage.py +0 -0
  18. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/examples/chat_app.py +0 -0
  19. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/examples/file_sharing.py +0 -0
  20. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/examples/p2p_example.py +0 -0
  21. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/examples/p2p_socket_example.py +0 -0
  22. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/examples/pubsub_example.py +0 -0
  23. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/examples/pubsub_simple_test.py +0 -0
  24. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/setup.cfg +0 -0
  25. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/src/ipfs_node/__init__.py +0 -0
  26. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/src/ipfs_node/ipfs_files.py +0 -0
  27. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/src/ipfs_node/ipfs_node.py +0 -0
  28. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/src/ipfs_node/ipfs_peers.py +0 -0
  29. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/src/ipfs_node/ipfs_pubsub.py +0 -0
  30. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/src/ipfs_node/ipfs_tunnels.py +0 -0
  31. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/src/ipfs_node/utils/__init__.py +0 -0
  32. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/src/ipfs_node/utils/cid_utils.py +0 -0
  33. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/src/ipfs_node/utils/peer_utils.py +0 -0
  34. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/src/ipfs_node.egg-info/dependency_links.txt +0 -0
  35. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/src/ipfs_node.egg-info/requires.txt +0 -0
  36. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/src/ipfs_node.egg-info/top_level.txt +0 -0
  37. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/src/libkubo/__init__.py +0 -0
  38. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/src/libkubo/libkubo_android_arm64.h +0 -0
  39. /ipfs_node-0.1.8/src/libkubo/libkubo_linux_x86_64.h → /ipfs_node-0.1.11/src/libkubo/libkubo_linux_arm64.h +0 -0
  40. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/tests/test_all.py +0 -0
  41. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/tests/test_peers.py +0 -0
  42. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/tests/test_pubsub.py +0 -0
  43. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/tests/test_tunnels.py +0 -0
  44. {ipfs_node-0.1.8 → ipfs_node-0.1.11}/tests/test_utils.py +0 -0
@@ -1,16 +1,13 @@
1
- MIT License
1
+ MIT No Attribution
2
2
 
3
- Copyright (c) 2025
3
+ Copyright [year] [fullname]
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
7
7
  in the Software without restriction, including without limitation the rights
8
8
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
9
  copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
10
+ furnished to do so.
14
11
 
15
12
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
13
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
@@ -18,4 +15,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
15
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
16
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
17
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
18
+ SOFTWARE.
@@ -0,0 +1,121 @@
1
+ Creative Commons Legal Code
2
+
3
+ CC0 1.0 Universal
4
+
5
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6
+ LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9
+ REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10
+ PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11
+ THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12
+ HEREUNDER.
13
+
14
+ Statement of Purpose
15
+
16
+ The laws of most jurisdictions throughout the world automatically confer
17
+ exclusive Copyright and Related Rights (defined below) upon the creator
18
+ and subsequent owner(s) (each and all, an "owner") of an original work of
19
+ authorship and/or a database (each, a "Work").
20
+
21
+ Certain owners wish to permanently relinquish those rights to a Work for
22
+ the purpose of contributing to a commons of creative, cultural and
23
+ scientific works ("Commons") that the public can reliably and without fear
24
+ of later claims of infringement build upon, modify, incorporate in other
25
+ works, reuse and redistribute as freely as possible in any form whatsoever
26
+ and for any purposes, including without limitation commercial purposes.
27
+ These owners may contribute to the Commons to promote the ideal of a free
28
+ culture and the further production of creative, cultural and scientific
29
+ works, or to gain reputation or greater distribution for their Work in
30
+ part through the use and efforts of others.
31
+
32
+ For these and/or other purposes and motivations, and without any
33
+ expectation of additional consideration or compensation, the person
34
+ associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35
+ is an owner of Copyright and Related Rights in the Work, voluntarily
36
+ elects to apply CC0 to the Work and publicly distribute the Work under its
37
+ terms, with knowledge of his or her Copyright and Related Rights in the
38
+ Work and the meaning and intended legal effect of CC0 on those rights.
39
+
40
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
41
+ protected by copyright and related or neighboring rights ("Copyright and
42
+ Related Rights"). Copyright and Related Rights include, but are not
43
+ limited to, the following:
44
+
45
+ i. the right to reproduce, adapt, distribute, perform, display,
46
+ communicate, and translate a Work;
47
+ ii. moral rights retained by the original author(s) and/or performer(s);
48
+ iii. publicity and privacy rights pertaining to a person's image or
49
+ likeness depicted in a Work;
50
+ iv. rights protecting against unfair competition in regards to a Work,
51
+ subject to the limitations in paragraph 4(a), below;
52
+ v. rights protecting the extraction, dissemination, use and reuse of data
53
+ in a Work;
54
+ vi. database rights (such as those arising under Directive 96/9/EC of the
55
+ European Parliament and of the Council of 11 March 1996 on the legal
56
+ protection of databases, and under any national implementation
57
+ thereof, including any amended or successor version of such
58
+ directive); and
59
+ vii. other similar, equivalent or corresponding rights throughout the
60
+ world based on applicable law or treaty, and any national
61
+ implementations thereof.
62
+
63
+ 2. Waiver. To the greatest extent permitted by, but not in contravention
64
+ of, applicable law, Affirmer hereby overtly, fully, permanently,
65
+ irrevocably and unconditionally waives, abandons, and surrenders all of
66
+ Affirmer's Copyright and Related Rights and associated claims and causes
67
+ of action, whether now known or unknown (including existing as well as
68
+ future claims and causes of action), in the Work (i) in all territories
69
+ worldwide, (ii) for the maximum duration provided by applicable law or
70
+ treaty (including future time extensions), (iii) in any current or future
71
+ medium and for any number of copies, and (iv) for any purpose whatsoever,
72
+ including without limitation commercial, advertising or promotional
73
+ purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74
+ member of the public at large and to the detriment of Affirmer's heirs and
75
+ successors, fully intending that such Waiver shall not be subject to
76
+ revocation, rescission, cancellation, termination, or any other legal or
77
+ equitable action to disrupt the quiet enjoyment of the Work by the public
78
+ as contemplated by Affirmer's express Statement of Purpose.
79
+
80
+ 3. Public License Fallback. Should any part of the Waiver for any reason
81
+ be judged legally invalid or ineffective under applicable law, then the
82
+ Waiver shall be preserved to the maximum extent permitted taking into
83
+ account Affirmer's express Statement of Purpose. In addition, to the
84
+ extent the Waiver is so judged Affirmer hereby grants to each affected
85
+ person a royalty-free, non transferable, non sublicensable, non exclusive,
86
+ irrevocable and unconditional license to exercise Affirmer's Copyright and
87
+ Related Rights in the Work (i) in all territories worldwide, (ii) for the
88
+ maximum duration provided by applicable law or treaty (including future
89
+ time extensions), (iii) in any current or future medium and for any number
90
+ of copies, and (iv) for any purpose whatsoever, including without
91
+ limitation commercial, advertising or promotional purposes (the
92
+ "License"). The License shall be deemed effective as of the date CC0 was
93
+ applied by Affirmer to the Work. Should any part of the License for any
94
+ reason be judged legally invalid or ineffective under applicable law, such
95
+ partial invalidity or ineffectiveness shall not invalidate the remainder
96
+ of the License, and in such case Affirmer hereby affirms that he or she
97
+ will not (i) exercise any of his or her remaining Copyright and Related
98
+ Rights in the Work or (ii) assert any associated claims and causes of
99
+ action with respect to the Work, in either case contrary to Affirmer's
100
+ express Statement of Purpose.
101
+
102
+ 4. Limitations and Disclaimers.
103
+
104
+ a. No trademark rights held by Affirmer are waived, abandoned,
105
+ surrendered, licensed or otherwise affected by this document.
106
+ b. Affirmer offers the Work as-is and makes no representations or
107
+ warranties of any kind concerning the Work, express, implied,
108
+ statutory or otherwise, including without limitation warranties of
109
+ title, merchantability, fitness for a particular purpose, non
110
+ infringement, or the absence of latent or other defects, accuracy, or
111
+ the present or absence of errors, whether or not discoverable, all to
112
+ the greatest extent permissible under applicable law.
113
+ c. Affirmer disclaims responsibility for clearing rights of other persons
114
+ that may apply to the Work or any use thereof, including without
115
+ limitation any person's Copyright and Related Rights in the Work.
116
+ Further, Affirmer disclaims responsibility for obtaining any necessary
117
+ consents, permissions or other rights required for any use of the
118
+ Work.
119
+ d. Affirmer understands and acknowledges that Creative Commons is not a
120
+ party to this document and has no duty or obligation with respect to
121
+ this CC0 or use of the Work.
@@ -1,18 +1,27 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: ipfs_node
3
- Version: 0.1.8
3
+ Version: 0.1.11
4
4
  Summary: Run an IPFS node inside of python using kubo as a library.
5
5
  Home-page: https://github.com/emendir/py_ipfs_node
6
6
  Author: Emendir
7
7
  Author-email:
8
8
  Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: MIT License
10
9
  Classifier: Operating System :: OS Independent
11
10
  Requires-Python: >=3.7
12
11
  Description-Content-Type: text/markdown
13
12
  License-File: LICENSE
13
+ License-File: LICENSE-CC0
14
14
  Requires-Dist: cffi>=1.15.0
15
15
  Requires-Dist: ipfs_tk
16
+ Dynamic: author
17
+ Dynamic: classifier
18
+ Dynamic: description
19
+ Dynamic: description-content-type
20
+ Dynamic: home-page
21
+ Dynamic: license-file
22
+ Dynamic: requires-dist
23
+ Dynamic: requires-python
24
+ Dynamic: summary
16
25
 
17
26
  # Kubo Python Library
18
27
 
@@ -29,16 +38,32 @@ This library provides Python bindings for [Kubo](https://github.com/ipfs/kubo),
29
38
  - Publish and subscribe to IPFS PubSub topics
30
39
  - Mount and connect to remote TCP services via libp2p
31
40
 
32
- ## Project Status
41
+ ## Project Status **EXPERIMENTAL**
33
42
 
34
43
  This library is very early in its development, and is published as a proof-of-concept that it is feasible to write a python wrapper around kubo (Go-IPFS) to run IPFS nodes from within python.
35
44
  Much of the code is LLM-generated, and code coverage is poor.
36
45
 
37
- The API structure of this library WILL CHANGE in the near future!
46
+ The API of this library WILL CHANGE in the near future!
38
47
 
39
48
  So far this library has been tested on Linux x86 64-bit and Android ARM 64-bit (in Termux & in Kivy).
40
49
  Assuming that it proves to be a reliable way of working in python, this library will be developed to maturity and maintained.
41
50
 
51
+ ## Compatibility
52
+
53
+ - linux x86-64 (tested on Ubuntu)
54
+ - linux arm-64 (tested on Ubuntu on a raspberry pi 5)
55
+
56
+ ## Roadmap
57
+
58
+ [py_ipfs_node](https://github.com/emendir/py_ipfs_node), will be incorporated into [ipfs_toolkit](https://github.com/emendir/IPFS-Toolkit-Python) [when py_ipfs_node's API has stabilised](https://github.com/emendir/py_ipfs_node/issues/1).
59
+
60
+ [ipfs_toolkit](https://github.com/emendir/IPFS-Toolkit-Python) will become a multimodal IPFS library with a unified API for alternative modes of using IPFS:
61
+ - running an embedded IPFS node
62
+ - interacting with a separate IPFS node via its HTTP RPC
63
+
64
+ You can check out a prototype version of the combination of these two libraries under the `kubo_python` branch of the IPFS-Toolkit repo:
65
+ https://github.com/emendir/IPFS-Toolkit-Python/tree/kubo_python
66
+
42
67
  ## Installation
43
68
 
44
69
  ```bash
@@ -130,6 +155,47 @@ with IpfsNode.ephemeral() as node:
130
155
  - [P2P Stream Mounting](examples/p2p_example.py)
131
156
  - [P2P Socket Communication](examples/p2p_socket_example.py)
132
157
 
133
- ## License
158
+ ## Contributing
159
+
160
+ ### Get Involved
161
+
162
+ - GitHub Discussions: if you want to share ideas
163
+ - GitHub Issues: if you find bugs, other issues, or would like to submit feature requests
164
+ - GitHub Merge Requests: if you think you know what you're doing, you're very welcome!
165
+
166
+ ### Donations
167
+
168
+ To support me in my work on this and other projects, you can make donations with the following currencies:
169
+
170
+ - **Bitcoin:** `BC1Q45QEE6YTNGRC5TSZ42ZL3MWV8798ZEF70H2DG0`
171
+ - **Ethereum:** `0xA32C3bBC2106C986317f202B3aa8eBc3063323D4`
172
+ - [**Fiat** (via Credit or Debit Card, Apple Pay, Google Pay, Revolut Pay)](https://checkout.revolut.com/pay/4e4d24de-26cf-4e7d-9e84-ede89ec67f32)
173
+
174
+ Donations help me:
175
+ - dedicate more time to developing and maintaining open-source projects
176
+ - cover costs for IT infrastructure
177
+ - finance projects requiring additional hardware & compute
178
+
179
+ ## About the Developer
180
+
181
+ This project is developed by a human one-man team, publishing under the name _Emendir_.
182
+ I build open technologies trying to improve our world;
183
+ learning, working and sharing under the principle:
184
+
185
+ > _Freely I have received, freely I give._
186
+
187
+ Feel welcome to join in with code contributions, discussions, ideas and more!
188
+
189
+ ## Open-Source in the Public Domain
190
+
191
+ I dedicate this project to the public domain.
192
+ It is open source and free to use, share, modify, and build upon without restrictions or conditions.
193
+
194
+ I make no patent or trademark claims over this project.
195
+
196
+ Formally, you may use this project under either the:
197
+ - [MIT No Attribution (MIT-0)](https://choosealicense.com/licenses/mit-0/) or
198
+ - [Creative Commons Zero (CC0)](https://choosealicense.com/licenses/cc0-1.0/)
199
+ licence at your choice.
200
+
134
201
 
135
- MIT License
@@ -13,16 +13,32 @@ This library provides Python bindings for [Kubo](https://github.com/ipfs/kubo),
13
13
  - Publish and subscribe to IPFS PubSub topics
14
14
  - Mount and connect to remote TCP services via libp2p
15
15
 
16
- ## Project Status
16
+ ## Project Status **EXPERIMENTAL**
17
17
 
18
18
  This library is very early in its development, and is published as a proof-of-concept that it is feasible to write a python wrapper around kubo (Go-IPFS) to run IPFS nodes from within python.
19
19
  Much of the code is LLM-generated, and code coverage is poor.
20
20
 
21
- The API structure of this library WILL CHANGE in the near future!
21
+ The API of this library WILL CHANGE in the near future!
22
22
 
23
23
  So far this library has been tested on Linux x86 64-bit and Android ARM 64-bit (in Termux & in Kivy).
24
24
  Assuming that it proves to be a reliable way of working in python, this library will be developed to maturity and maintained.
25
25
 
26
+ ## Compatibility
27
+
28
+ - linux x86-64 (tested on Ubuntu)
29
+ - linux arm-64 (tested on Ubuntu on a raspberry pi 5)
30
+
31
+ ## Roadmap
32
+
33
+ [py_ipfs_node](https://github.com/emendir/py_ipfs_node), will be incorporated into [ipfs_toolkit](https://github.com/emendir/IPFS-Toolkit-Python) [when py_ipfs_node's API has stabilised](https://github.com/emendir/py_ipfs_node/issues/1).
34
+
35
+ [ipfs_toolkit](https://github.com/emendir/IPFS-Toolkit-Python) will become a multimodal IPFS library with a unified API for alternative modes of using IPFS:
36
+ - running an embedded IPFS node
37
+ - interacting with a separate IPFS node via its HTTP RPC
38
+
39
+ You can check out a prototype version of the combination of these two libraries under the `kubo_python` branch of the IPFS-Toolkit repo:
40
+ https://github.com/emendir/IPFS-Toolkit-Python/tree/kubo_python
41
+
26
42
  ## Installation
27
43
 
28
44
  ```bash
@@ -114,6 +130,47 @@ with IpfsNode.ephemeral() as node:
114
130
  - [P2P Stream Mounting](examples/p2p_example.py)
115
131
  - [P2P Socket Communication](examples/p2p_socket_example.py)
116
132
 
117
- ## License
133
+ ## Contributing
134
+
135
+ ### Get Involved
136
+
137
+ - GitHub Discussions: if you want to share ideas
138
+ - GitHub Issues: if you find bugs, other issues, or would like to submit feature requests
139
+ - GitHub Merge Requests: if you think you know what you're doing, you're very welcome!
140
+
141
+ ### Donations
142
+
143
+ To support me in my work on this and other projects, you can make donations with the following currencies:
144
+
145
+ - **Bitcoin:** `BC1Q45QEE6YTNGRC5TSZ42ZL3MWV8798ZEF70H2DG0`
146
+ - **Ethereum:** `0xA32C3bBC2106C986317f202B3aa8eBc3063323D4`
147
+ - [**Fiat** (via Credit or Debit Card, Apple Pay, Google Pay, Revolut Pay)](https://checkout.revolut.com/pay/4e4d24de-26cf-4e7d-9e84-ede89ec67f32)
148
+
149
+ Donations help me:
150
+ - dedicate more time to developing and maintaining open-source projects
151
+ - cover costs for IT infrastructure
152
+ - finance projects requiring additional hardware & compute
153
+
154
+ ## About the Developer
155
+
156
+ This project is developed by a human one-man team, publishing under the name _Emendir_.
157
+ I build open technologies trying to improve our world;
158
+ learning, working and sharing under the principle:
159
+
160
+ > _Freely I have received, freely I give._
161
+
162
+ Feel welcome to join in with code contributions, discussions, ideas and more!
163
+
164
+ ## Open-Source in the Public Domain
165
+
166
+ I dedicate this project to the public domain.
167
+ It is open source and free to use, share, modify, and build upon without restrictions or conditions.
168
+
169
+ I make no patent or trademark claims over this project.
170
+
171
+ Formally, you may use this project under either the:
172
+ - [MIT No Attribution (MIT-0)](https://choosealicense.com/licenses/mit-0/) or
173
+ - [Creative Commons Zero (CC0)](https://choosealicense.com/licenses/cc0-1.0/)
174
+ licence at your choice.
175
+
118
176
 
119
- MIT License
@@ -16,34 +16,32 @@ def compile_go_library():
16
16
  print("Compiling Go shared library...")
17
17
 
18
18
  # Define Go source directory
19
- libkubo_dir = os.path.join(PROJ_DIR, 'src', 'libkubo')
19
+ libkubo_dir = os.path.join(PROJ_DIR, "src", "libkubo")
20
20
 
21
21
  # Check if Go is installed
22
22
  try:
23
23
  subprocess.check_call(
24
- ['go', 'version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
24
+ ["go", "version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE
25
+ )
25
26
  except (subprocess.SubprocessError, FileNotFoundError):
26
- raise RuntimeError(
27
- "Go compiler not found. Please install Go 1.19 or later.")
27
+ raise RuntimeError("Go compiler not found. Please install Go 1.19 or later.")
28
28
 
29
29
  # Build shared library for the current platform
30
30
  if not os.path.exists(libkubo_dir):
31
31
  os.makedirs(libkubo_dir)
32
32
 
33
33
  # Determine the output file extension based on platform
34
- if platform.system() == 'Windows':
35
- lib_name = 'libkubo.dll'
36
- elif platform.system() == 'Darwin':
37
- lib_name = 'libkubo.dylib'
34
+ if platform.system() == "Windows":
35
+ lib_name = "libkubo.dll"
36
+ elif platform.system() == "Darwin":
37
+ lib_name = "libkubo.dylib"
38
38
  else:
39
- lib_name = 'libkubo_linux_x86_64.so'
39
+ lib_name = "libkubo_linux_x86_64.so"
40
40
 
41
41
  # Get Kubo library source code if not already fetched
42
42
  try:
43
- if not os.path.exists(os.path.join(libkubo_dir, 'go.sum')):
44
- subprocess.check_call([
45
- 'go', 'mod', 'tidy'
46
- ], cwd=libkubo_dir)
43
+ if not os.path.exists(os.path.join(libkubo_dir, "go.sum")):
44
+ subprocess.check_call(["go", "mod", "tidy"], cwd=libkubo_dir)
47
45
  except subprocess.CalledProcessError as e:
48
46
  print(f"Error fetching Go dependencies: {e}")
49
47
  print("Continuing with existing code...")
@@ -55,11 +53,7 @@ def compile_go_library():
55
53
  return
56
54
  print("Compiling libkubo...")
57
55
  # Build the shared library
58
- build_cmd = [
59
- 'go', 'build', '-buildmode=c-shared',
60
- '-o', output_path,
61
- libkubo_dir
62
- ]
56
+ build_cmd = ["go", "build", "-buildmode=c-shared", "-o", output_path, libkubo_dir]
63
57
 
64
58
  print(f"Running: {' '.join(build_cmd)}")
65
59
  subprocess.check_call(build_cmd, cwd=libkubo_dir)
@@ -95,22 +89,19 @@ pip.main(["install", "-r", os.path.join(PROJ_DIR, "requirements.txt")])
95
89
 
96
90
  setup(
97
91
  name="ipfs_node",
98
- version="0.1.8",
92
+ version="0.1.11",
99
93
  packages=find_packages(where="src"),
100
94
  package_dir={"": "src"},
101
95
  package_data={
102
- 'libkubo': ['*.so', '*.h'],
96
+ "libkubo": ["*.dll", "*.dylib", "*.so", "*.h"],
103
97
  },
104
98
  include_package_data=True,
105
99
  cmdclass={
106
- 'build_py': BuildGoLibraryCommand,
107
- 'install': InstallCommand,
108
- 'develop': DevelopCommand,
100
+ "build_py": BuildGoLibraryCommand,
101
+ "install": InstallCommand,
102
+ "develop": DevelopCommand,
109
103
  },
110
- install_requires=[
111
- 'cffi>=1.15.0',
112
- 'ipfs_tk'
113
- ],
104
+ install_requires=["cffi>=1.15.0", "ipfs_tk"],
114
105
  author="Emendir",
115
106
  author_email="",
116
107
  description="Run an IPFS node inside of python using kubo as a library.",
@@ -119,8 +110,7 @@ setup(
119
110
  url="https://github.com/emendir/py_ipfs_node",
120
111
  classifiers=[
121
112
  "Programming Language :: Python :: 3",
122
- "License :: OSI Approved :: MIT License",
123
113
  "Operating System :: OS Independent",
124
114
  ],
125
- python_requires='>=3.7',
115
+ python_requires=">=3.7",
126
116
  )
@@ -1,18 +1,27 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: ipfs_node
3
- Version: 0.1.8
3
+ Version: 0.1.11
4
4
  Summary: Run an IPFS node inside of python using kubo as a library.
5
5
  Home-page: https://github.com/emendir/py_ipfs_node
6
6
  Author: Emendir
7
7
  Author-email:
8
8
  Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: MIT License
10
9
  Classifier: Operating System :: OS Independent
11
10
  Requires-Python: >=3.7
12
11
  Description-Content-Type: text/markdown
13
12
  License-File: LICENSE
13
+ License-File: LICENSE-CC0
14
14
  Requires-Dist: cffi>=1.15.0
15
15
  Requires-Dist: ipfs_tk
16
+ Dynamic: author
17
+ Dynamic: classifier
18
+ Dynamic: description
19
+ Dynamic: description-content-type
20
+ Dynamic: home-page
21
+ Dynamic: license-file
22
+ Dynamic: requires-dist
23
+ Dynamic: requires-python
24
+ Dynamic: summary
16
25
 
17
26
  # Kubo Python Library
18
27
 
@@ -29,16 +38,32 @@ This library provides Python bindings for [Kubo](https://github.com/ipfs/kubo),
29
38
  - Publish and subscribe to IPFS PubSub topics
30
39
  - Mount and connect to remote TCP services via libp2p
31
40
 
32
- ## Project Status
41
+ ## Project Status **EXPERIMENTAL**
33
42
 
34
43
  This library is very early in its development, and is published as a proof-of-concept that it is feasible to write a python wrapper around kubo (Go-IPFS) to run IPFS nodes from within python.
35
44
  Much of the code is LLM-generated, and code coverage is poor.
36
45
 
37
- The API structure of this library WILL CHANGE in the near future!
46
+ The API of this library WILL CHANGE in the near future!
38
47
 
39
48
  So far this library has been tested on Linux x86 64-bit and Android ARM 64-bit (in Termux & in Kivy).
40
49
  Assuming that it proves to be a reliable way of working in python, this library will be developed to maturity and maintained.
41
50
 
51
+ ## Compatibility
52
+
53
+ - linux x86-64 (tested on Ubuntu)
54
+ - linux arm-64 (tested on Ubuntu on a raspberry pi 5)
55
+
56
+ ## Roadmap
57
+
58
+ [py_ipfs_node](https://github.com/emendir/py_ipfs_node), will be incorporated into [ipfs_toolkit](https://github.com/emendir/IPFS-Toolkit-Python) [when py_ipfs_node's API has stabilised](https://github.com/emendir/py_ipfs_node/issues/1).
59
+
60
+ [ipfs_toolkit](https://github.com/emendir/IPFS-Toolkit-Python) will become a multimodal IPFS library with a unified API for alternative modes of using IPFS:
61
+ - running an embedded IPFS node
62
+ - interacting with a separate IPFS node via its HTTP RPC
63
+
64
+ You can check out a prototype version of the combination of these two libraries under the `kubo_python` branch of the IPFS-Toolkit repo:
65
+ https://github.com/emendir/IPFS-Toolkit-Python/tree/kubo_python
66
+
42
67
  ## Installation
43
68
 
44
69
  ```bash
@@ -130,6 +155,47 @@ with IpfsNode.ephemeral() as node:
130
155
  - [P2P Stream Mounting](examples/p2p_example.py)
131
156
  - [P2P Socket Communication](examples/p2p_socket_example.py)
132
157
 
133
- ## License
158
+ ## Contributing
159
+
160
+ ### Get Involved
161
+
162
+ - GitHub Discussions: if you want to share ideas
163
+ - GitHub Issues: if you find bugs, other issues, or would like to submit feature requests
164
+ - GitHub Merge Requests: if you think you know what you're doing, you're very welcome!
165
+
166
+ ### Donations
167
+
168
+ To support me in my work on this and other projects, you can make donations with the following currencies:
169
+
170
+ - **Bitcoin:** `BC1Q45QEE6YTNGRC5TSZ42ZL3MWV8798ZEF70H2DG0`
171
+ - **Ethereum:** `0xA32C3bBC2106C986317f202B3aa8eBc3063323D4`
172
+ - [**Fiat** (via Credit or Debit Card, Apple Pay, Google Pay, Revolut Pay)](https://checkout.revolut.com/pay/4e4d24de-26cf-4e7d-9e84-ede89ec67f32)
173
+
174
+ Donations help me:
175
+ - dedicate more time to developing and maintaining open-source projects
176
+ - cover costs for IT infrastructure
177
+ - finance projects requiring additional hardware & compute
178
+
179
+ ## About the Developer
180
+
181
+ This project is developed by a human one-man team, publishing under the name _Emendir_.
182
+ I build open technologies trying to improve our world;
183
+ learning, working and sharing under the principle:
184
+
185
+ > _Freely I have received, freely I give._
186
+
187
+ Feel welcome to join in with code contributions, discussions, ideas and more!
188
+
189
+ ## Open-Source in the Public Domain
190
+
191
+ I dedicate this project to the public domain.
192
+ It is open source and free to use, share, modify, and build upon without restrictions or conditions.
193
+
194
+ I make no patent or trademark claims over this project.
195
+
196
+ Formally, you may use this project under either the:
197
+ - [MIT No Attribution (MIT-0)](https://choosealicense.com/licenses/mit-0/) or
198
+ - [Creative Commons Zero (CC0)](https://choosealicense.com/licenses/cc0-1.0/)
199
+ licence at your choice.
200
+
134
201
 
135
- MIT License
@@ -1,5 +1,6 @@
1
1
  INSTALL.md
2
2
  LICENSE
3
+ LICENSE-CC0
3
4
  MANIFEST.in
4
5
  README.md
5
6
  setup.py
@@ -26,10 +27,13 @@ src/ipfs_node/utils/cid_utils.py
26
27
  src/ipfs_node/utils/peer_utils.py
27
28
  src/libkubo/__init__.py
28
29
  src/libkubo/libkubo_android_arm64.h
29
- src/libkubo/libkubo_android_arm64.so
30
+ src/libkubo/libkubo_linux_arm64.h
31
+ src/libkubo/libkubo_linux_arm64.so
30
32
  src/libkubo/libkubo_linux_x86_64.h
31
33
  src/libkubo/libkubo_linux_x86_64.so
32
34
  src/libkubo/libkubo_loader.py
35
+ src/libkubo/libkubo_windows_x86_64.dll
36
+ src/libkubo/libkubo_windows_x86_64.h
33
37
  tests/test_all.py
34
38
  tests/test_peers.py
35
39
  tests/test_pubsub.py
@@ -0,0 +1,237 @@
1
+ /* Code generated by cmd/cgo; DO NOT EDIT. */
2
+
3
+ /* package github.com/emendir/py_ipfs_node/libkubo */
4
+
5
+
6
+ #line 1 "cgo-builtin-export-prolog"
7
+
8
+ #include <stddef.h>
9
+
10
+ #ifndef GO_CGO_EXPORT_PROLOGUE_H
11
+ #define GO_CGO_EXPORT_PROLOGUE_H
12
+
13
+ #ifndef GO_CGO_GOSTRING_TYPEDEF
14
+ typedef struct { const char *p; ptrdiff_t n; } _GoString_;
15
+ #endif
16
+
17
+ #endif
18
+
19
+ /* Start of preamble from import "C" comments. */
20
+
21
+
22
+ #line 3 "files.go"
23
+ #include <stdlib.h>
24
+ #include <stdbool.h>
25
+
26
+ #line 1 "cgo-generated-wrapper"
27
+
28
+ #line 3 "p2p.go"
29
+
30
+ #include <stdlib.h>
31
+ #include <stdbool.h>
32
+
33
+ #line 1 "cgo-generated-wrapper"
34
+
35
+ #line 3 "peers.go"
36
+ #include <stdlib.h>
37
+
38
+ #line 1 "cgo-generated-wrapper"
39
+
40
+ #line 3 "pubsub.go"
41
+ #include <stdlib.h>
42
+
43
+ #line 1 "cgo-generated-wrapper"
44
+
45
+ #line 3 "repo.go"
46
+ #include <stdlib.h>
47
+
48
+ #line 1 "cgo-generated-wrapper"
49
+
50
+
51
+ /* End of preamble from import "C" comments. */
52
+
53
+
54
+ /* Start of boilerplate cgo prologue. */
55
+ #line 1 "cgo-gcc-export-header-prolog"
56
+
57
+ #ifndef GO_CGO_PROLOGUE_H
58
+ #define GO_CGO_PROLOGUE_H
59
+
60
+ typedef signed char GoInt8;
61
+ typedef unsigned char GoUint8;
62
+ typedef short GoInt16;
63
+ typedef unsigned short GoUint16;
64
+ typedef int GoInt32;
65
+ typedef unsigned int GoUint32;
66
+ typedef long long GoInt64;
67
+ typedef unsigned long long GoUint64;
68
+ typedef GoInt64 GoInt;
69
+ typedef GoUint64 GoUint;
70
+ typedef size_t GoUintptr;
71
+ typedef float GoFloat32;
72
+ typedef double GoFloat64;
73
+ #ifdef _MSC_VER
74
+ #include <complex.h>
75
+ typedef _Fcomplex GoComplex64;
76
+ typedef _Dcomplex GoComplex128;
77
+ #else
78
+ typedef float _Complex GoComplex64;
79
+ typedef double _Complex GoComplex128;
80
+ #endif
81
+
82
+ /*
83
+ static assertion to make sure the file is being used on architecture
84
+ at least with matching size of GoInt.
85
+ */
86
+ typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];
87
+
88
+ #ifndef GO_CGO_GOSTRING_TYPEDEF
89
+ typedef _GoString_ GoString;
90
+ #endif
91
+ typedef void *GoMap;
92
+ typedef void *GoChan;
93
+ typedef struct { void *t; void *v; } GoInterface;
94
+ typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
95
+
96
+ #endif
97
+
98
+ /* End of boilerplate cgo prologue. */
99
+
100
+ #ifdef __cplusplus
101
+ extern "C" {
102
+ #endif
103
+
104
+
105
+ // AddFile adds a file to IPFS
106
+ //
107
+ extern char* AddFile(char* repoPath, char* filePath, _Bool onlyHash);
108
+
109
+ // FreeString is a no-op for now - we'll let Go's garbage collection handle the memory
110
+ //
111
+ extern void FreeString(char* str);
112
+
113
+ // Download retrieves a file or directory from IPFS
114
+ //
115
+ extern int Download(char* repoPath, char* cidStr, char* destPath);
116
+
117
+ // PinCID pins a CID to the IPFS node
118
+ //
119
+ extern int PinCID(char* repoPath, char* cidStr);
120
+
121
+ // UnpinCID unpins a CID from the IPFS node
122
+ //
123
+ extern int UnpinCID(char* repoPath, char* cidStr);
124
+
125
+ // ListPins returns a list of pinned CIDs
126
+ //
127
+ extern char* ListPins(char* repoPath);
128
+
129
+ // RemoveCID removes a pinned CID from IPFS (alias for UnpinCID for clarity)
130
+ //
131
+ extern int RemoveCID(char* repoPath, char* cidStr);
132
+
133
+ // P2PForward creates a libp2p stream mounting forwarding connection
134
+ //
135
+ extern int P2PForward(char* repoPath, char* proto, char* listenAddr, char* targetPeerID);
136
+
137
+ // P2PListen creates a libp2p service that listens for connections on the given protocol
138
+ //
139
+ extern int P2PListen(char* repoPath, char* proto, char* targetAddr);
140
+
141
+ // P2PClose closes p2p listener or stream
142
+ //
143
+ extern int P2PClose(char* repoPath, char* proto, char* listenAddr, char* targetAddr, _Bool _all, _Bool listeners, _Bool forwarders);
144
+
145
+ // P2PListListeners lists active p2p listeners
146
+ //
147
+ extern char* P2PListListeners(char* repoPath);
148
+
149
+ // P2PEnable ensures p2p functionality is enabled in the config
150
+ //
151
+ extern int P2PEnable(char* repoPath);
152
+
153
+ // P2PListForwards lists active p2p forwarding connections
154
+ //
155
+ extern char* P2PListForwards(char* repoPath);
156
+
157
+ // P2PCloseAllListeners closes all p2p listeners
158
+ //
159
+ extern int P2PCloseAllListeners(char* repoPath);
160
+
161
+ // P2PCloseAllForwards closes all p2p forwards
162
+ //
163
+ extern int P2PCloseAllForwards(char* repoPath);
164
+
165
+ // ConnectToPeer connects to a peer
166
+ //
167
+ extern int ConnectToPeer(char* repoPath, char* peerAddr);
168
+
169
+ // ListPeers connects to a peer
170
+ //
171
+ extern char* ListPeers(char* repoPath);
172
+
173
+ // ListPeers connects to a peer
174
+ //
175
+ extern char* ListPeersIDs(char* repoPath);
176
+
177
+ // FindPeer connects to a peer
178
+ //
179
+ extern char* FindPeer(char* repoPath, char* peerAddr, int timeOut);
180
+
181
+ // PubSubListTopics lists the topics the node is subscribed to
182
+ //
183
+ extern char* PubSubListTopics(char* repoPath);
184
+
185
+ // PubSubPublish publishes a message to a topic
186
+ //
187
+ extern int PubSubPublish(char* repoPath, char* topic, void* data, int dataLen);
188
+
189
+ // PubSubSubscribe subscribes to a topic
190
+ //
191
+ extern long long int PubSubSubscribe(char* repoPath, char* topic);
192
+
193
+ // PubSubNextMessage gets the next message from a subscription
194
+ //
195
+ extern char* PubSubNextMessage(long long int subID);
196
+
197
+ // PubSubUnsubscribe unsubscribes from a topic
198
+ //
199
+ extern int PubSubUnsubscribe(long long int subID);
200
+
201
+ // PubSubPeers lists peers participating in a topic
202
+ //
203
+ extern char* PubSubPeers(char* repoPath, char* topic);
204
+
205
+ // PubSubCloseRepoSubscriptions closes all active pubsub subscriptions for a specific repository
206
+ //
207
+ extern int PubSubCloseRepoSubscriptions(char* repoPath);
208
+
209
+ // PubSubCloseAllSubscriptions closes all active pubsub subscriptions across all repositories
210
+ //
211
+ extern int PubSubCloseAllSubscriptions();
212
+
213
+ // CreateRepo initializes a new IPFS repository
214
+ //
215
+ extern int CreateRepo(char* repoPath);
216
+ extern int RunNode(char* repoPath);
217
+
218
+ // PubSubEnable enables pubsub on an IPFS node configuration
219
+ //
220
+ extern int PubSubEnable(char* repoPath);
221
+ extern char* TestGetString();
222
+
223
+ // GetNodeID gets the ID of the IPFS node
224
+ //
225
+ extern char* GetNodeID(char* repoPath);
226
+
227
+ // GetNodeMultiAddrs gets the ID of the IPFS node
228
+ //
229
+ extern char* GetNodeMultiAddrs(char* repoPath);
230
+
231
+ // CleanupNode explicitly releases a node by path
232
+ //
233
+ extern int CleanupNode(char* repoPath);
234
+
235
+ #ifdef __cplusplus
236
+ }
237
+ #endif
@@ -0,0 +1,88 @@
1
+ import os
2
+ from cffi import FFI
3
+ import platform
4
+ from pathlib import Path
5
+
6
+ ffi = FFI()
7
+
8
+
9
+ def is_android() -> bool:
10
+ """Check if OS is android."""
11
+ if "ANDROID_ROOT" in os.environ and "ANDROID_DATA" in os.environ:
12
+ return True
13
+ return (
14
+ "android" in platform.release().lower()
15
+ or "android" in platform.version().lower()
16
+ )
17
+
18
+
19
+ system = platform.system()
20
+ machine = platform.machine().lower()
21
+
22
+ if system == "Windows":
23
+ if machine in ("x86_64", "amd64"):
24
+ lib_name = "libkubo_windows_x86_64.dll"
25
+ # header_name = "libkubo_windows_x86_64.h"
26
+ # windows header causes problems, so parse linux header instead
27
+ header_name = "libkubo_linux_x86_64.h"
28
+ # elif machine in ("aarch64", "arm64"):
29
+ # lib_name = "libkubo_windows_arm64.dll"
30
+ # header_name = "libkubo_windows_arm64.h"
31
+ else:
32
+ raise RuntimeError(f"Unsupported Windows architecture: {machine}")
33
+
34
+ elif system == "Darwin":
35
+ lib_name = "libkubo.dylib"
36
+ header_name = "libkubo.h"
37
+
38
+ elif system == "Linux":
39
+ if is_android():
40
+ if machine in ("aarch64", "arm64"):
41
+ lib_name = "libkubo_android_arm64.so"
42
+ header_name = "libkubo_android_arm64.h"
43
+ else:
44
+ raise RuntimeError(f"Unsupported Android arch: {machine}")
45
+ else:
46
+ if machine in ("x86_64", "amd64"):
47
+ lib_name = "libkubo_linux_x86_64.so"
48
+ header_name = "libkubo_linux_x86_64.h"
49
+ elif machine in ("aarch64", "arm64"):
50
+ lib_name = "libkubo_linux_arm64.so"
51
+ header_name = "libkubo_linux_arm64.h"
52
+ elif machine.startswith("armv7") or machine == "armv7l":
53
+ lib_name = "libkubo_linux_armhf.so"
54
+ header_name = "libkubo_linux_armhf.h"
55
+ else:
56
+ raise RuntimeError(f"Unsupported Linux architecture: {machine}")
57
+ else:
58
+ raise RuntimeError(f"Unsupported platform: {system} {machine}")
59
+
60
+ print(lib_name)
61
+ print(header_name)
62
+
63
+ # Get the absolute path to the library
64
+ lib_path = str(Path(__file__).parent / lib_name)
65
+ header_path = str(Path(__file__).parent / header_name)
66
+
67
+ with open(header_path) as file:
68
+ lines = [line.strip() for line in file.readlines()]
69
+ func_declarations = [
70
+ line for line in lines if line.startswith("extern ") and line.endswith(";")
71
+ ]
72
+ ffi.cdef("\n".join(func_declarations))
73
+ ffi.set_source("libkubo", None)
74
+ libkubo = ffi.dlopen(lib_path)
75
+
76
+
77
+ def c_str(data: str | bytes):
78
+ if isinstance(data, str):
79
+ data = data.encode()
80
+ return ffi.new("char[]", data)
81
+
82
+
83
+ def from_c_str(string_ptr):
84
+ return ffi.string(string_ptr).decode("utf-8")
85
+
86
+
87
+ def c_bool(value: bool):
88
+ return ffi.new("bool *", value)[0]
@@ -0,0 +1,237 @@
1
+ /* Code generated by cmd/cgo; DO NOT EDIT. */
2
+
3
+ /* package github.com/emendir/py_ipfs_node/libkubo */
4
+
5
+
6
+ #line 1 "cgo-builtin-export-prolog"
7
+
8
+ #include <stddef.h>
9
+
10
+ #ifndef GO_CGO_EXPORT_PROLOGUE_H
11
+ #define GO_CGO_EXPORT_PROLOGUE_H
12
+
13
+ #ifndef GO_CGO_GOSTRING_TYPEDEF
14
+ typedef struct { const char *p; ptrdiff_t n; } _GoString_;
15
+ #endif
16
+
17
+ #endif
18
+
19
+ /* Start of preamble from import "C" comments. */
20
+
21
+
22
+ #line 3 "files.go"
23
+ #include <stdlib.h>
24
+ #include <stdbool.h>
25
+
26
+ #line 1 "cgo-generated-wrapper"
27
+
28
+ #line 3 "p2p.go"
29
+
30
+ #include <stdlib.h>
31
+ #include <stdbool.h>
32
+
33
+ #line 1 "cgo-generated-wrapper"
34
+
35
+ #line 3 "peers.go"
36
+ #include <stdlib.h>
37
+
38
+ #line 1 "cgo-generated-wrapper"
39
+
40
+ #line 3 "pubsub.go"
41
+ #include <stdlib.h>
42
+
43
+ #line 1 "cgo-generated-wrapper"
44
+
45
+ #line 3 "repo.go"
46
+ #include <stdlib.h>
47
+
48
+ #line 1 "cgo-generated-wrapper"
49
+
50
+
51
+ /* End of preamble from import "C" comments. */
52
+
53
+
54
+ /* Start of boilerplate cgo prologue. */
55
+ #line 1 "cgo-gcc-export-header-prolog"
56
+
57
+ #ifndef GO_CGO_PROLOGUE_H
58
+ #define GO_CGO_PROLOGUE_H
59
+
60
+ typedef signed char GoInt8;
61
+ typedef unsigned char GoUint8;
62
+ typedef short GoInt16;
63
+ typedef unsigned short GoUint16;
64
+ typedef int GoInt32;
65
+ typedef unsigned int GoUint32;
66
+ typedef long long GoInt64;
67
+ typedef unsigned long long GoUint64;
68
+ typedef GoInt64 GoInt;
69
+ typedef GoUint64 GoUint;
70
+ typedef size_t GoUintptr;
71
+ typedef float GoFloat32;
72
+ typedef double GoFloat64;
73
+ #ifdef _MSC_VER
74
+ #include <complex.h>
75
+ typedef _Fcomplex GoComplex64;
76
+ typedef _Dcomplex GoComplex128;
77
+ #else
78
+ typedef float _Complex GoComplex64;
79
+ typedef double _Complex GoComplex128;
80
+ #endif
81
+
82
+ /*
83
+ static assertion to make sure the file is being used on architecture
84
+ at least with matching size of GoInt.
85
+ */
86
+ typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];
87
+
88
+ #ifndef GO_CGO_GOSTRING_TYPEDEF
89
+ typedef _GoString_ GoString;
90
+ #endif
91
+ typedef void *GoMap;
92
+ typedef void *GoChan;
93
+ typedef struct { void *t; void *v; } GoInterface;
94
+ typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
95
+
96
+ #endif
97
+
98
+ /* End of boilerplate cgo prologue. */
99
+
100
+ #ifdef __cplusplus
101
+ extern "C" {
102
+ #endif
103
+
104
+
105
+ // AddFile adds a file to IPFS
106
+ //
107
+ extern __declspec(dllexport) char* AddFile(char* repoPath, char* filePath, _Bool onlyHash);
108
+
109
+ // FreeString is a no-op for now - we'll let Go's garbage collection handle the memory
110
+ //
111
+ extern __declspec(dllexport) void FreeString(char* str);
112
+
113
+ // Download retrieves a file or directory from IPFS
114
+ //
115
+ extern __declspec(dllexport) int Download(char* repoPath, char* cidStr, char* destPath);
116
+
117
+ // PinCID pins a CID to the IPFS node
118
+ //
119
+ extern __declspec(dllexport) int PinCID(char* repoPath, char* cidStr);
120
+
121
+ // UnpinCID unpins a CID from the IPFS node
122
+ //
123
+ extern __declspec(dllexport) int UnpinCID(char* repoPath, char* cidStr);
124
+
125
+ // ListPins returns a list of pinned CIDs
126
+ //
127
+ extern __declspec(dllexport) char* ListPins(char* repoPath);
128
+
129
+ // RemoveCID removes a pinned CID from IPFS (alias for UnpinCID for clarity)
130
+ //
131
+ extern __declspec(dllexport) int RemoveCID(char* repoPath, char* cidStr);
132
+
133
+ // P2PForward creates a libp2p stream mounting forwarding connection
134
+ //
135
+ extern __declspec(dllexport) int P2PForward(char* repoPath, char* proto, char* listenAddr, char* targetPeerID);
136
+
137
+ // P2PListen creates a libp2p service that listens for connections on the given protocol
138
+ //
139
+ extern __declspec(dllexport) int P2PListen(char* repoPath, char* proto, char* targetAddr);
140
+
141
+ // P2PClose closes p2p listener or stream
142
+ //
143
+ extern __declspec(dllexport) int P2PClose(char* repoPath, char* proto, char* listenAddr, char* targetAddr, _Bool _all, _Bool listeners, _Bool forwarders);
144
+
145
+ // P2PListListeners lists active p2p listeners
146
+ //
147
+ extern __declspec(dllexport) char* P2PListListeners(char* repoPath);
148
+
149
+ // P2PEnable ensures p2p functionality is enabled in the config
150
+ //
151
+ extern __declspec(dllexport) int P2PEnable(char* repoPath);
152
+
153
+ // P2PListForwards lists active p2p forwarding connections
154
+ //
155
+ extern __declspec(dllexport) char* P2PListForwards(char* repoPath);
156
+
157
+ // P2PCloseAllListeners closes all p2p listeners
158
+ //
159
+ extern __declspec(dllexport) int P2PCloseAllListeners(char* repoPath);
160
+
161
+ // P2PCloseAllForwards closes all p2p forwards
162
+ //
163
+ extern __declspec(dllexport) int P2PCloseAllForwards(char* repoPath);
164
+
165
+ // ConnectToPeer connects to a peer
166
+ //
167
+ extern __declspec(dllexport) int ConnectToPeer(char* repoPath, char* peerAddr);
168
+
169
+ // ListPeers connects to a peer
170
+ //
171
+ extern __declspec(dllexport) char* ListPeers(char* repoPath);
172
+
173
+ // ListPeers connects to a peer
174
+ //
175
+ extern __declspec(dllexport) char* ListPeersIDs(char* repoPath);
176
+
177
+ // FindPeer connects to a peer
178
+ //
179
+ extern __declspec(dllexport) char* FindPeer(char* repoPath, char* peerAddr, int timeOut);
180
+
181
+ // PubSubListTopics lists the topics the node is subscribed to
182
+ //
183
+ extern __declspec(dllexport) char* PubSubListTopics(char* repoPath);
184
+
185
+ // PubSubPublish publishes a message to a topic
186
+ //
187
+ extern __declspec(dllexport) int PubSubPublish(char* repoPath, char* topic, void* data, int dataLen);
188
+
189
+ // PubSubSubscribe subscribes to a topic
190
+ //
191
+ extern __declspec(dllexport) long long int PubSubSubscribe(char* repoPath, char* topic);
192
+
193
+ // PubSubNextMessage gets the next message from a subscription
194
+ //
195
+ extern __declspec(dllexport) char* PubSubNextMessage(long long int subID);
196
+
197
+ // PubSubUnsubscribe unsubscribes from a topic
198
+ //
199
+ extern __declspec(dllexport) int PubSubUnsubscribe(long long int subID);
200
+
201
+ // PubSubPeers lists peers participating in a topic
202
+ //
203
+ extern __declspec(dllexport) char* PubSubPeers(char* repoPath, char* topic);
204
+
205
+ // PubSubCloseRepoSubscriptions closes all active pubsub subscriptions for a specific repository
206
+ //
207
+ extern __declspec(dllexport) int PubSubCloseRepoSubscriptions(char* repoPath);
208
+
209
+ // PubSubCloseAllSubscriptions closes all active pubsub subscriptions across all repositories
210
+ //
211
+ extern __declspec(dllexport) int PubSubCloseAllSubscriptions();
212
+
213
+ // CreateRepo initializes a new IPFS repository
214
+ //
215
+ extern __declspec(dllexport) int CreateRepo(char* repoPath);
216
+ extern __declspec(dllexport) int RunNode(char* repoPath);
217
+
218
+ // PubSubEnable enables pubsub on an IPFS node configuration
219
+ //
220
+ extern __declspec(dllexport) int PubSubEnable(char* repoPath);
221
+ extern __declspec(dllexport) char* TestGetString();
222
+
223
+ // GetNodeID gets the ID of the IPFS node
224
+ //
225
+ extern __declspec(dllexport) char* GetNodeID(char* repoPath);
226
+
227
+ // GetNodeMultiAddrs gets the ID of the IPFS node
228
+ //
229
+ extern __declspec(dllexport) char* GetNodeMultiAddrs(char* repoPath);
230
+
231
+ // CleanupNode explicitly releases a node by path
232
+ //
233
+ extern __declspec(dllexport) int CleanupNode(char* repoPath);
234
+
235
+ #ifdef __cplusplus
236
+ }
237
+ #endif
@@ -1,45 +0,0 @@
1
- from cffi import FFI
2
- import platform
3
- from pathlib import Path
4
- ffi = FFI()
5
-
6
-
7
- # Determine library name based on platform
8
- if platform.system() == 'Windows':
9
- lib_name = 'libkubo.dll'
10
- header_name = 'libkubo.h'
11
- elif platform.system() == 'Darwin':
12
- lib_name = 'libkubo.dylib'
13
- header_name = 'libkubo.h'
14
- else:
15
- if "aarch64" == platform.machine():
16
- lib_name = "libkubo_android_arm64.so"
17
- header_name = "libkubo_android_arm64.h"
18
- else:
19
- lib_name = 'libkubo_linux_x86_64.so'
20
- header_name = 'libkubo_linux_x86_64.h'
21
-
22
-
23
-
24
- # Get the absolute path to the library
25
- lib_path = str(Path(__file__).parent / lib_name)
26
- header_path = str(Path(__file__).parent / header_name)
27
-
28
- with open(header_path) as file:
29
- lines = [line.strip() for line in file.readlines()]
30
- func_declarations = [
31
- line for line in lines if line.startswith("extern ") and line.endswith(";")
32
- ]
33
- ffi.cdef("\n".join(func_declarations))
34
- ffi.set_source("libkubo", None)
35
- libkubo = ffi.dlopen(lib_path)
36
-
37
-
38
- def c_str(data:str|bytes):
39
- if isinstance(data, str):
40
- data = data.encode()
41
- return ffi.new("char[]", data)
42
- def from_c_str(string_ptr):
43
- return ffi.string(string_ptr).decode('utf-8')
44
- def c_bool(value: bool):
45
- return ffi.new("bool *", value)[0]
File without changes
File without changes
File without changes
File without changes