Closed bendub closed 4 years ago
it's the same bug as #2 ;-)
Two bugs resolved in one action \o/
In fact ... it's a lot more complex ... I've made the "os.chdir()" (when server starts) to be sure to place the CWD where the 'exe' (freezed one) sits. (to be able to locate static & config.json). It works very well ... on "windows" with freezed one (because static files are embedded in the freezed exe) or simple py-files ... But it's not really adapted for people who wants to release pypi packages ...
How do you embed your files (setuptools with "package_data" ? or data_files)
For packaged one, I will need to deal with pkg_ressource ... or let the user/packager a way to setup the desired path
Hello Manatlan, I embed my files in a package using setuptools with "package_data":
package_data={
'': ['ui/static/*.html',
'ui/static/*.png']
}
thks ...
and, to build your package : you did :
python3.7 setup.py sdist
?
Yes, to be precise:
python3 setup.py sdist bdist_wheel
I don't reach to include static files in my sdist tar.gz ;-(
Could you use my tar.gz?
Can't reach to embbed static files ... perhaps you will see my trouble ?! test_app.zip
please, can you try that (replace your guy.py with this one guy.txt )... do you have got better result ? (sorry, can't test here .. because can't reproduce)
Could you use my tar.gz?
yes .. I could
First ... forgot all I said before ^^ ;-)
I've reach to embbed data in a package (bdist_wheel) ... using the marvelous "poetry" ;-) And reach to reproduce exactly your problem !
Try this future version of guy guy.txt (don't wanna to release yet ... because I should test on windows, with frozen exe (to be sure that there are no regression) ... I could test/release on monday evening) (and currently : no regression on android/apk !)
Now ... guy doesn't change/enforce "current directory" (it's a lot better like that !) ... and it can see if it's executed from a python package ... and rewrite the good path to the data ! So now : you can build pypi package ;-)
In your case : perhaps you should change your static folder ... because it seems that you have prefixed it with "ui" (set guy.FOLDERSTATIC = "ui/static"
) ...
BTW, it works, like a charm, for me ... using poetry to build my wheel ... in your case, with pure setuptools ... it should work too ... but not sure at 100%
BTW2 : I will add a page, in the docs, to explain how to embbed a guy app in a pypi package (using poetry only ... )
btw, the new tuto is here : https://guy-docs.glitch.me/howto_build_whl_package/
btw, i've comitted the 0.4.0 version, on github, with is "pip-packageable" (but not on pypi ... need more tests yet)
Thanks Manatlan. I'll try it tomorrow.
the 0.4.0 is out, on pypi ... should fix this issue I close it
Sorry for the late. I packaged my app using poetry and I have the same problem again.
In your case : perhaps you should change your static folder ... because it seems that you have prefixed it with "ui" (set guy.FOLDERSTATIC = "ui/static") ...
what the msg ?
To avoid problem, following your advice, I move 'static' directory in "myapp/myapp/static". The error reported in my browser is:
ERROR: can't find '/home/USER/.../cloc_venv/bin/static/ClocGui.html'
It seems it look for 'static' directory in the place where
__name=="__main"
PS : I test my project in a virtualenv
You're right .. I've got the same kind of troubles, when using venv place (with poetry shell) ... So I was doing all my tests without using venv ....
If you look : https://github.com/manatlan/guy/blob/98c41e3a48f7f99dbcf1666e7b0431797c112480/guy.py#L65 It's the way it (try) to resolv where static sits ...
In fact, it will certainly work for you if you release your whl, and install it ... and execute from package.
I really need to found a new (AND SIMPLE) way to resolv this things, in all cases ... (In my the "old guy" : wuy ... devs needed to set a "wuy.path" to specify where static were ... and I don't want to do that in "guy" ...)
Please ... try the new "0.4.1" ... It will be able to find the "static" associated with the class, in all cases ... and it should work, as expected, using venv too
It works! Thanks you Manatlan. I can access my UI now. However I had errors when I play with the config.json file. But I need to test more, perhaps the problem is from my side.
With 0.4.1 there were trouble with config... The 0.4.2 seems ok for me
Le ven. 31 janv. 2020 à 18:37, bdubois notifications@github.com a écrit :
It works! Thanks you Manatlan. I can access my UI now. However I had errors when I play with the config.json file. But I need to test more, perhaps the problem is from my side.
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/manatlan/guy/issues/3?email_source=notifications&email_token=AABEZQUBL7M4IBGL7LPOCB3RAROVZA5CNFSM4J5FPZJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKPM6OA#issuecomment-580833080, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABEZQQ6XUT6BC32MPRCHV3RAROVZANCNFSM4J5FPZJA .
Hello manatlan, I package an app using setuptools. The app is installed in the user environment:
The directory 'static' is actually located in ~/.local/lib/python3.X/site-packages/MyPkg/ui/static.
Thank you