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

package as a standalone binary #93

Open
atomotic opened this issue Nov 14, 2017 · 9 comments

Comments

@atomotic
Copy link

commented Nov 14, 2017

hint: more than the docker image a standalone and multiplatform binary (containing the app and the database) could be simpler to distribute.

i would like to investigate the possibility to package everything with pyinstaller adding the database as a data file

@simonw

This comment has been minimized.

Copy link
Owner

commented Nov 14, 2017

Even without bundling in the database file itself, I'd love to have a standalone binary version of the core datasette CLI utility.

I think Sanic may have some complex dependencies, but I've never tried pyinstaller so I don't know how easy or hard it would be to get this working.

@simonw

This comment has been minimized.

Copy link
Owner

commented Nov 14, 2017

@atomotic

This comment has been minimized.

Copy link
Author

commented Nov 14, 2017

tried quickly, this seems working:

~ pip3 install pyinstaller
~ pyinstaller -F --add-data /usr/local/lib/python3.6/site-packages/datasette/templates:datasette/templates --add-data /usr/local/lib/python3.6/site-packages/datasette/static:datasette/static  /usr/local/bin/datasette

~ du -h dist/datasette
6.8M	dist/datasette
~ file dist/datasette
dist/datasette: Mach-O 64-bit executable x86_64
@simonw

This comment has been minimized.

Copy link
Owner

commented Nov 14, 2017

That didn't quite work for me. It built me a dist/datasette executable but when I try to run it I get an error:

$ pwd
/Users/simonw/Dropbox/Development/datasette
$ source venv/bin/activate
$ pyinstaller -F --add-data datasette/templates:datasette/templates --add-data datasette/static:datasette/static /Users/simonw/Dropbox/Development/datasette/venv/bin/datasette
$ dist/datasette --help
Traceback (most recent call last):
  File "datasette", line 11, in <module>
  File "site-packages/pkg_resources/__init__.py", line 572, in load_entry_point
  File "site-packages/pkg_resources/__init__.py", line 564, in get_distribution
  File "site-packages/pkg_resources/__init__.py", line 436, in get_provider
  File "site-packages/pkg_resources/__init__.py", line 984, in require
  File "site-packages/pkg_resources/__init__.py", line 870, in resolve
pkg_resources.DistributionNotFound: The 'datasette' distribution was not found and is required by the application
[99117] Failed to execute script datasette
@atomotic

This comment has been minimized.

Copy link
Author

commented Nov 14, 2017

i will look better tomorrow, it's late i surely made some mistake
https://asciinema.org/a/ZyAWbetrlriDadwWyVPUWB94H

@simonw

This comment has been minimized.

Copy link
Owner

commented Nov 14, 2017

It worked!

$ pyinstaller -F \
    --add-data /usr/local/lib/python3.5/site-packages/datasette/templates:datasette/templates \
    --add-data /usr/local/lib/python3.5/site-packages/datasette/static:datasette/static \
    /usr/local/bin/datasette

$ file dist/datasette 
dist/datasette: Mach-O 64-bit executable x86_64
$ dist/datasette --help
Usage: datasette [OPTIONS] COMMAND [ARGS]...

  Datasette!

Options:
  --help  Show this message and exit.

Commands:
  serve*   Serve up specified SQLite database files with...
  build
  package  Package specified SQLite files into a new...
  publish  Publish specified SQLite database files to...
@simonw

This comment has been minimized.

Copy link
Owner

commented Nov 14, 2017

It's a shame pyinstaller can't act as a cross-compiler - so I don't think I can get Travis CI to build packages. But it's fantastic that it's possible to turn the tool into a standalone executable!

@atomotic

This comment has been minimized.

Copy link
Author

commented Nov 15, 2017

actually you can use travis to build for linux/macos and appveyor to build for windows.

@simonw

This comment has been minimized.

Copy link
Owner

commented Oct 6, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.