Kivy-ios Xcode build error - python

I'm trying to run my Kivy app in Xcode (5.1). So far, I've managed to create an Xcode project, but it gets weird in build phase, throws an error like so:
+ echo '-> Compile to pyo'
-> Compile to pyo
+ /Users/onebit0fme/kivy-ios/tmp/Python-2.7.1/hostpython -OO -m compileall /Users/onebit0fme/kivy-ios/app-MyApp/YourApp
../tools/populate-project.sh: line 32: /Users/onebit0fme/kivy-ios/tmp/Python- 2.7.1/hostpython: No such file or directory
+ echo '-> Remove unused files (pyc, py)'
-> Remove unused files (pyc, py)
+ find /Users/onebit0fme/kivy-ios/app-MyApp/YourApp -iname '*.py' -exec rm '{}' ';'
+ find /Users/onebit0fme/kivy-ios/app-MyApp/YourApp -iname '*.pyc' -exec rm '{}' ';'
+ echo '-> Source code of MyApp updated.'
-> Source code of MyApp updated.
Command /bin/sh emitted errors but did not return a nonzero exit code to indicate failure
Now, most interesting are these lines:
+ /Users/onebit0fme/kivy-ios/tmp/Python-2.7.1/hostpython -OO -m compileall /Users/onebit0fme/kivy-ios/app-MyApp/YourApp
../tools/populate-project.sh: line 32: /Users/onebit0fme/kivy-ios/tmp/Python- 2.7.1/hostpython: No such file or directory
I installed latest version of Python (2.7.6) with 'port' and set it to be default. What I don't understand are:
1. Why it tries to find Python-2.7.1 ???
2. Why it looks in 'kivy-ios/tmp/' folder (I'm sure it's not there, and never was)???
This error comes from 'kivy-ios/populate_project.sh' line 32:
echo "-> Compile to pyo"
$HOSTPYTHON -OO -m compileall $YOURAPPDIR
and I don't know where '$HOSTPYTHON' is coming from and why it gets evaluated to '/Users/onebit0fme/kivy-ios/tmp/Python-2.7.1/hostpython'.
I'm completely lost and desperate, please help who has at least a hint of what is going on.
UPDATE:
Turns out, when I did 'tools/build-all.sh', it did its job and echoed 'BUILD SUCCEEDED', but then "tar: Unrecognized archive format". As the result, there's no "build/python/lib/python27.zip" in kivy-ios folder. So, I guess, it didn't finish Kivy-ios installation, again, no idea why...

Solved. Indeed, turns out kivy-ios did not built all the packages because Python package has been moved to a new location (that's why "tar: Unrecognized archive format" appeared and I ignored it unfortunately). The solution is to change python package http in 'tools/build-python.sh'.
Here's the link to solution: https://github.com/kivy/kivy-ios/issues/85

Related

-bash: source: filename argument required

I'm working through a Python tutorial, and I attempted to pip install autoenv==1.0.0. I created the .env file in the dir
source env/bin/activate
export APP_SETTINGS="config.DevelopmentConfig"
and then ran these commands in the shell, outside of a venv
echo "source `which activate.sh`" >> ~/.bashrc
source ~/.bashrc
I got back:
-bash: source: filename argument required
source: usage: source filename [arguments]
Come to find out, autoenv failed to install. I was able to get it to install and re-ran the above commands and now it works but I'm still getting the above message whenever I reload the terminal
How can I find and remove the source command or resolve it?
** edit: running which activate returns
23:24 $ which activate.sh
/usr/local/bin/activate.sh
I've looked in .bash_profile and can't find anything that seems related.
I've looked in the .bashrc file and found a path to activate.sh, though the path has the file located in the bin which it is not.
After running
grep source ~/.bash
suggested by Cyrus above, I found 3 random "Source" commands, after deleting them, the issue went away.
Thanks, Cyrus and Mihir for your help.

Makefile on Windows 10 - file not found

After some time I finally managed to successfully install python and pip and run it on my machine using Visual Studio Code.
I am working in virtual environment in python and we have a Makefile with following statement:
test:
source .env && PYTHONPATH=. PY_ENV=testing py.test ${ARGS} --duration=20
File .env lives in the main directory next to Makefile. It contains some environmental variables needed for testing certain APIs.
When I take the line out of the file and run it in my terminal, everything works fine and all tests are running etc.
However if I call the following: make test I am getting this error:
$ make test
source .env && PYTHONPATH=. PY_ENV=testing py.test --duration=20
/usr/bin/sh: line 0: source: .env: file not found
make: *** [test] Error 1
(venv)
To me it looks like when running this command from within Makefile it can't see the .env file but have no idea how to solve it.
The source command isn't looking up the file in the current working directory. As mentioned in man source:
Read and execute commands from filename in the current shell
environment and return the exit status of the last command executed
from filename. If filename does not contain a slash, filenames in
PATH are used to find the directory containing filename.
Change the file path like so:
test:
source ./.env && PYTHONPATH=. PY_ENV=testing py.test ${ARGS} --duration=20
Note that this error does not occur in bash version < 4. This is due to an implementation bug when run under POSIX mode (what make uses, since its default shell is sh, which is usually bash --posix). The correct behaviour was first mentioned in the documentation of bash-2.05 (revision 28ef6c31, file doc/bashref.info):
When Bash is not in POSIX mode, the current directory is searched if
FILENAME is not found in `$PATH'.
These older versions searched the current directory regardless of POSIX mode. It was only in bash-4.0-rc1 (revision 3185942a, file general.c) that this was corrected. Running git diff 3185942a~ 3185942a general.c outputs this section:
## -69,6 +69,7 ## posix_initialize (on)
if (on != 0)
{
interactive_comments = source_uses_path = expand_aliases = 1;
+ source_searches_cwd = 0;
}

Python Setuptools build RPM error

I am trying to build RPM package for python setuptools-12.0.3 but getting wired error,
Its look like related to SPEC file %files -f INSTALLED_FILES but how to fix it? or is it a bug? I can see two files path in single line, how do i fix it?
+ /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
+ /usr/lib/rpm/redhat/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
This is the command i am using python2.7 setup.py bdist_rpm to build RPM
+ /usr/lib/rpm/redhat/brp-compress
+ /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
+ /usr/lib/rpm/redhat/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
+ /usr/lib/rpm/brp-python-bytecompile
Bytecompiling .py files below /root/rpmbuild/SOURCES/setuptools-12.0.3/build/bdist.linux-x86_64/rpm/BUILDROOT/setuptools-12.0.3-1.x86_64/usr/lib/python2.6 using /usr/bin/python2.6
+ /usr/lib/rpm/redhat/brp-python-hardlink
+ /usr/lib/rpm/redhat/brp-java-repack-jars
Processing files: setuptools-12.0.3-1.noarch
error: Two files on one line: /usr/lib/python2.6/site-packages/setuptools/script
error: File must begin with "/": (dev).tmpl
RPM build errors:
Two files on one line: /usr/lib/python2.6/site-packages/setuptools/script
File must begin with "/": (dev).tmpl
error: command 'rpmbuild' failed with exit status 1
Solution
After spending couple hours i figure out what was wrong:
copy setuptools.spec file in my own rpmbuild environment at /root/rpmbuild/SPECS/
Change %files -f INSTALLED_FILES to %files
Run rpmbuild -ba setuptools.spec
It generate list of files which need to add in %files section, But in that list there was one file which space in filename Ouch!!
script (dev).tmpl
I have used wildcard to match all files and problem solved. somehow rpmbuild doesn't understand escap character ( Don't know if there is a better way)
%files
%defattr(-,root,root)
...
...
/usr/local/lib/python2.7/site-packages/setuptools/script*
...

Simplest way to run Sphinx on one python file

We have a Sphinx configuration that'll generate a slew of HTML documents for our whole codebase. Sometimes, I'm working on one file and I just would like to see the HTML output from that file to make sure I got the syntax right without running the whole suite.
I looked for the simplest command I could run in a terminal to run sphinx on this one file and I'm sure the info's out there but I didn't see it.
Sphinx processes reST files (not Python files directly). Those files may contain references to Python modules (when you use autodoc). My experience is that if only a single Python module has been modified since the last complete output build, Sphinx does not regenerate everything; only the reST file that "pulls in" that particular Python module is processed. There is a message saying updating environment: 0 added, 1 changed, 0 removed.
To explicitly process a single reST file, specify it as an argument to sphinx-build:
sphinx-build -b html -d _build/doctrees . _build/html your_filename.rst
This is done in two steps:
Generate rst file from the python module with sphinx-apidoc.
Generate html from rst file with sphinx-build.
This script does the work. Call it while standing in the same directory as the module and provide it with the file name of the module:
#!/bin/bash
# Generate html documentation for a single python module
PACKAGE=${PWD##*/}
MODULE="$1"
MODULE_NAME=${MODULE%.py}
mkdir -p .tmpdocs
rm -rf .tmpdocs/*
sphinx-apidoc \
-f -e --module-first --no-toc -o .tmpdocs "$PWD" \
# Exclude all directories
$(find "$PWD" -maxdepth 1 -mindepth 1 -type d) \
# Exclude all other modules (apidoc crashes if __init__.py is excluded)
$(find "$PWD" -maxdepth 1 -regextype posix-egrep \
! -regex ".*/$MODULE|.*/__init__.py" -type f)
rm .tmpdocs/$PACKAGE.rst
# build crashes if index.rst does not exist
touch .tmpdocs/index.rst
sphinx-build -b html -c /path/to/your/conf.py/ \
-d .tmpdocs .tmpdocs .tmpdocs .tmpdocs/*.rst
echo "**** HTML-documentation for $MODULE is available in .tmpdocs/$PACKAGE.$MODULE_NAME.html"

problem compiling libjingle

I downloaded and installed libjingle-0.5.2.zip, and according to the README also downloaded and installed swtoolkit.0.9.1.zip, scons-local-2.1.0.alpha.20101125.tar.gz, and expat-2.0.1.tar.gz, and got nrtp by cvs download. After overwriting my Makefile twice, attempting to follow the rather poorly-written README, I came up with the following Makefile that almost works:
# First, make sure the SCONS_DIR environment variable is set correctly.
SCONS_DIR ?= /usr/src/scons-local/scons-local-2.1.0.alpha.20101125/
#SCONS_DIR ?= /usr/src/scons-local/
export
default: build
# Second, run talk/third_party/expat-2.0.1/configure...
talk/third_party/expat-2.0.1/Makefile:
cd talk/third_party/expat-2.0.1 && ./configure
# ...and talk/third_party/srtp/configure.
talk/third_party/srtp/Makefile:
cd talk/third_party/srtp && ./configure
# Third, go to the talk/ directory and run $path_to_swtoolkit/hammer.sh. Run
# $path_to_swtoolkit/hammer.sh --help for information on how to build for
# different modes.
build: talk/third_party/expat-2.0.1/Makefile talk/third_party/srtp/Makefile
cd talk && ../../swtoolkit/hammer.sh
help:
../swtoolkit/hammer.sh --help
However, make gives me the following errors:
jcomeau#intrepid:/usr/src/libjingle-0.5.2$ make
cd talk && ../../swtoolkit/hammer.sh
*** Error loading site_init file './../../swtoolkit/site_scons/site_init.py':
AttributeError: 'Dir' object has no attribute 'endswith':
File "/usr/src/scons-local/scons-local-2.1.0.alpha.20101125/SCons/Script/Main.py", line 1338:
_exec_main(parser, values)
File "/usr/src/scons-local/scons-local-2.1.0.alpha.20101125/SCons/Script/Main.py", line 1302:
_main(parser)
File "/usr/src/scons-local/scons-local-2.1.0.alpha.20101125/SCons/Script/Main.py", line 929:
_load_site_scons_dir(d.path, options.site_dir)
File "/usr/src/scons-local/scons-local-2.1.0.alpha.20101125/SCons/Script/Main.py", line 719:
exec fp in site_m
File "./../../swtoolkit/site_scons/site_init.py", line 455:
SiteInitMain()
File "./../../swtoolkit/site_scons/site_init.py", line 451:
SCons.Node.FS.get_default_fs().SConstruct_dir, None)
File "/usr/src/scons-local/scons-local-2.1.0.alpha.20101125/SCons/Script/Main.py", line 677:
site_dir = os.path.join(topdir, site_dir_name)
File "/usr/lib/python2.6/posixpath.py", line 67:
elif path == '' or path.endswith('/'):
make: *** [build] Error 2
I'm guessing that something new (a 'Dir' object being where a POSIX path string is expected) in one of the packages is breaking the build process, but which one? There are just too many layers of cruft here for me to follow. For sure I could just keep trying older packages, particularly for swtoolkit and scons, but if anyone here has successfully compiled libjingle and could prod me in the right direction, I'd appreciate it.
I'm not familiar with the project, but think I have a fix to get you past that point. You need to cast those Dir instances using str() in swtoolkit/site_scons/site_init.py. That way they can safely be evaluated by path.endswith('/'). Odd that such an issue would exist for very long in the main part of the build infrastructure:
Line 330:
SCons.Script.Main._load_site_scons_dir(
str(SCons.Node.FS.get_default_fs().SConstruct_dir), site_dir)
Line 450:
SCons.Script.Main._load_site_scons_dir(
str(SCons.Node.FS.get_default_fs().SConstruct_dir), None)
I did following to build libjingle :
Building LibJingle for Linux
How to Build
Libjingle is built with swtoolkit ( http://code.google.com/p/swtoolkit/), which
is a set of extensions to the open-source SCons build tool ( http://www.scons.org).
First, install Python 2.4 or later from http://www.python.org/.
Please note that since swtoolkit only works with Python 2.x, you will
not be able to use Python 3.x.
Second, install the stand alone scons-local package 2.0.0 or later from
http://www.scons.org/download.php and set an environment variable,
SCONS_DIR, to point to the directory containing SCons, for example,
/src/libjingle/scons-local/scons-local-2.0.0.final.0/.
Third, install swtoolkit from http://code.google.com/p/swtoolkit/.
Finally, Libjingle depends on two open-source projects, expat and srtp.
Download expat from http://sourceforge.net/projects/expat/ to
talk/third_party/expat-2.0.1/. Follow the instructions at
http://sourceforge.net/projects/srtp/develop to download latest srtp to
talk/third_party/srtp. Note that srtp-1.4.4 does not work since it misses
the extensions used by Libjingle.
If you put expat or srtp in a different directory, you need to edit
talk/libjingle.scons correspondingly.
2.1 Build Libjingle under Linux or OS X
First, make sure the SCONS_DIR environment variable is set correctly.
Second, run talk/third_party/expat-2.0.1/configure and
talk/third_party/srtp/configure.
Third, go to the talk/ directory and run $path_to_swtoolkit/hammer.sh. Run
$path_to_swtoolkit/hammer.sh --help for information on how to build for
different modes.
Other than above given steps, See following as reference
Set SCONS_DIR Path
export SCONS_DIR=/home/esumit/libjingle/libjingle-0.5.2/talk/third_party/scons-local/scons-local-2.0.1
Install libasound2-dev Lib to compile libJingle, otherwise you will encounter errors.
sudo apt-get install libasound2-dev
Download SRTP using the following command. If it asks for a passowrd, just hit Enter.
cvs -z3 -d:pserver:anonymous#srtp.cvs.sourceforge.net:/cvsroot/srtp co -P srtp
Possible components in LibJingle Directory
libjingle-0.5.2/talk/third_party$ ls
expat-2.0.1 libudev scons-local srtp swtoolkit
Execute following command to build LibJingle
libjingle-0.5.2/talk$ ./third_party/swtoolkit/hammer.sh

Categories