{"html_url": "https://github.com/simonw/datasette/issues/211#issuecomment-381482407", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/211", "id": 381482407, "node_id": "MDEyOklzc3VlQ29tbWVudDM4MTQ4MjQwNw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-04-16T05:18:29Z", "updated_at": "2018-04-16T05:18:29Z", "author_association": "OWNER", "body": "Here's the result of running this:\r\n\r\n datasette publish heroku fivethirtyeight.db \\\r\n --plugins-dir=plugins/ --title=\"FiveThirtyEight\" --branch=plugins-dir\r\n\r\nhttps://intense-river-24599.herokuapp.com/fivethirtyeight-2628db9?sql=select+convert_units%28100%2C+%27m%27%2C+%27ft%27%29", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 314471743, "label": "Load plugins from a `--plugins-dir=plugins/` directory"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/211#issuecomment-381481990", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/211", "id": 381481990, "node_id": "MDEyOklzc3VlQ29tbWVudDM4MTQ4MTk5MA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-04-16T05:14:57Z", "updated_at": "2018-04-16T05:14:57Z", "author_association": "OWNER", "body": "Added unit tests in 33c6bcadb962457be6b0c7f369826b404e2bcef5", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 314471743, "label": "Load plugins from a `--plugins-dir=plugins/` directory"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/211#issuecomment-381478253", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/211", "id": 381478253, "node_id": "MDEyOklzc3VlQ29tbWVudDM4MTQ3ODI1Mw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-04-16T04:42:02Z", "updated_at": "2018-04-16T04:42:02Z", "author_association": "OWNER", "body": "This worked as well:\r\n\r\n datasette package fivethirtyeight.db \\\r\n --plugins-dir=plugins/ --title=\"FiveThirtyEight\" --branch=plugins-dir\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 314471743, "label": "Load plugins from a `--plugins-dir=plugins/` directory"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/211#issuecomment-381478217", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/211", "id": 381478217, "node_id": "MDEyOklzc3VlQ29tbWVudDM4MTQ3ODIxNw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-04-16T04:41:38Z", "updated_at": "2018-04-16T04:41:38Z", "author_association": "OWNER", "body": "Here's the result of running:\r\n\r\n datasette publish now fivethirtyeight.db \\\r\n --plugins-dir=plugins/ --title=\"FiveThirtyEight\" --branch=plugins-dir\r\n\r\nhttps://datasette-phjtvzwwzl.now.sh/fivethirtyeight-2628db9?sql=select+convert_units%28100%2C+%27m%27%2C+%27ft%27%29\r\n\r\nWhere `plugins/pint_plugin.py` contains the following:\r\n```\r\nfrom datasette import hookimpl\r\nimport pint\r\n\r\nureg = pint.UnitRegistry()\r\n\r\n@hookimpl\r\ndef prepare_connection(conn):\r\n def convert_units(amount, from_, to_):\r\n \"select convert_units(100, 'm', 'ft');\"\r\n return (amount * ureg(from_)).to(to_).to_tuple()[0]\r\n conn.create_function('convert_units', 3, convert_units)\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 314471743, "label": "Load plugins from a `--plugins-dir=plugins/` directory"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/211#issuecomment-381462005", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/211", "id": 381462005, "node_id": "MDEyOklzc3VlQ29tbWVudDM4MTQ2MjAwNQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-04-16T02:23:07Z", "updated_at": "2018-04-16T02:23:07Z", "author_association": "OWNER", "body": "This needs unit tests. I also need to manually test the `datasette package` and `datesette publish` commands.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 314471743, "label": "Load plugins from a `--plugins-dir=plugins/` directory"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/211#issuecomment-381456434", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/211", "id": 381456434, "node_id": "MDEyOklzc3VlQ29tbWVudDM4MTQ1NjQzNA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-04-16T01:36:16Z", "updated_at": "2018-04-16T01:37:44Z", "author_association": "OWNER", "body": "The easiest way to implement this in Python 2 would be `execfile(...)` - but that was removed in Python 3. According to https://stackoverflow.com/a/437857/6083 `2to3` replaces that with this, which ensures the filename is associated with the code for debugging purposes:\r\n\r\n```\r\nwith open(\"somefile.py\") as f:\r\n code = compile(f.read(), \"somefile.py\", 'exec')\r\n exec(code, global_vars, local_vars)\r\n```\r\n\r\nImplementing it this way would force this kind of plugin to be self-contained in a single file. I think that's OK: if you want a more complex plugin you can use the standard pluggy-powered setuptools mechanism to build it.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 314471743, "label": "Load plugins from a `--plugins-dir=plugins/` directory"}, "performed_via_github_app": null}