A Python port of the Invisible Internet Project (I2P)
1# Homebrew formula for I2P Python Router
2# Install: brew install --build-from-source i2p-python.rb
3# Service: brew services start i2p-python
4
5class I2pPython < Formula
6 include Language::Python::Virtualenv
7
8 desc "I2P anonymous overlay network router — Python implementation"
9 homepage "https://geti2p.net/"
10 # TODO: Update URL and sha256 when published to PyPI
11 url "https://files.pythonhosted.org/packages/source/i/i2p-python/i2p_python-0.1.0.tar.gz"
12 sha256 "PLACEHOLDER_SHA256"
13 license "MIT"
14
15 depends_on "python@3.12"
16 depends_on "openssl@3"
17 depends_on "libsodium"
18 depends_on "libffi"
19 depends_on "rust" => :build
20
21 # TODO: Generate resource blocks with:
22 # brew update-python-resources i2p-python
23 # Each transitive PyPI dependency needs a resource block.
24
25 def install
26 ENV["SODIUM_INSTALL"] = "system"
27 ENV["OPENSSL_DIR"] = Formula["openssl@3"].opt_prefix
28
29 virtualenv_install_with_resources
30
31 # Ensure CLI commands are linked
32 %w[i2p-router i2p-sam i2p-tunnel].each do |cmd|
33 (bin/cmd).write_env_script(
34 libexec/"bin"/cmd,
35 PATH: "#{Formula["openssl@3"].opt_bin}:${PATH}"
36 )
37 end
38 end
39
40 service do
41 run [opt_bin/"i2p-router", "--data-dir", var/"lib/i2p-python", "--log-level", "INFO"]
42 keep_alive true
43 log_path var/"log/i2p-router.log"
44 error_log_path var/"log/i2p-router-error.log"
45 working_dir var/"lib/i2p-python"
46 environment_variables PATH: std_service_path_env
47 end
48
49 def post_install
50 (var/"lib/i2p-python").mkpath
51 (var/"log").mkpath
52 end
53
54 test do
55 assert_match "I2P Python Router", shell_output("#{bin}/i2p-router --help")
56 assert_match "i2p-sam", shell_output("#{bin}/i2p-sam --help")
57 assert_match "i2p-tunnel", shell_output("#{bin}/i2p-tunnel --help")
58 end
59end