Comments (14)
I don't think this has been tried with buildozer recently so I'm not surprised it's not working there.
As for your issue, it's impossible to troubleshoot this kind of issue over a github issue. But I would suggest you look at the activate (perhaps post it here) script. And please make sure you're following the exact steps to activate the venv (pushd etc).
I would also consider starting from an existing Kivy.dmg. You can see a full example here. I would also take a look at how we generate Kivy.app to see if you're doing something wrong.
from kivy-sdk-packager.
The activate script looks like this:
"""Xonsh activate script for virtualenv"""
from xonsh.tools import get_sep as _get_sep
def _deactivate(args):
if "pydoc" in aliases:
del aliases["pydoc"]
if ${...}.get("_OLD_VIRTUAL_PATH", ""):
$PATH = $_OLD_VIRTUAL_PATH
del $_OLD_VIRTUAL_PATH
if ${...}.get("_OLD_VIRTUAL_PYTHONHOME", ""):
$PYTHONHOME = $_OLD_VIRTUAL_PYTHONHOME
del $_OLD_VIRTUAL_PYTHONHOME
if "VIRTUAL_ENV" in ${...}:
del $VIRTUAL_ENV
if "VIRTUAL_ENV_PROMPT" in ${...}:
del $VIRTUAL_ENV_PROMPT
if "nondestructive" not in args:
# Self destruct!
del aliases["deactivate"]
""" unset irrelevant variables"""
_deactivate(["nondestructive"])
aliases["deactivate"] = _deactivate
$VIRTUAL_ENV = r"/Users/linusbrennecke/Projekte/parcours_bundler/kivy-sdk-packager/osx/Parcoursplaner.app/Contents/Resources/venv"
$_OLD_VIRTUAL_PATH = $PATH
$PATH = $PATH[:]
$PATH.add($VIRTUAL_ENV + _get_sep() + "bin", front=True, replace=True)
if ${...}.get("PYTHONHOME", ""):
# unset PYTHONHOME if set
$_OLD_VIRTUAL_PYTHONHOME = $PYTHONHOME
del $PYTHONHOME
$VIRTUAL_ENV_PROMPT = ""
if not $VIRTUAL_ENV_PROMPT:
del $VIRTUAL_ENV_PROMPT
aliases["pydoc"] = ["python", "-m", "pydoc"]
End of script (Sorry for the layout, couldn't get the markdown to format it as code)
I don't know if there's something wrong with it.
from kivy-sdk-packager.
You are seemingly using activate.xsh
. Try using the regular apple zsh
shell. We don't patch the xsh script.
from kivy-sdk-packager.
I am using zsh now. Running activate throws this error:
activate:cd :60: string not in pwd: ./../../../Frameworks/Python.framework/Versions/3.7
Here is the corresponding line:
export PYTHONHOME="$(cd "$(dirname "$BASH_SOURCE")"/../../../Frameworks/Python.framework/Versions/3*; echo "$(pwd)")"
Changing 3*
to 3.7
solved the issue. I doubt that it was intended for a user to have to manually change the script though.
Nonetheless I still get the ImportError.
The current activate looks like this:
# This file must be used with "source bin/activate" *from bash*
# you cannot run it directly
if [ "${BASH_SOURCE-}" = "$0" ]; then
echo "You must source this script: \$ source $0" >&2
exit 33
fi
deactivate () {
unset -f pydoc >/dev/null 2>&1 || true
# reset old environment variables
# ! [ -z ${VAR+_} ] returns true if VAR is declared at all
if ! [ -z "${_OLD_VIRTUAL_PATH:+_}" ] ; then
PATH="$_OLD_VIRTUAL_PATH"
export PATH
unset _OLD_VIRTUAL_PATH
fi
if ! [ -z "${_OLD_VIRTUAL_PYTHONHOME+_}" ] ; then
PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME"
export PYTHONHOME
unset _OLD_VIRTUAL_PYTHONHOME
fi
# The hash command must be called to get it to forget past
# commands. Without forgetting past commands the $PATH changes
# we made may not be respected
hash -r 2>/dev/null
if ! [ -z "${_OLD_VIRTUAL_PS1+_}" ] ; then
PS1="$_OLD_VIRTUAL_PS1"
export PS1
unset _OLD_VIRTUAL_PS1
fi
unset VIRTUAL_ENV
if [ ! "${1-}" = "nondestructive" ] ; then
# Self destruct!
unset -f deactivate
fi
}
# unset irrelevant variables
deactivate nondestructive
VIRTUAL_ENV=$(cd $(dirname "$BASH_SOURCE"); dirname `pwd`)
if ([ "$OSTYPE" = "cygwin" ] || [ "$OSTYPE" = "msys" ]) && $(command -v cygpath &> /dev/null) ; then
VIRTUAL_ENV=$(cygpath -u "$VIRTUAL_ENV")
fi
export VIRTUAL_ENV
_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/bin:$PATH"
export PATH
# unset PYTHONHOME if set
if [ "_" ] ; then
_OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME"
export PYTHONHOME="$(cd "$(dirname "$BASH_SOURCE")"/../../../Frameworks/Python.framework/Versions/3.7; echo "$(pwd)")"
#export PYTHONHOME="$(cd "$(dirname "$BASH_SOURCE")"/../../../Frameworks/Python.framework/Versions/3*; echo "$(pwd)")"
fi
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then
_OLD_VIRTUAL_PS1="${PS1-}"
if [ "x" != x ] ; then
PS1="${PS1-}"
else
PS1="(`basename \"$VIRTUAL_ENV\"`) ${PS1-}"
fi
export PS1
fi
# Make sure to unalias pydoc if it's already there
alias pydoc 2>/dev/null >/dev/null && unalias pydoc || true
pydoc () {
python -m pydoc "$@"
}
# The hash command must be called to get it to forget past
# commands. Without forgetting past commands the $PATH changes
# we made may not be respected
hash -r 2>/dev/null
from kivy-sdk-packager.
Hmm, did you try the kivy built Kivy.dmg file? Because that is the intended way for users to interact with it. Building a bundle from scratch is harder because more things are likely to go wrong. Especially if your local system is not completely clean, like on the CI.
Ultimately, we're playing a game of cat and mouse because virtualenvs don't officially support what we're doing, so with any updates we have to make sure we're patching it correctly. So yeah, some debugging is required if things break.
from kivy-sdk-packager.
Given that it works on the CI that I linked to above, I suspect it is something with your env or installation. We test the generated app, so it definitely works.
from kivy-sdk-packager.
Yep, it worked using the built Kivy.dmg file, thank you :)
Now I am just running into the problem that my app crashes on startup. I tried running my app through the "yourapp" symlink (is there a better way to debug the packaged app?) and the main.py doesn't seem to find the other modules. Those modules are present and subdirectories contain __init__.py
files. Any idea what is going wrong?
from kivy-sdk-packager.
You probably didn't install them like a python package!? You need to install them so it gets installed to site-packages, like normal python packages. Otherwise, python wouldn't find them, even if it's in the current directory.
This is why I made https://github.com/kivy/kivy_pong_demo. Personally, I don't have a MAC so I can't test, but I would first start with https://github.com/kivy/kivy_pong_demo/releases to make sure the compiled dmg works. Then I would use that project as a base or test platform for your app to see what you're potentially doing that breaks it.
Specifically, notice how https://github.com/kivy/kivy_pong_demo/blob/main/.github/workflows/pythonapp.yml#L119 installs the project (using its setup.py
) so python can run it. Take a look at the other steps as well.
from kivy-sdk-packager.
I installed it using pip, but maybe i have an error in my setup.py. I'll try the pong_demo out :)
from kivy-sdk-packager.
So i created a .dmg file for the pong_demo and it worked, but when I tried to add another .py file to the pong_demo app, the file couldn't be imported again.
It turns out I have to specify imports of python files differently for local development execution and for the .dmg package.
For example:
If I run main.py directly, I import the file like this: from mymodule import myfunction
.
But in order for the App to function I need to import like this: from kivy_pong_demo.mymodule import myfunction
.
Is there a way to make an import statement work for both cases or automatically transforming the import statements before/during build? (besides writing my own script of course ;) )
from kivy-sdk-packager.
I think this is a issue with how you use imports.
- Importing stuff from a package using the
from kivy_pong_demo.mymodule import myfunction
syntax always works ifkivy_pong_demo
is a known package. - Importing stuff from within a package referencing other sub-packages or modules using the
from .mymodule import myfunction
syntax works if the script you're running is running as a module, not as a script. I.e. this won't work if you're runningpython main .py
, but it would work if you're running it aspython -m kivy_pong_demo.main
. This is called relative importing. - What you are doing, simply importing
mymodule import myfunction
, this works only if the current folder is on the PYTHONPATH, but doesn't work in general and is not a way I'd recommend to use to import stuff from packages. I imagine it worked for you in your dev env simply by accident due to what your current working directory was. However, it doesn't work in general.
So I think you need to change how you import stuff to one of the first two approaches, and I'd highly recommend the first one. Perhaps you don't want to use the from kivy_pong_demo.mymodule import myfunction
syntax during dev because you haven't installed it yet? I would suggest then to become familiar with the pip editable/development install syntax (pip install -e .
), which is meant for this. It installs the package in place.
from kivy-sdk-packager.
I got it to work but I have run into another problem that I can't find a solution for:
In the packaged app everything looks blurry as if all images have been drawn and then increased in size. I have tried different metrics and modified the size of the widgets but it always remains blurry.
I noticed that this also occurs on the pong app.
Is there some kind of OS setting that I could modify or is there an issue with the startup script?
Screenshot of the app when run through main.py:
Screenshot of the app when run through yourapp:
As you can see even the application title gets blurred.
from kivy-sdk-packager.
When running the app normally, are you using master or 2.0.0? Because when you're using Kivy.app you're probably using 2.0.0. You can get a Kivy.app from latest master here.
Otherwise, I'm not sure because I don't personally use a mac. I would look in the kivy repo issues to see other reports of blurriness. You can also try asking on discord.
from kivy-sdk-packager.
Closing as support issue.
from kivy-sdk-packager.
Related Issues (20)
- Is not compatible with brew installed GNU findutils HOT 1
- Gstreamer_dev missing header file in wheel - gstconfig.h
- Cannot upgrade pip: kivy -m pip install -U pip HOT 3
- kivy -m pip install -r requirements-osx.txt - cannot find file HOT 2
- Running pip on OSX / Kivy3: No such file or directory: activate_this.py HOT 2
- The SDL2 version changes break the daily PPA HOT 7
- PPA doesn't include all dependencies for providers (clipboard/spelling/...)
- buildozer fails for OSX HOT 1
- Directions for setting up osx app via "Using the Kivy SDK" don't work as stated HOT 2
- Drag/drop of python script onto Kivy.app doesn't work as stated, have workaround
- Having tried every single method of osx app building, all work w/ demo, none w/ deps
- Building Kivy.app fails because of "virtualenv --relocatable" HOT 2
- build osx + buildozer failed HOT 3
- The packaged macOS app should contain binaries for both Apple Silicon and Intel (Universal2)
- macOS: create-osx-bundle.sh outdated HOT 2
- Kivy default home dir is not writable on OSX
- Python 3.11 gstreamer is not uploaded to PIP HOT 1
- Update MACOSX_DEPLOYMENT_TARGET HOT 3
- not resolved: config.pxi
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kivy-sdk-packager.