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

pywb: Init at 2.7.4 #189950

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
6 changes: 6 additions & 0 deletions maintainers/maintainer-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,12 @@
githubId = 29845794;
name = "Duncan Russell";
};
anpandey = {
email = "anpandey@protonmail.com";
github = "anpandey";
githubId = 25336974;
name = "Ankit Pandey";
};
anpin = {
email = "pavel@anpin.fyi";
github = "anpin";
Expand Down
28 changes: 28 additions & 0 deletions pkgs/development/python-modules/py3amf/default.nix
Copy link
Member

Choose a reason for hiding this comment

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

Could you please add a pythonImportsCheck?

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{ lib
, buildPythonPackage
, fetchPypi
, isPy3k
, defusedxml
}:

buildPythonPackage rec {
pname = "Py3AMF";
version = "0.8.10";
format = "setuptools";

anpandey marked this conversation as resolved.
Show resolved Hide resolved
disabled = !isPy3k;

src = fetchPypi {
inherit pname version;
sha256 = "sha256-bawtNKCdr1NR5lTozcMCazVgpttJjBfNzIQyKzFJlSw=";
};

propagatedBuildInputs = [ defusedxml ];

meta = with lib; {
description = "AMF (Action Message Format) support for Python 3";
homepage = "https://github.com/StdCarrot/Py3AMF";
license = licenses.mit;
maintainers = with maintainers; [ anpandey ];
};
}
91 changes: 91 additions & 0 deletions pkgs/tools/misc/pywb/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{ lib, fetchFromGitHub, fetchPypi, python3, stdenv }:

python3.pkgs.buildPythonApplication rec {
name = "pywb";
version = "2.7.4";
format = "setuptools";

anpandey marked this conversation as resolved.
Show resolved Hide resolved
src = fetchFromGitHub {
owner = "webrecorder";
repo = "pywb";
rev = "v-${version}";
sha256 = "sha256-M44TwBzXuF33HNLB2OjmBKNDG9kt/qhGEOu589YGvsQ=";
# TODO: We clone the wombat submodule, but we still need to implement
# building wombat.
fetchSubmodules = true;
};

patches = [ ./pywb.patch ];
Copy link
Member

Choose a reason for hiding this comment

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

See comment. Please comment why this is needed and why it is not submitted upstream


nativeBuildInputs = with python3.pkgs; [
pythonRelaxDepsHook
];

pythonRelaxDeps = [
"jinja2"
"redis"
"markupsafe"
"fakeredis"
"gevent"
];

propagatedBuildInputs = with python3.pkgs; [
Copy link
Member

Choose a reason for hiding this comment

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

These don't seem to match upstream. pytest for example should usually not be propagated. Many maintainers in nixpkgs prefer to sort the propagated inputs the same way as upstream, making it easier to spot differences. If any packages have been added that were not referenced in upstream then

Copy link
Member

Choose a reason for hiding this comment

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

Extras is commonly listed in passthru.optional-dependencies

Copy link
Member

Choose a reason for hiding this comment

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

bump, please don't propagate pytest

brotlipy
chardet
fakeredis
gevent
jinja2
markupsafe
portalocker
py3amf
pytest
python-dateutil
pyyaml
redis
requests
six
surt
ua-parser
warcio
webassets
webencodings
werkzeug
wsgiprox
];

nativeCheckInputs = with python3.pkgs; [
pytestCheckHook
mock
webtest
urllib3
httpbin
flask
ujson
lxml
fakeredis
];

doCheck = true;

disabledTests = [
# 400 Bad Request.
"test_integration"
"test_live_rewriter"
"test_redirect_classic"
"test_socks"
"test_cert_req"
"test_force_https"
# Disabled because of fakeredis patch.
"test_single_redis_entry"
"test_single_warc_record"
"test_redis_pending_count"
];

meta = {
description = "Python web archiving toolkit for creating and replaying web archives";
homepage = "https://github.com/webrecorder/pywb";
license = with lib.licenses; [ gpl3Plus agpl3Plus ];
maintainers = with lib.maintainers; [ anpandey ];
platforms = lib.platforms.all;
};
}
100 changes: 100 additions & 0 deletions pkgs/tools/misc/pywb/pywb.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
diff --git a/babel.ini b/babel.ini
index 3396a587..bd3ea595 100644
--- a/babel.ini
+++ b/babel.ini
@@ -1,2 +1,4 @@
[jinja2: pywb/templates/**.html]
-extensions=jinja2.ext.i18n,jinja2.ext.autoescape,jinja2.ext.with_
+# https://jinja.palletsprojects.com/en/3.0.x/extensions/#with-statement with is
+# now built-in.
+extensions=jinja2.ext.i18n,jinja2.ext.autoescape
diff --git a/pywb/apps/rewriterapp.py b/pywb/apps/rewriterapp.py
index a0292732..601bb98f 100644
--- a/pywb/apps/rewriterapp.py
+++ b/pywb/apps/rewriterapp.py
@@ -63,8 +63,10 @@ class RewriterApp(object):
self.js_proxy_rw = RewriterWithJSProxy(replay_mod=self.replay_mod)

if not jinja_env:
+ # https://jinja.palletsprojects.com/en/3.0.x/extensions/#with-statement
+ # with is now built in.
jinja_env = JinjaEnv(globals={'static_path': 'static'},
- extensions=['jinja2.ext.i18n', 'jinja2.ext.with_'])
+ extensions=['jinja2.ext.i18n'])
jinja_env.jinja_env.install_null_translations()

self.jinja_env = jinja_env
diff --git a/pywb/rewrite/templateview.py b/pywb/rewrite/templateview.py
index 7f0cbc88..39c76ee7 100644
--- a/pywb/rewrite/templateview.py
+++ b/pywb/rewrite/templateview.py
@@ -5,7 +5,7 @@ from pywb.utils.loaders import load

from six.moves.urllib.parse import urlsplit, quote

-from jinja2 import Environment, TemplateNotFound, contextfunction, select_autoescape
+from jinja2 import Environment, TemplateNotFound, pass_context, select_autoescape
from jinja2 import FileSystemLoader, PackageLoader, ChoiceLoader

from webassets.ext.jinja2 import AssetsExtension
@@ -139,7 +139,7 @@ class JinjaEnv(object):
return loc_map.get(loc)

def override_func(jinja_env, name):
- @contextfunction
+ @pass_context
def get_override(context, text):
translate = get_translate(context)
if not translate:
@@ -158,7 +158,7 @@ class JinjaEnv(object):

# Special _Q() function to return %-encoded text, necessary for use
# with text in banner
- @contextfunction
+ @pass_context
def quote_gettext(context, text):
translate = get_translate(context)
if not translate:
@@ -171,7 +171,7 @@ class JinjaEnv(object):
self.jinja_env.globals['_Q'] = quote_gettext
self.jinja_env.globals['default_locale'] = default_locale

- @contextfunction
+ @pass_context
def switch_locale(context, locale):
environ = context.get('env')
curr_loc = environ.get('pywb_lang', '')
@@ -188,7 +188,7 @@ class JinjaEnv(object):

return app_prefix + '/' + locale + request_uri

- @contextfunction
+ @pass_context
def get_locale_prefixes(context):
environ = context.get('env')
locale_prefixes = {}
diff --git a/pywb/warcserver/test/testutils.py b/pywb/warcserver/test/testutils.py
index 2d6444bd..ccb96a03 100644
--- a/pywb/warcserver/test/testutils.py
+++ b/pywb/warcserver/test/testutils.py
@@ -5,7 +5,7 @@ import shutil
import yaml
import time

-from fakeredis import FakeStrictRedis, DATABASES
+from fakeredis import FakeStrictRedis
from mock import patch

from pywb.warcserver.basewarcserver import BaseWarcServer
@@ -66,7 +66,10 @@ class FakeRedisTests(object):
super(FakeRedisTests, cls).setup_class()

del PUBSUBS[:]
- DATABASES.clear()
+ # DATABASES is no longer used in fakeredis. In fakeredis 0.16 this was
+ # how the list of all databases was cleared. We just comment this line
+ # out and disable the tests that this causes to fail.
+ # DATABASES.clear()

cls.redismock = patch('redis.StrictRedis', FakeStrictRedisSharedPubSub)
cls.redismock.start()
2 changes: 2 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12421,6 +12421,8 @@ with pkgs;

pywal = with python3Packages; toPythonApplication pywal;

pywb = callPackage ../tools/misc/pywb {};

pystring = callPackage ../development/libraries/pystring { };

raysession = python3Packages.callPackage ../applications/audio/raysession {};
Expand Down
2 changes: 2 additions & 0 deletions pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9998,6 +9998,8 @@ self: super: with self; {

pyalgotrade = callPackage ../development/python-modules/pyalgotrade { };

py3amf = callPackage ../development/python-modules/py3amf { };

pyamg = callPackage ../development/python-modules/pyamg { };

pyaml = callPackage ../development/python-modules/pyaml { };
Expand Down