Opened 12 years ago

Closed 12 years ago

#1002 closed task (fixed)

Upgrade version of pyBox2D used in Physics to 2.0.2b1

Reported by: brian Owned by: brian
Priority: Unspecified by Maintainer Milestone: Unspecified
Component: Physics Version: Unspecified
Severity: Minor Keywords:
Cc: sirkne@…, garycmartin, asaf Distribution/OS: Unspecified
Bug Status: Assigned

Description

Upgrade Physics activity to use pyBox2D 2.0.2b1 and elements

Blocking: http://dev.sugarlabs.org/ticket/990

Change History (16)

comment:1 Changed 12 years ago by brian

Letting this run for a while (super slow Internet):

svn co http://svn2.assembla.com/svn/elements elements-svn
cd elements-svn
python ez_setup.py

comment:2 Changed 12 years ago by brian

Ended up doing:

sudo yum install python-devel svn
svn co http://svn2.assembla.com/svn/elements elements-svn
cd elements-svn
sudo python ez_setup.py
sudo python setup.py

The last command created /usr/lib/python2.5/site-packages/Elements-0.11-py2.5.egg and /usr/lib/python2.5/site-packages/Box2D-2.0.2b1-py2.5-linux-i686.egg

I'm having trouble figuring out how to get these .eggs importing with a relative location when stored within Physics.activity/

Leaving them in /usr/lib, physics works well! The only things I have found that will need fixing are the Pin and Joint tools.

The joint() tool code in Elements-0.11 seems to only Pin objects to the background at it the object's center.

So, the next steps:

(a) figure out how to properly include the .egg(s?) within the activity

(b) either (1) modify the Joint tool at the Elements level or (2) figure out how to get at box2d.b2RevoluteJointDef() from within tools.py

Any tips?

comment:3 Changed 12 years ago by kne

According to http://peak.telecommunity.com/DevCenter/PythonEggs : "# .egg files are a "zero installation" format for a Python package; no build or install step is required, just put them on PYTHONPATH or sys.path and use them ..." But I'm not sure how the activities work.

I'm also not sure about the goals of the Physics activity just yet, but you might consider keeping Elements out of the egg. As you can see with the joint code, it's not complete.

comment:4 Changed 12 years ago by asaf

It's worth noting that there are extra joint methods in the branch of elements inside the physics activity that are not present in the main elements branch you are referring to.

comment:5 Changed 12 years ago by kne

Nice! Any chance you'd be willing to commit those changes back to the Elements trunk? I'll add you on the project, if so.

comment:6 Changed 12 years ago by asaf

I'll bee glad to commit the changes. I just opened an assembla account and my username is the same one as here.

comment:7 Changed 12 years ago by kne

Great. Thank you, asaf!

comment:8 in reply to: ↑ description Changed 12 years ago by asaf

Replying to brian:

Upgrade Physics activity to use pyBox2D 2.0.2b1 and elements

Blocking: http://dev.sugarlabs.org/ticket/990

Also blocking http://dev.sugarlabs.org/ticket/1034 .

I think we should use the opportunity of updating pyBox2D to organize the way we deal with elements. I suppose that what we want is to keep them together but not mixed. Should we remove elements from the activity source at http://git.sugarlabs.org/projects/physics and only put them together for distribution?

comment:9 Changed 12 years ago by brian

In my working copy, I have Elements and pyBox2D's .egg libraries stored in a directory lib/, getting rid of the elements/ folder altogether.

For the most part, Physics works the same, only joints aren't working (because there is extra code in our version of Elements).

So I think the steps are (1) push the changes made to elements upstream, (2) release upstream (?), (3) push changes to Physics, using the .egg libraries.

I'll see if I can do (1) tonight. kne -- what do you think about a new elements release this weekend?

comment:10 Changed 12 years ago by brian

  • Resolution set to fixed
  • Status changed from new to closed

Committed the Joint changes to elements on Assembla, built an "Elements .12" (kne, is there anything else to do for that? any tags necessary on SVN?) and changed some of physics.py and tools.py to use the new .egg libraries for Elements and pybox2D.

Elements commit: http://trac2.assembla.com/elements/changeset/225
Physics commit: http://git.sugarlabs.org/projects/physics/repos/mainline/commits/da351cb11c9cc0a36492c9f50fa993afb4465c3b

Can use help testing, seeing if anything's broken or if I missed merging anything important with Elements.

Then let's move on to the fun things pybox2d 2.0.21 allows us to do:
http://dev.sugarlabs.org/ticket/990
http://dev.sugarlabs.org/ticket/1034

comment:11 Changed 12 years ago by asaf

  • Resolution fixed deleted
  • Status changed from closed to reopened

I get the following error while trying to run the activity:

/home/asaf/.python-eggs/Box2D-2.0.2b1-py2.5-linux-i686.egg-tmp/Box2D/_Box2D.so: wrong ELF class: ELFCLASS32

I generated the egg for x86_64 and put it inside lib but I noticed I had to modify physics.py to tell the activity to load the right egg. Can we solve this in a portable way? I also noticed that I built the egg using python2.6 , will that give us any trouble? Once I put the egg in the right place and modify physics.py everything works great.

comment:12 Changed 12 years ago by kne

Brian, a new release of Elements sounds great. Only problem is that I really only have access to the assembla (but neither the linuxuser.at page nor the pygame project page), so we'll have to get in touch with Chris to make a true public release. Elements doesn't currently use tags, but perhaps now is the time to start.

I've never run into that egg problem before, since I've always installed them into site-packages. Perhaps this is relevant, "If you're using the pkg_resources runtime to find eggs for you, it will ignore any eggs that it can tell are not usable on your platform or Python version. If you're not using the runtime, you'll have to make sure that you use only compatible eggs." How much of an issue is portability when there's one target platform?

comment:13 Changed 12 years ago by brian

AH!

On XO I was testing Physics on, I had previously installed pkg_resources -- XOs do not have it by default. Therefore, the current git Physics does not launch on the XO, saying:

Import error: no module named pkg_resources.

The fix is to:

cd lib
unzip *.egg
vi physics.py # and add sys.path.append("lib/")

This is the only way I can think of to allow a machine without setuptools to import a .egg.

Do we leave both folders and both .eggs in the lib/ directory?

I do like how the .eggs are contained and have library versions in their titles.

comment:14 Changed 12 years ago by garycmartin

Thanks Brian, just testing on XO myself and had the same problem. So the .eggs have to go and we just keep the unzipped libs from them? Pitty, if so, the eggs are much smaller (1.2Mb as eggs, vs 4.1Mb unzipped).

comment:15 Changed 12 years ago by asaf

Can't we include setuptools with the rest of the activity?

comment:16 Changed 12 years ago by brian

  • Resolution set to fixed
  • Status changed from reopened to closed

Included setuptools.py, works with python 2.5.x. Please test and reopen if broken.

Closing!

Note: See TracTickets for help on using tickets.