{"action":"created","issue":{"url":"https://api.github.com/repos/brython-dev/brython/issues/491","repository_url":"https://api.github.com/repos/brython-dev/brython","labels_url":"https://api.github.com/repos/brython-dev/brython/issues/491/labels{/name}","comments_url":"https://api.github.com/repos/brython-dev/brython/issues/491/comments","events_url":"https://api.github.com/repos/brython-dev/brython/issues/491/events","html_url":"https://github.com/brython-dev/brython/issues/491","id":174407607,"number":491,"title":"Feature Request: Brython Production App Development Pipeline","user":{"login":"glyph","id":716529,"avatar_url":"https://avatars.githubusercontent.com/u/716529?v=3","gravatar_id":"","url":"https://api.github.com/users/glyph","html_url":"https://github.com/glyph","followers_url":"https://api.github.com/users/glyph/followers","following_url":"https://api.github.com/users/glyph/following{/other_user}","gists_url":"https://api.github.com/users/glyph/gists{/gist_id}","starred_url":"https://api.github.com/users/glyph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glyph/subscriptions","organizations_url":"https://api.github.com/users/glyph/orgs","repos_url":"https://api.github.com/users/glyph/repos","events_url":"https://api.github.com/users/glyph/events{/privacy}","received_events_url":"https://api.github.com/users/glyph/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"PierreQuentel","id":3447215,"avatar_url":"https://avatars.githubusercontent.com/u/3447215?v=3","gravatar_id":"","url":"https://api.github.com/users/PierreQuentel","html_url":"https://github.com/PierreQuentel","followers_url":"https://api.github.com/users/PierreQuentel/followers","following_url":"https://api.github.com/users/PierreQuentel/following{/other_user}","gists_url":"https://api.github.com/users/PierreQuentel/gists{/gist_id}","starred_url":"https://api.github.com/users/PierreQuentel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PierreQuentel/subscriptions","organizations_url":"https://api.github.com/users/PierreQuentel/orgs","repos_url":"https://api.github.com/users/PierreQuentel/repos","events_url":"https://api.github.com/users/PierreQuentel/events{/privacy}","received_events_url":"https://api.github.com/users/PierreQuentel/received_events","type":"User","site_admin":false},"assignees":[{"login":"PierreQuentel","id":3447215,"avatar_url":"https://avatars.githubusercontent.com/u/3447215?v=3","gravatar_id":"","url":"https://api.github.com/users/PierreQuentel","html_url":"https://github.com/PierreQuentel","followers_url":"https://api.github.com/users/PierreQuentel/followers","following_url":"https://api.github.com/users/PierreQuentel/following{/other_user}","gists_url":"https://api.github.com/users/PierreQuentel/gists{/gist_id}","starred_url":"https://api.github.com/users/PierreQuentel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PierreQuentel/subscriptions","organizations_url":"https://api.github.com/users/PierreQuentel/orgs","repos_url":"https://api.github.com/users/PierreQuentel/repos","events_url":"https://api.github.com/users/PierreQuentel/events{/privacy}","received_events_url":"https://api.github.com/users/PierreQuentel/received_events","type":"User","site_admin":false}],"milestone":null,"comments":66,"created_at":"2016-09-01T00:05:28Z","updated_at":"2016-11-26T08:04:51Z","closed_at":null,"body":"I've reported some of these issues before, some of them have been closed; but looking at the history of those discussions I don't think it was clear what I was asking for, so I want to try to write up a central tracking issue so that the core team can understand what I wish Brython could do.  The discussion mostly meandered around through performance issues, which, while extremely important, are not really what I care about _now_.\n\nSo, here's the problem: I find it very hard to get started developing an application in Brython.  [The official 'deploy'](https://brython.info/static_doc/en/deploy.html) documentation does not actually tell me how to deploy _my_ application at all, but rather, just how to load Brython itself into a web page.\n\nFirst off, as with any Python development tool, I expect to be able to `pip install brython` and start doing something with it.  Even if all this did was put the `.js` file somewhere on my filesystem, similar to the way [certifi](https://github.com/certifi/python-certifi) does nothing but print the location of a `.pem` file, it would be handy having this on PyPI as a way to quickly get started, rather than hunting around for a `.zip` file.\n\nSecond, it's not clear how to organize my front-end project.  If I were writing a Python project, I'd write a `setup.py` and perhaps a `requirements.txt` to pin versions.  If I were writing JavaScript, I'd use `browserify` along with `npm install`.  If I'm using Brython, where should I put my files so that `import` works cleanly?  If I want to write a Brython-compatible library, how do I install it?  How do I share my code with other developers?  Right now the only obvious thing is to either write your own web server, and invent some idiom for putting things onto `sys.path` from scratch.\n\nThird, once you have more than a few modules, start-up performance is really, really bad.  Unusably bad, even.  This is a recurring complaint, most recently in #461.  Brython's performance itself is actually perfectly acceptable, if only it could skip the catastrophic load-time hit of transpiling everything from JavaScript every time.  This is related to the second problem, because if we had a way to organize and declare a hierarchy of brython-friendly code that could be imported, and a command to install it and deploy it to the browser, then optimizing startup performance is just a question of translating `.py` files to `.pyc.js` files, and then adding them to a `.vfs` file.  This is also related to the first problem, because if we had `pip install brython`, then in addition to printing the location of `brython.js`, this file could easily also have a `brython compile` subcommand that would produce said `.vfs` file.\n\nFourth, what does automated testing of a Brython project look like?  Firing up an actual browser is really bad for an interactive red/green/refactor testing workflow, not to mention that it's not clear how to deploy that to Travis-CI.\n\nAll together, I want to do something like this.\n\n``` console\n$ mkdir mybry\n$ mkvirtualenv -p `which python 3.5` mybrythonapp\n$ pip install brython\n$ $EDTIOR setup.py\n$ $EDITOR mybry/__init__.py blub.txt\n$ $EDITOR web/index.html\n$ python setup.py bdist_wheel\n$ brython bundle --used-by=web/index.html --used-by=web/about.html --used-by=web/login.html --output web/__brython_cache__.vfs.js --include=dist/*.whl\n$ twist web --path web/\n$ open http://localhost:8080/\n$ brython test 'mybry.test.*'\n```\n\nBy convention, `brython.js` could then try pre-loading `/__brython_cache__.vfs.js` to prepopulate `sys.modules` with already-compiled-to-javascript modules.  You could also have other `brython` shell commands which would set up symlinks for easy re-loading during development.\n\nThe _exact_ details of this aren't important though; I just wanted to give one possible example.  There are a lot of ways that this could work.\n\nThe current state of the Brython introduction is the same as a Python tutorial that just says \"put all your code in one file, you probably won't need two files\".\n\nIn my opinion this is the _most_ important thing that Brython needs to do, in order for mainstream web developers (who, right now, in JavaScript, have advanced build-and-deploy pipelines with grunt and gulp and npm and browserify and a dozen other tools, and in Python, have precompiled wheels and Docker images and so on) to be able to take it seriously for frontend applications that include more than one module.\n\nI hope that this has made it clear what I want from Brython and serves for a good basis for a discussion.\n"},"comment":{"url":"https://api.github.com/repos/brython-dev/brython/issues/comments/263050453","html_url":"https://github.com/brython-dev/brython/issues/491#issuecomment-263050453","issue_url":"https://api.github.com/repos/brython-dev/brython/issues/491","id":263050453,"user":{"login":"glyph","id":716529,"avatar_url":"https://avatars.githubusercontent.com/u/716529?v=3","gravatar_id":"","url":"https://api.github.com/users/glyph","html_url":"https://github.com/glyph","followers_url":"https://api.github.com/users/glyph/followers","following_url":"https://api.github.com/users/glyph/following{/other_user}","gists_url":"https://api.github.com/users/glyph/gists{/gist_id}","starred_url":"https://api.github.com/users/glyph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glyph/subscriptions","organizations_url":"https://api.github.com/users/glyph/orgs","repos_url":"https://api.github.com/users/glyph/repos","events_url":"https://api.github.com/users/glyph/events{/privacy}","received_events_url":"https://api.github.com/users/glyph/received_events","type":"User","site_admin":false},"created_at":"2016-11-26T08:04:51Z","updated_at":"2016-11-26T08:04:51Z","body":"> In the current version of the brython package there is a server, but I don't think it's really useful, the HTML page works very well without a server, and when uploaded it's the site server that is used. Anyway I'd rather not add a dependancy to a specific server in setup.py.\r\n\r\nActually, it occurs to me that adding a server-specific dependency will make it too hard to use features like CDNs, so let me think about how to do this from within the `brython` tool.\r\n\r\n> As for the additional modules, I'm not sure to understand what .bundle-ignore would do. What would be in it, and if it's a reference to these modules, how would they be added in the directory where you run python -m brython --install ? If you can do a PR that would be great.\r\n\r\n`.bundle-include`, you mean?\r\n\r\nLet's say you did `pip install mybrowserlib`, which installed the following:\r\n\r\n```\r\n+ site-packages\r\n    + mybrowserlib\r\n        __init__.py\r\n        a.py\r\n        b.py\r\n        c.py\r\n```\r\n\r\nIf your browser app used `mybrowserlib` and `mybrowserlib.c` but not `mybrowserlib.a` or `mybrowserlib.b`, you could add a `.bundle-include` to your project that does\r\n\r\n```\r\nmybrowserlib\r\nmybrowserlib.c\r\n```\r\n\r\nand then `python -m brython --install` would generate a `brython_modules.js` containing the translated versions of `mybrowserlib/__init__.py` and `mybrowserlib/c.py`.\r\n\r\nNevertheless I will see if I can do a PR sometime next week."}}
{"actor":{"display_login":"glyph"}}