[PATCH] gnu: Add brython.

  • Done
  • quality assurance status badge
Details
4 participants
  • jgart
  • Ludovic Courtès
  • Maxim Cournoyer
  • Ricardo Wurmus
Owner
unassigned
Submitted by
jgart
Severity
normal
J
(address . guix-patches@gnu.org)
6c81552237809c87c157684e550a69a7@dismail.de
Hi Guix!

Here is brython. Thank you!

This was an effort of today's Guix Packaging Meetup.

best regards,

jgart

libremiami.org
L
L
Ludovic Courtès wrote on 1 Apr 2021 14:26
(name . jgart)(address . jgart@dismail.de)
87czve9omx.fsf@gnu.org
Hi,

"jgart" <jgart@dismail.de> skribis:

Toggle quote (2 lines)
> This was an effort of today's Guix Packaging Meetup.

Nice!

Toggle quote (15 lines)
> From 519c8d5e5369744cadbe4bc7607b0c4c8f05128a Mon Sep 17 00:00:00 2001
> From: LibreMiami <packaging-guix@libremiami.org>
> Date: Sun, 28 Mar 2021 21:13:31 -0400
> Subject: [PATCH 2/2] gnu: Add brython.
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
>
> * gnu/packages/web.scm (brython): New variable.
>
> Co-authored-by: Léo Le Bouter <lle-bout@zaclys.net>
> Co-authored-by: jgart <jgart@dismail.de>
> Co-authored-by: Ryan Prior <rprior@protonmail.com>
> Co-authored-by: Andrea Pierré <a.pierre@zaclys.net>

[...]

Toggle quote (6 lines)
> + (native-inputs
> + `(; 'install phase needs the python command
> + ("python" ,((package-input-rewriting
> + `((,python . ,python-3.9))
> + #:deep? #f) python-wrapper))))

That’s likely to perform very poorly. Normally, you’d save the result
of ‘package-input-rewriting’ (a procedure) in a variable and reuse it
anytime you need to make that transformation, so that caching can kick
in.

Toggle quote (3 lines)
> + (arguments
> + `(#:python ,python-3.9 ; required during build

In current ‘master’, all Python 3.x package are built against 3.8. I
think we should stick to that and not introduce different dependencies
as this can only lead to bad surprises.

Can Brython be built against 3.8? If not, I think it’ll have to go to
the ‘core-updates’ branch, which may be merged soon after the release
(end of April).

WDYT?

Toggle quote (3 lines)
> + (lambda* (#:key outputs #:allow-other-keys)
> + ;; write access is required to .js files for minifying

Nitpick: Please capitalize sentences and end with a period (here and
elsewhere).

Toggle quote (3 lines)
> + (for-each
> + (lambda (vv) (chmod vv #o644))

Use ‘make-file-writable’ instead of this lambda.

Toggle quote (3 lines)
> + (invoke "python3" "scripts/make_dist.py")
> + #t))

No need for the trailing #t.

Toggle quote (3 lines)
> + (synopsis
> + "Run python code in a web browser")

This can be on a single line.

Toggle quote (3 lines)
> + (description
> + "@code{Brython} is a compliant implementation of Python 3 that allows

You can remove @code here (@code is only used for inline code snippets
and similar things).

Thanks!

Ludo’.
J
J
jgart wrote on 5 Jul 2021 21:48
[PATCH] * gnu/packages/web.scm (brython): New variable.
(address . 47459@debbugs.gnu.org)
20210705194813.19624-1-jgart@dismail.de
From: LibreMiami <packaging-guix@libremiami.org>

Co-authored-by: Andrea Pierré <a.pierre@zaclys.net>
Co-authored-by: jgart <jgart@dismail.de>
Co-authored-by: Léo Le Bouter <lle-bout@zaclys.net>
Co-authored-by: Ryan Prior <rprior@protonmail.com>
---
gnu/packages/python-web.scm | 48 +++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)

Toggle diff (61 lines)
diff --git a/gnu/packages/python-web.scm b/gnu/packages/python-web.scm
index e4d1326fb8..9b692c2ade 100644
--- a/gnu/packages/python-web.scm
+++ b/gnu/packages/python-web.scm
@@ -329,6 +329,54 @@ communicate with each other, and positioned as an asynchronous successor to
WSGI. This package includes libraries for implementing ASGI servers.")
(license license:bsd-3)))
+(define-public brython
+ (package
+ (name "brython")
+ (version "3.9.5")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/brython-dev/brython")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0ikxhvgy1zdg8zrdx2bajp1v7r9dhk6v9jan20i05ahvm9s8gfd6"))))
+ (build-system python-build-system)
+ (native-inputs
+ `(("python" ,python)))
+ (arguments
+ `(#:tests? #f ; tests require npm packages
+ #:phases
+ (modify-phases %standard-phases
+ (replace 'build
+ (lambda* (#:key outputs #:allow-other-keys)
+ ;; Write access is required for minifying javascript files.
+ (for-each make-file-writable
+ (find-files "." "\\.js$"))
+
+ ;; Patch build scripts to reference source directory properly.
+ (substitute* (find-files "scripts" "\\.py$")
+ (("os\\.path\\.dirname\\(os\\.getcwd\\(\\)\\)")
+ (string-append "\"" (getcwd) "\"")))
+
+ (invoke "python3" "scripts/make_dist.py")
+ #t))
+ (replace 'install
+ (lambda args
+ ;; setup.py is within 'setup' subdirectory
+ (with-directory-excursion "setup"
+ (invoke "python3" "setup.py" "sdist")
+ (apply (assoc-ref %standard-phases 'install) args))
+ #t)))))
+ (home-page "http://brython.info")
+ (synopsis "Run python code in a web browser")
+ (description
+"@code{Brython} is a compliant implementation of Python 3 that allows
+writing end-user applications in Python that run in the browser.")
+ (license license:bsd-3)))
+
(define-public python-css-html-js-minify
(package
(name "python-css-html-js-minify")
--
2.31.1
J
J
jgart wrote on 6 Jul 2021 00:29
brython bump to 3.9.5 and fixes for core-updates branch
(address . 47459@debbugs.gnu.org)
46d8aebe2811380cf79b2ef56e14e1c2@dismail.de
Hi Ludo,

Thank you for your suggestions! They are much appreciated. I think I incorporated all of them and
bumped brython from 3.9.1 to 3.9.5 since it's been a while... Sorry for the delay. I hope this patch finds you
well. The above patch was taken from core-updates.

I tried adding a message via the mumi interface but it never went through...
M
M
Maxim Cournoyer wrote on 22 Jun 2022 21:23
Re: bug#47459: [PATCH] gnu: Add brython.
87pmj04i55.fsf_-_@gmail.com
tags 47459 moreinfo
thanks

Hi,

"jgart" <jgart@dismail.de> writes:

Toggle quote (8 lines)
> Hi Ludo,
>
> Thank you for your suggestions! They are much appreciated. I think I incorporated all of them and
> bumped brython from 3.9.1 to 3.9.5 since it's been a while... Sorry for the delay. I hope this patch finds you
> well. The above patch was taken from core-updates.
>
> I tried adding a message via the mumi interface but it never went through...

I wanted to merge this in, but as I looked at it, I got curious about
the "source" that is on the heavy side (53 MiB), and saw what look like
generated "source" code:

du -h www/src/py_VFS.js
4.3M www/src/py_VFS.js

The file contains section that read like:

Toggle snippet (3 lines)
9, 0xFF89,0xCA, 0xFF8A,0xCB, 0xFF8B,0xCC, 0xFF8C,0xCD, 0xFF8D,0xCE, 0xFF8E,0xCF, 0xFF8F,0xD0, 0xFF90,0xD1, 0xFF91,0xD2, 0xFF92,0xD3, 0xFF93,0xD4, 0xFF94,0xD5, 0xFF95,0xD6, 0xFF96,0xD7, 0xFF97,0xD8, 0xFF98,0xD9, 0xFF99,0xDA, 0xFF9A,0xDB, 0xFF9B,0xDC, 0xFF9C,0xDD, 0xFF9D,0xDE, 0xFF9E,0xDF, 0xFF9F,0xE0, -1,0xE1, -1,0xE2, -1,0xE3, -1,0xE4, -1,0xE5, -1,0xE6, -1,0xE7, -1,0xE8, -1,0xE9, -1,0xEA, -1,0xEB, -1,0xEC, -1,0xED, -1,0xEE, -1,0xEF, -1,0xF0, -1,0xF1, -1,0xF2, -1,0xF3, -1,0xF4, -1,0xF5, -1,0xF6, -1,0xF7, -1,0xF8, -1,0xF9, -1,0xFA, -1,0xFB, -1,0xFC, -1,0xFD, -1,0xFE, -1,0xFF, -1,0x8140, 0x3000,0x8141, 0x3001,0x8142, 0x3002,0x8143, 0xFF0C,0x8144, 0xFF0E,0x8145, 0x30FB,0x8146, 0xFF1A,0x8147, 0xFF1B,0x8148, 0xFF1F,0x8149, 0xFF01,0x814A, 0x309B,0x814B, 0x309C,0x814C, 0x00B4,0x814D, 0xFF40,0x814E, 0x00A8,0x814F, 0xFF3E,0x8150, 0xFFE3,0x8151, 0xFF3F,0x8152, 0x30FD,0x8153, 0x30FE,0x8154, 0x309D,0x8155, 0x309E,0x8156, 0x3003,0x8157, 0x4EDD,0x8158, 0x3005,0x8159, 0x3006,0x815A, 0x3007,0x815B, 0x30FC,0x815C, 0x2015,0x815D, 0x2010,0x815E, 0xFF0F,0x815F, 0xFF3C,0x8160, 0xFF5E,0x8161, 0x2225,0x8162, 0xFF5C,0x8163, 0x2026,0x8164, 0x2025,0x8165, 0x2018,0x8166, 0x2019,0x8167, 0x201C,0x8168, 0x201D,0x8169, 0xFF08,0x816A, 0xFF09,0x816B, 0x3014,0x816C, 0x3015,0x816D, 0xFF3B,0x816E, 0xFF3D,0x816F, 0xFF5B,0x8170, 0xFF5D,0x8171, 0x3008,0x8172, 0x3009,0x8173, 0x300A,0x8174, 0x300B,0x8175, 0x300C,0x8176, 0x300D,0x8177, 0x300E,0x8178, 0x300F,0x8179, 0x3010,0x817A, 0x3011,0x817B, 0xFF0B,0x817C, 0xFF0D,0x817D, 0x00B1,0x817E, 0x00D7,0x8180, 0x00F7,0x8181, 0xFF1D,0x8182, 0x2260,0x8183, 0xFF1C,0x8184, 0xFF1E,0x8185, 0x2266,0x8186, 0x2267,0x8187, 0x221E,0x8188, 0x2234,0x8189, 0x2642,0x818A, 0x2640,0x818B, 0x00B0,0x818C, 0x2032,0x818D, 0x2033,0x818E, 0x2103,0x818F, 0xFFE5,0x8190, 0xFF04,0x8191, 0xFFE0,0x8192, 0xFFE1,0x8193, 0xFF05,0x8194, 0xFF03,0x8195, 0xFF06,0x8196, 0xFF0A,0x8197, 0xFF20,0x8198, 0x00A7,0x8199, 0x2606,0x819A, 0x2605,0x819B, 0x25CB,0x819C, 0x25CF,0x819D, 0x25CE,0x819E, 0x25C7,0x819F, 0x25C6,0x81A0, 0x25A1,0x81A1, 0x25A0,0x81A2, 0x25B3,0x81A3, 0x25B2,0x81A4, 0x25BD,0x81A5, 0x25BC,0x81A6, 0x203B,0x81A7, 0x3012,0x81A8, 0x2192,0x81A9, 0x2190,0x81AA, 0x2191,0x81AB, 0x2193,0x81AC, 0x3013,0x81B8, 0x2208,0x81B9, 0x220B,0x81BA, 0x2286,0x81BB, 0x2287,0x81BC, 0x2282,0x81BD, 0x2283,0x81BE, 0x222A,0x81BF, 0x2229,0x81C8,

I don't think this qualifies as source code.

Could you look into how these source come into existence? Otherwise
it's akin to bundling binaries, which we strive to not do in Guix.

Thanks,

Maxim
M
M
Maxim Cournoyer wrote on 28 Sep 2022 20:24
(name . jgart)(address . jgart@dismail.de)
87ill7uzl1.fsf_-_@gmail.com
Hi,

Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:

Toggle quote (16 lines)
> I wanted to merge this in, but as I looked at it, I got curious about
> the "source" that is on the heavy side (53 MiB), and saw what look like
> generated "source" code:
>
> du -h www/src/py_VFS.js
> 4.3M www/src/py_VFS.js
>
> The file contains section that read like:
>
> 9, 0xFF89,0xCA, 0xFF8A,0xCB, 0xFF8B,0xCC, 0xFF8C,0xCD, 0xFF8D,0xCE, 0xFF8E,0xCF, 0xFF8F,0xD0, 0xFF90,0xD1, 0xFF91,0xD2, 0xFF92,0xD3, 0xFF93,0xD4, 0xFF94,0xD5, 0xFF95,0xD6, 0xFF96,0xD7, 0xFF97,0xD8, 0xFF98,0xD9, 0xFF99,0xDA, 0xFF9A,0xDB, 0xFF9B,0xDC, 0xFF9C,0xDD, 0xFF9D,0xDE, 0xFF9E,0xDF, 0xFF9F,0xE0, -1,0xE1, -1,0xE2, -1,0xE3, -1,0xE4, -1,0xE5, -1,0xE6, -1,0xE7, -1,0xE8, -1,0xE9, -1,0xEA, -1,0xEB, -1,0xEC, -1,0xED, -1,0xEE, -1,0xEF, -1,0xF0, -1,0xF1, -1,0xF2, -1,0xF3, -1,0xF4, -1,0xF5, -1,0xF6, -1,0xF7, -1,0xF8, -1,0xF9, -1,0xFA, -1,0xFB, -1,0xFC, -1,0xFD, -1,0xFE, -1,0xFF, -1,0x8140, 0x3000,0x8141, 0x3001,0x8142, 0x3002,0x8143, 0xFF0C,0x8144, 0xFF0E,0x8145, 0x30FB,0x8146, 0xFF1A,0x8147, 0xFF1B,0x8148, 0xFF1F,0x8149, 0xFF01,0x814A, 0x309B,0x814B, 0x309C,0x814C, 0x00B4,0x814D, 0xFF40,0x814E, 0x00A8,0x814F, 0xFF3E,0x8150, 0xFFE3,0x8151, 0xFF3F,0x8152, 0x30FD,0x8153, 0x30FE,0x8154, 0x309D,0x8155, 0x309E,0x8156, 0x3003,0x8157, 0x4EDD,0x8158, 0x3005,0x8159, 0x3006,0x815A, 0x3007,0x815B, 0x30FC,0x815C, 0x2015,0x815D, 0x2010,0x815E, 0xFF0F,0x815F, 0xFF3C,0x8160, 0xFF5E,0x8161, 0x2225,0x8162, 0xFF5C,0x8163, 0x2026,0x8164, 0x2025,0x8165, 0x2018,0x8166, 0x2019,0x8167, 0x201C,0x8168, 0x201D,0x8169, 0xFF08,0x816A, 0xFF09,0x816B, 0x3014,0x816C, 0x3015,0x816D, 0xFF3B,0x816E, 0xFF3D,0x816F, 0xFF5B,0x8170, 0xFF5D,0x8171, 0x3008,0x8172, 0x3009,0x8173, 0x300A,0x8174, 0x300B,0x8175, 0x300C,0x8176, 0x300D,0x8177, 0x300E,0x8178, 0x300F,0x8179, 0x3010,0x817A, 0x3011,0x817B, 0xFF0B,0x817C, 0xFF0D,0x817D, 0x00B1,0x817E, 0x00D7,0x8180, 0x00F7,0x8181, 0xFF1D,0x8182, 0x2260,0x8183, 0xFF1C,0x8184, 0xFF1E,0x8185, 0x2266,0x8186, 0x2267,0x8187, 0x221E,0x8188, 0x2234,0x8189, 0x2642,0x818A, 0x2640,0x818B, 0x00B0,0x818C, 0x2032,0x818D, 0x2033,0x818E, 0x2103,0x818F, 0xFFE5,0x8190, 0xFF04,0x8191, 0xFFE0,0x8192, 0xFFE1,0x8193, 0xFF05,0x8194, 0xFF03,0x8195, 0xFF06,0x8196, 0xFF0A,0x8197, 0xFF20,0x8198, 0x00A7,0x8199, 0x2606,0x819A, 0x2605,0x819B, 0x25CB,0x819C, 0x25CF,0x819D, 0x25CE,0x819E, 0x25C7,0x819F, 0x25C6,0x81A0, 0x25A1,0x81A1, 0x25A0,0x81A2, 0x25B3,0x81A3, 0x25B2,0x81A4, 0x25BD,0x81A5, 0x25BC,0x81A6, 0x203B,0x81A7, 0x3012,0x81A8, 0x2192,0x81A9, 0x2190,0x81AA, 0x2191,0x81AB, 0x2193,0x81AC, 0x3013,0x81B8, 0x2208,0x81B9, 0x220B,0x81BA, 0x2286,0x81BB, 0x2287,0x81BC, 0x2282,0x81BD, 0x2283,0x81BE, 0x222A,0x81BF, 0x2229,0x81C8,
>
> I don't think this qualifies as source code.
>
> Could you look into how these source come into existence? Otherwise
> it's akin to bundling binaries, which we strive to not do in Guix.

No news; closing.

Maxim
Closed
J
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
20220928153852.GI1906@dismail.de
On Wed, 28 Sep 2022 14:24:26 -0400 Maxim Cournoyer <maxim.cournoyer@gmail.com> wrote:
OK, thanks
Closed
R
R
Ricardo Wurmus wrote on 28 Sep 2022 22:36
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
87pmffs07z.fsf@elephly.net
Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:

Toggle quote (11 lines)
> Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:
>
>> I wanted to merge this in, but as I looked at it, I got curious about
>> the "source" that is on the heavy side (53 MiB), and saw what look like
>> generated "source" code:
>>
>> du -h www/src/py_VFS.js
>> 4.3M www/src/py_VFS.js
>>
>> The file contains section that read like: [binary gibberish]

There’s an upstream discussion about these files:


“the files brython.js, py_VFS.js or brython_dist.js […] are generated
from the rest of the files”
“In general, the brython.js, py_VFS.js or brython_dist.js are usually
generated by Pierre after a PR or before a new release except if you
want to check something specific in your own or if you want to create
a version for your site with your specific unofficial changes.”

This suggests that there should be a way to generate them from the other
built files.

--
Ricardo
Closed
R
Closed
M
M
Maxim Cournoyer wrote on 29 Sep 2022 03:28
(name . Ricardo Wurmus)(address . rekado@elephly.net)
87h70rnf45.fsf@gmail.com
Hi Ricardo,

Ricardo Wurmus <rekado@elephly.net> writes:

Toggle quote (9 lines)
> Ricardo Wurmus <rekado@elephly.net> writes:
>
>> This suggests that there should be a way to generate them from the other
>> built files.
>
> This is where py_VFS.js is generated:
>
> https://github.com/brython-dev/brython/blob/270fb6ffe3a31c9f5d5897f7228f5c08a3701868/scripts/make_VFS.py

Interesting! jgart, if you'd like give it a try, it seems the package
definition should be fixable, via a snippet or a phase that'd generate
the binaries used as "source".

Thanks!

--
Maxim
Closed
?