# Homebrew formula for I2P Python Router # Install: brew install --build-from-source i2p-python.rb # Service: brew services start i2p-python class I2pPython < Formula include Language::Python::Virtualenv desc "I2P anonymous overlay network router — Python implementation" homepage "https://geti2p.net/" # TODO: Update URL and sha256 when published to PyPI url "https://files.pythonhosted.org/packages/source/i/i2p-python/i2p_python-0.1.0.tar.gz" sha256 "PLACEHOLDER_SHA256" license "MIT" depends_on "python@3.12" depends_on "openssl@3" depends_on "libsodium" depends_on "libffi" depends_on "rust" => :build # TODO: Generate resource blocks with: # brew update-python-resources i2p-python # Each transitive PyPI dependency needs a resource block. def install ENV["SODIUM_INSTALL"] = "system" ENV["OPENSSL_DIR"] = Formula["openssl@3"].opt_prefix virtualenv_install_with_resources # Ensure CLI commands are linked %w[i2p-router i2p-sam i2p-tunnel].each do |cmd| (bin/cmd).write_env_script( libexec/"bin"/cmd, PATH: "#{Formula["openssl@3"].opt_bin}:${PATH}" ) end end service do run [opt_bin/"i2p-router", "--data-dir", var/"lib/i2p-python", "--log-level", "INFO"] keep_alive true log_path var/"log/i2p-router.log" error_log_path var/"log/i2p-router-error.log" working_dir var/"lib/i2p-python" environment_variables PATH: std_service_path_env end def post_install (var/"lib/i2p-python").mkpath (var/"log").mkpath end test do assert_match "I2P Python Router", shell_output("#{bin}/i2p-router --help") assert_match "i2p-sam", shell_output("#{bin}/i2p-sam --help") assert_match "i2p-tunnel", shell_output("#{bin}/i2p-tunnel --help") end end