Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Adds setup.py and other details for packaging #10

Merged
merged 3 commits into from
Oct 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include securedrop_proxy/*.py
include requirements.txt
include README.md
include LICENSE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't have this file yet in the repo btw

include setup.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we remove this since it's redundant?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will make the python file inclusion explicit.

include Pipfile
include Pipfile.lock
include qubes/securedrop.Proxy
include config-example.yaml
2 changes: 1 addition & 1 deletion qubes/securedrop.Proxy
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/home/user/projects/securedrop-proxy/entrypoint.sh
/usr/bin/sd-proxy /etc/sd-proxy.yaml
41 changes: 0 additions & 41 deletions sd-proxy.py

This file was deleted.

46 changes: 46 additions & 0 deletions securedrop_proxy/entrypoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env python3

# The sd-proxy RPC script triggered by qubes RPC.

# This script is executed by `/etc/qubes-rpc/sd-proxy`. It must be
# called with exactly one argument: the path to its config file. See
# the README for configuration options.

import sys
import json
import uuid
import subprocess

from . import proxy
from . import config
from . import callbacks
from . import main


def start():
# a fresh, new proxy object
p = proxy.Proxy()

# set up an error handler early, so we can use it during
# configuration, etc
p.on_done = callbacks.err_on_done

# path to config file must be at argv[1]
if len(sys.argv) != 2:
p.simple_error(
500, "sd-proxy script not called with path to configuration file"
)
p.on_done(p.res)

# read config. `read_conf` will call `p.on_done` if there is a config
# problem, and will return a Conf object on success.
conf_path = sys.argv[1]
p.conf = config.read_conf(conf_path, p)

# read user request from STDIN
incoming = []
for line in sys.stdin:
incoming.append(line)
incoming = "\n".join(incoming)

main.__main__(incoming, p)
Copy link
Contributor

@redshiftzero redshiftzero Sep 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we want two commits that:

  1. git mv sd-proxy.py into securedrop_proxy/entrypoint.py? (git mv to preserve git history)
  2. create start function (to make the changes clear)

otherwise we'll have two versions of this that are basically the same

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking to remove sd-proxy.py in a next commit :)

32 changes: 32 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import setuptools

with open("README.md", "r") as fh:
long_description = fh.read()

setuptools.setup(
name="securedrop-proxy",
version="0.1.0",
author="Freedom of the Press Foundation",
author_email="[email protected]",
description="SecureDrop Qubes proxy service",
long_description=long_description,
long_description_content_type="text/markdown",
license="GPLv3+",
install_requires=["requests","furl", "pyyaml", "werkzeug"],
python_requires=">=3.5",
url="https://github.com/freedomofpress/securedrop-proxy",
packages=setuptools.find_packages(exclude=["docs", "tests"]),
classifiers=(
"Development Status :: 3 - Alpha",
"Programming Language :: Python :: 3",
"Topic :: Software Development :: Libraries :: Python Modules",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
),
entry_points={
'console_scripts': [
'sd-proxy = securedrop_proxy.entrypoint:start',
],
},
)