Workflow for change/compile/test in panda3d?

I am pretty much ready to start digging in and helping with issues for panda3d. (The build finished successfully). My typical workflow is

  1. Find issues to work on.
  2. Post on that issue in github making sure I know exactly what needs to be done and making it clear I am working on it
  3. Make the changes to the required files.
  4. Test to make sure the changes do what I want
  5. Issue the pull request from my fork.

My only question is step 4. How do I test my modifications locally before sending in a pull request?

That sounds about right. You can do a rebuild after making the changes and then run with your modified build. You may want to add a unit test to the test suite to make sure that your changed code does what it is intended to do, and/or write a test script to test the feature or bug fix in context, and then run it against the modified Panda build.

Then, once everything is working well, you can commit to a branch, push it to your fork, and open a pull request. If you’re not sure yet about the approach, you can open a “draft” pull request and get early feedback on your changes.

A tip: don’t build with --installer; instead, set the PYTHONPATH variable in the command-line to point to the built folder, and run the compiled build straight away from that. That saves a lot of time.

I will probably need guidance for making sure I write the unit test scripts in a sensible way. I assume I should write a separate script in the appropriate folder (panda3d/tests/) that uses python to test whatever I changed.

I will definitely do the draft pulls until I (and everyone else) is comfortable with changes.

Just to make sure I am understanding your last comment. When I am testing a build and calling a python script, I do it like this:

python3 PYTHONPATH=/path/to/the/build/folder

That would save a lot of time. Or am I setting this as an environment variable?
How does everyone debug code?

I am off to find an issue to start on…

He means add the path to the Python interpreter to the environment variable.

I do this explicitly. The path to the Python that is located in the build folder + the path to the test script.

Example on Windows and SDK in CMD:

D:\Panda3D-1.10.7-x64\python\python.exe D:\Panda3D-1.10.7-x64\samples\roaming-ralph\

Thanks for the comment serega, So what I do is use an explicit path to python and then an explicit path to my test script to make sure the code is doing what I want. A replication of your command for me on a Mac (basically a unix system) it would be:

python3/bin/python3 panda3d/samples/roaming-ralph/

So now we come to the question of commits into panda3d. What is the standard op. procedure for the panda3d community? I have forked the repository, made panda3d/panda3d.git the upstream repository and have a local copy and made my changes. These have then been committed to the upstream repo. With other groups I have worked with, I have seen two workflows:

  1. Everyone on the master branch and does pull requests to the master branch. Releases are then created as new branches

  2. Every new feature/issue that is worked on, is created as a separate branch and the pull request is sent from that branch. After it is accepted, it is committed to the master branch.

or is the workflow different for panda3d? Thanks.

I don’t think these points are mutually exclusive?

The master branch is the main branch of development. When someone wants to make a feature, they create a branch, add changes to that branch, then open up a pull request against the master branch. Once the change is accepted, it is merged into the master branch.

The release branches are spawned off from the master branch by the release maintainer.

Thanks. That tells me what I need to know.
I am probably going to need help setting up a test for these changes. Here is as far as I have gotten. I successfully installed pytest and then set my the env variable PYTHONPATH to point to my built directory. (/Users/paustian/Documents/ComputingProjects/panda3d/built). Just to see if everything is working before I create a test, I tried to run the tests in the test folder. I cd to the panda3d folder and then did this command:


I then get these errors

================================================= test session starts =================================================
platform darwin -- Python 3.8.2, pytest-6.1.2, py-1.9.0, pluggy-0.13.1
rootdir: /Users/paustian/Documents/ComputingProjects/panda3d, configfile: setup.cfg, testpaths: tests
collected 0 items / 1 error                                                                                           

======================================================= ERRORS ========================================================
____________________________________________ ERROR collecting test session ____________________________________________
/Applications/ in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1014: in _gcd_import
<frozen importlib._bootstrap>:991: in _find_and_load
<frozen importlib._bootstrap>:975: in _find_and_load_unlocked
<frozen importlib._bootstrap>:671: in _load_unlocked
../python3/lib/python3.8/site-packages/_pytest/assertion/ in exec_module
    exec(co, module.__dict__)
tests/audio/ in <module>
    from panda3d.core import *
E   ModuleNotFoundError: No module named 'panda3d.core'
=============================================== short test summary info ===============================================
ERROR  - ModuleNotFoundError: No module named 'panda3d.core'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================================== 1 error in 0.12s ===================================================

Again, thanks for all your help. I feel like I am making progress.

A copy of Python from your operating system may be running. I do not know how this is organized in Unix systems, but you need exactly the Python that participated in the Panda build.

Thanks Serega. So if I want to redo the build, how do I get the compiler to do it from scratch. I want to use a venv I created for panda3d.

That error suggests that either:

  • An incompatible version of Python is used to run it compared to the one that built it, in which case the solution is to run makepanda using the version of Python you want to run Panda with (no clean rebuild needed)
  • You actually built Panda without Python support (look for a warning message in the build about that),
  • Or the PYTHONPATH setting was not done correctly.

If you want to run Panda inside a venv, you could also add --wheel to the makepanda flags and pip install the resulting whl into the venv, though it sounds tedious to do so repeatedly after every rebuild.

If you do want to force a clean rebuild, deleting the “built” folder is all you should need to do.

I apologize for being such a noobie on this, but I am back to square one. You are right that I built Panda3D without python support. So, I am trying to get this command to run:

python3 makepanda/ --everything --verbose --no-opencv --no-fmod

I immediately get this warning:
Could not locate Python installation at /Library/Frameworks/Python.framework/Versions/3.8

On Big Sur there is no Python.framework, nor a symlink to such a framework. I saw some similar threads on this, but didn’t see any clear answer on how to fix this.

Did you install Python from a source other than Where did it install?

That did it. I thought I had installed the latest python build, but that must have been before I had moved over to Big Sur. It’s compiling now, and doing the python compiles. Hopefully, this will be the last install issue and I can get to work. Thanks for your help and your patience.

I am up and running and have the change/compile/test cycle figured out. I hope to have a pull request by the end of the day.