Notes for hacking, developing, and modifying pygame.
Building pygame
See the wiki page: [[Compilation]] to figure out how to compile pygame on different platforms.
How to do debug builds?
python setup.py build --debug install
How to speed up compilation? The build only compiles things that have changed by default.
Parallel builds can be done with python 3.5+, where you can set the -j option with the number of workers you want to use. Probably setting it to the same as your number of CPU cores is a good idea.
python setup.py build -j4 install
Buildbots, pygame compiled on every change
There is a pygame github page. Development now happens on github.
Right now, pygame uses Github Actions and AppVeyor (windows) for CI. These are useful to make sure that changes proposed by contributors do not break pygame in any way, pygame must still build and work fine across different platforms and python versions.
Linux manylinux builds
Manylinux builds are binary files for pip which should work on many versions of linux.
See in the pygame repo manylinux-build/README.rst
Generating docs
python setup.py docs
This runs buildconfig/makeref.py which runs Sphinx to generate HTML docs and src_c/docs/{module}_doc.h C headers from reStructuredText source.
The reStructuredText .rst files are stored in the
pygame/docs/reST/ref/ (reference manual)
and docs/reST/tut/(tutorials) directories.
An online reStructuredText primer can be found on the Python website site.
Sphinx specific markup is described in theSphinx Documentation.
Parameters for functions should be documented with param info field lists.
The Python Sphinx package itself depends on Docutils, Jinja2, and Pygments.
Running tests
To run the tests from the test sub-directory in the pygame distribution:
python test/__main__.py -v
To run the tests from the installed pygame.tests module:
python -m pygame.tests -v
In either case the --help command line option will give usage instructions.
An important option is -v. This lets you see more details of the tests as they run.
C API docs
The C API docs can be found at /docs/c_api.html. The source code for these docs in RestructuredText format is in docs/reST/c_api.rst and docs/reST/c_api/.
Code style
Try and follow the code style of the particular file you are editing.
Use 4 spaces instead of tabs, and Pep-8 generally. Make sure your editor doesn't insert tabs.
Try to keep things under 80 characters wide.
Try not to mix in white space commits with other code commits. This makes reading diffs easier if you separate the whitespace updates from the actual changes.
For C code, we use clang-format. There is a config in src_c/.clang-format which tries to use a pep-7 style.
Writing tests.
Tests are in the test/ directory.
Please see test/README.txt (in the pygame repo) for more of a description on the tests, and the testing framework.
A naming convention is used for all tests. So from the name of a module, class, method, or function, you can find the tests for it.
Each module has a test file. eg. for pygame.surface there is test/surface_test.py
In that file there are methods for each of the classes, functions and methods. So Surface.blit has a 'test_blit' method. There can be multiple test methods for each method. eg. 'test_blit_keyword_args' in surface_test.py one of a few tests Surface.blit. Add extra words at the end of the method name to make multiple tests for the same method.
Methods named with todo at the front "todo_blit" are methods that need to be written. Or finished. By default all of the todo tests are skipped by the test runner. You can however, make the todo_ tests fail - to see how many more tests need to be finished.
Tests can use tags in order to organise them. There are optionally [modulename]_tags.py files for each module. A test/surface_tags.py file is used to specify tags for the pygame.surface module. You can use tags to skip tests on different platforms, or to choose different tests to exclude or run.
There are some test related tools + code in test/util/ .
To see if anything in a module is not documented... you can use: python compare_docs.py pygame.sprite sprite.doc
To generate some test stubs for your unittests from an existing file... you can do: python gen_stubs.py midi
Submitting changes to github
See http://www.contribution-guide.org/.
If you are a member of the pygame repo on github you can start a new branch like this:
git clone git@github.com:pygame/pygame.git
cd pygame
git checkout -b my-fixes-branch
# Edit your changes here.
git commit .
git push --set-upstream origin my-fixes-branch
Then go to the web https://github.com/pygame/pygame to create a pull request. Add a couple of reviewers who you think might want to review the code.
If you are not part of the github pygame organization, then fork pygame with github, and then when you're ready, send us a pull request.
Issue triage
There's a lot of issues, and people often only care about the issue for a short time. It can be helpful to categorize issues to save time for other developers, and to try and move an issue along.
Here are some general guidelines:
- Thank the person for submitting the issue. They didn't have to, and it took them some time.
- If issue reporters haven't provided sufficient information to act on, ask them to do the same
- Ask users reporting bugs with older pygame versions to test whether the bug still happens on the latest version
- Tell people we need a test. Tell them in which file.
- Tell people we don't have time, if we are not likely to fix it soon.
- Tell people if a PR would be accepted. Tell them which files they may need to edit.
- Tell people to use stackoverflow/etc for issues with their own code. Then close these issues. Maybe link to some documentation on it if there is some.
- Labeling the module/OS/version they are on. If it's an issue with image loading label it 'image'. If it's on windows, label it 'windows', if it's an SDL2 issue label it SDL2.
- Adding tasks to the top of the issue including, 'add a unit test', 'add reproducable code' are helpful to see how far along the issue is to being fixed.
Dealing with code reviews and the automated testing of the Continuous Integration tools
So, you've come up with some excellent bug fixes, tests or improvements to pygame and you are wondering how to go from there to getting your code merged into the pygame mainline. Here are some top tips:
- Submit your code as a clean, focused pull request. Ideally this means that only the essential changes you made for the improvement you are making make it into your pull request. If you don't know what a pull request is then this guide from GitHub may be of some help.
- Create documentation. If you are making a new feature don't forget the documentation, pygames online docs are published from the github repo source files each time pygame is released, and if your feature doesn't have any documentation nobody will know it exists.
- Write unit & interactive tests. Whichever seem appropriate for making clear the intended uses of your module and testing out the full ranges of inputs and potential error states.
- Please be patient for code review. It can take some time, but also don't worry about it. It just means that somebody else from the pygame community will have a look over and run your code and check for things like tests, documentation and functionality. If you contribute to pygame enough you too may become a code reviewer and help us sift through the stacks of pull requests.
- Automated testing platforms (CI). CI runners are basically online testing robots that try and run any submitted pull requests on as wide a range of computing platforms and software versions as possible to check for compatibility. It can often take several attempts to get your perfectly-working local code to pass the inspection of these CI task masters. Don't stress about this its very common even for those of us that have been doing pull requests for a while. Common pitfalls include:
- The 'dummy' video driver. CI runners are just server machines on a rack somewhere in an amazon warehouse they don't have screens connected to them so pygame has to use a fake video driver called the 'dummy' to run pygame applications on them. This driver doesn't have the same range of functionality as the regular video drivers so it is not uncommon to have to skip a unit test when this driver is being used. You can activate it locally too by setting the SDL_VIDEODRIVER environment variable.
- Platform specific code. Sometimes code can be platform specific, what works on one can break on another. These would need conditional handling for the different platforms pygame supports
- Multiple versions of SDL/Python/other deps. Pygame should work on any SDL version higher than 2 and Python version higher than 3.6 (at the time of writing). At times there are features in SDL/Python that are only added in a minor or patch version. The code should make use of conditionals to error gracefully, or workaround this.
- If in doubt just ask in your pull request's comment page as it's likely someone will have seen a similar issue before and may be able to help.
Deprecation of old code
See https://github.com/pygame/pygame/issues/2197 for some discussion and PRs linked to it.
JAPANESE PATTERN-DESIGNER. JAPANESE PATTERN-DESIGNER. All that warm afternoon we paid the tiresome penalty of having pushed our animals too smartly at the outset. We grew sedate; sedate were the brows of the few strangers we met. We talked in pairs. When I spoke with Miss Harper the four listened. She asked about the evils of camp life; for she was one of that fine sort to whom righteousness seems every man's and woman's daily business, one of the most practical items in the world's affairs. And I said camp life was fearfully corrupting; that the merest boys cursed and swore and stole, or else were scorned as weaklings. Then I grew meekly silent and we talked in pairs again, and because I yearned to talk most with Camille I talked most with Estelle. Three times when I turned abruptly from her to Camille and called, "Hark!" the fagged-out horses halted, and as we struck our listening pose the bugle's faint sigh ever farther in our rear was but feebly proportioned to the amount of our gazing into each other's eyes. "I'm glad you didn't," Bruce smiled. "What a sensation those good people will have presently! And most of them have been on intimate terms with our Countess. My darling, I shall never be easy in my mind till you are out of that house." Those manifestations of sympathy which are often so much more precious than material assistance were also repugnant to Stoic principles. On this subject, Epict¨ºtus expresses himself with singular harshness. ¡®Do not,¡¯ he says, ¡®let yourself be put out by the sufferings of your friends. If they are unhappy, it is their own fault. God made them for happiness, not for misery. They are grieved at parting from you, are they? Why, then, did they set their affections on things outside themselves? If they suffer for their folly it serves them right.¡¯93 You are awfully good, Daddy, to bother yourself with me, when you're ¡°Some strong, pungent liquid had been poured on the green necklace,¡± the letter from the millionaire stated. ¡°No alarm was given. My wife did not want to broadcast either the fact that she had the real gems or the trouble in the hotel. But people had heard the ¡®fire!¡¯ cry and doubtless some suspected the possible truth, knowing why she was getting ready. ¡°But the switches that control the motor for the drum are right out on the wall in plain sight,¡± he told himself, moving over toward them, since the rolling door was left wide open when the amphibian was taken out. ¡°Yes, here they all are¡ªthis one up for lifting the door, and down to drop it. And that switch was in the neutral¡ª¡®off¡¯¡ªposition when we were first here¡ªand it¡¯s in neutral now.¡± The strong sense, lively fancy, and smart style of his satires, distinguished also Pope's prose, as in his "Treatise of the Bathos; or, the Art of Sinking in Poetry;" his "Memoirs of P. P., Clerk of this Parish"¡ªin ridicule of Burnet's "Own Times"¡ªhis Letters, etc. In some of the last he describes the country and country seats, and the life there of his friends; which shows that, in an age more percipient of the charm of such things, he would have probably approached nearer to the heart of Nature, and given us something more genial and delightful than anything that he has left us. The taste for Italian music was now every day increasing; singers of that nation appeared with great applause at most concerts. In 1703 Italian music was introduced into the theatres as intermezzi, or interludes, consisting of singing and dancing; then whole operas appeared, the music Italian, the words English; and, in 1707, Urbani, a male soprano, and two Italian women, sang their parts all in Italian, the other performers using English. Finally, in 1710, a complete Italian opera was performed at the Queen's Theatre, Haymarket, and from that time the Italian opera was regularly established in London. This led to the arrival of the greatest composer whom the world had yet seen. George Frederick Handel was born at Halle, in Germany, in 1685. He had displayed wonderful genius for music as a mere child, and having, at the age of seven years, astonished the Duke of Saxe Weissenfels¡ªat whose court his brother-in-law was a valet¡ªwho found him playing the organ in the chapel, he was, by the Duke's recommendation, regularly educated for the profession of music. At the age of ten, Handel composed the church service for voices and instruments; and after acquiring a great reputation in Hamburg¡ªwhere, in 1705, he brought out his "Almira"¡ªhe proceeded to Florence, where he produced the opera of "Rodrigo," and thence to Venice, Rome, and Naples. After remaining in Italy four years, he was induced to come to England in 1710, at the pressing entreaties of many of the English nobility, to superintend the opera. But, though he was enthusiastically received, the party spirit which raged at that period soon made it impossible to conduct the opera with any degree of self-respect and independence. He therefore abandoned the attempt, having sunk nearly all his fortune in it, and commenced the composition of his noble oratorios. Racine's "Esther," abridged and altered by Humphreys, was set by him, in 1720, for the chapel of the Duke of Chandos at Cannons. It was, however, only by slow degrees that the wonderful genius of Handel was appreciated, yet it won its way against all prejudices and difficulties. In 1731 his "Esther" was performed by the children of the chapel-royal at the house of Bernard Gates, their master, and the following year, at the king's command, at the royal theatre in the Haymarket. It was fortunate for Handel that the monarch was German too, or he might have quitted the country in disgust before his fame had triumphed over faction and ignorance. So far did these operate, that in 1742, when he produced his glorious "Messiah," it was so coldly received that it was treated as a failure. Handel, in deep discouragement, however, gave it another trial in Dublin, where the warm imaginations of the Irish caught all its sublimity, and gave it an enthusiastic reception. On its next presentation in London his audience reversed the former judgment, and the delighted composer then presented the manuscript to the Foundling Hospital, where it was performed annually for the benefit of that excellent institution, and added to its funds ten thousand three hundred pounds. It became the custom, from 1737, to perform oratorios[156] on the Wednesdays and Fridays in Lent. Handel, whose genius has never been surpassed for vigour, spirit, invention, and sublimity, became blind in his latter years. He continued to perform in public, and to compose, till within a week of his death, which took place on April 13, 1759. The Deacon took his position behind a big black walnut, while he reconnoitered the situation, and got his bearings on the clump of willows. He felt surer than ever of his man, for he actually saw a puff of smoke come from it, and saw that right behind the puff stood a willow that had grown to the proportions of a small tree, and had its bark rubbed off by the chafing of driftwood against it. "Certainly. I see it very plainly," said the Surgeon, after looking them over. "Very absurd to start such a report, but we are quite nervous on the subject of smallpox getting down to the army. "Yes, just one." Reuben pulled up his chair to the table. His father sat at one end, and at the other sat Mrs. Backfield; Harry was opposite Reuben. Reuben counted them¡ªten. Then he pushed them aside, and began rummaging in the cart among cabbages and bags of apples. In a second or two he had dragged out five more rabbits. Robert stood with hanging head, flushed cheeks, and quivering hands, till his father fulfilled his expectations by knocking him down. HoMEBT ÏÂÔØ ÀïÃÀÓÈÀûæ«
ENTER NUMBET 0016fzchain.com.cn
gjsxby.com.cn
www.gfltech.com.cn
luhuaji.org.cn
protestant.com.cn
qkxchs.com.cn
qhmg.com.cn
mnsfbd.com.cn
myjinkou.org.cn
wzchain.com.cn