Package: pygameweb
pygame.org websitePieces of the pygame website (https://www.pygame.org/) will be open sourced here.Strategy is to bring in code one piece at a time, and clean it up as I go.It’s a community website where people can post projects, comment on them,
but also write things in there themselves on wiki pages.ContributingPlease discuss contributions first to avoid disapointment and rework.Please seecontribution-guide.organdPython Code of Conductfor
details on what we expect from contributors. Thanks!The stack is something like: python 3.6, postgresql 9.6, Flask, py.test, sqlalchemy, alembic, gulp, ansible, node.QuickstartSet up the required packages:python3.6 -m venv anenv
. ./anenv/bin/activate
pip install --upgrade pip
pip install -r requirements.dev.txt
pip install -e .For now yuicompressor is needed for css compression:brew install yuicompressor node optipng
apt-get install yui-compressor nodejs optipngEnvironment setupcp example.env .envTool setupSee setup.cfg for all tool config (pytest, coverage, etc).Db setup instructionspostgresql 9.6One database for testing, and another one for running the app.We use alembic for db migrations.http://alembic.readthedocs.org/en/latest/Set up the postgresql database:createdb pygame
psql pygame -c "CREATE USER pygame WITH PASSWORD 'password';"
psql pygame -c "GRANT ALL PRIVILEGES ON DATABASE pygame to pygame;"We also create a database for running tests:createdb pygame_test
psql pygame -c "CREATE USER pygame_test WITH PASSWORD 'password';"
psql pygame_test -c "GRANT ALL PRIVILEGES ON DATABASE pygame_test to pygame_test;"To upgrade to latest model changes do:alembic upgrade headWhen you change a model make an alembic revision:alembic revision --autogenerate -m "Added a field for these reasons."Then you will need to apply the change to your db (and commit the version file):alembic upgrade headtesting with pytesthttp://docs.pytest.org/en/latest/To run all unit tests and functional tests use:pytestTo watch for changes and rerun tests:ptwMaybe you just want to test the wiki parts:pytest -k wikitests/unit/ are for unit tests.
tests/functional/ are for tests which would use flask and db.
tests/conftest.py is for test configuration.
tests/sqlpytestflask.py are some fixtures for db testing.Unit tests and functional tests are kept separate, because functional tests can take a while longer to run.We use various fixtures to make writing the tests easier and faster.Running the webserver locallyUse an environment variable to configure the database connection (see the
database setup steps above):export APP_DATABASE_URL="postgresql://pygame:password@localhost/pygame"Configure a directory containing static files:export APP_WWW="static/"The application may need a secure key, but for debugging it’s not important
that it’s properly random:export APP_SECRET_KEY="s3cret-stuff-blah"Finally, you can enable some Flask debugging machinery (which should be off for
the site in production):export APP_DEBUG=1Then run:pygameweb_frontTemplates with jinja2 and bootstrappygameweb/templates/We use:* `Jinja2 <http://jinja.pocoo.org/>`_
* `Flask-Bootstrap <https://pythonhosted.org/Flask-Bootstrap/basic-usage.html>`_
* `Bootstrap <http://getbootstrap.com/>`_Command line tools with clickWe use click and setuptools entry points (in setup.py) for command line tools:* `click <http://click.pocoo.org/5/>`_
* `entry points <https://packaging.python.org/distributing/#entry-points>`_Note, when you add or change a command line tool, you need topip install -e .again.If you can, try not to use command line options at all. Have one command do one thing,
and make the defaults good, or use the pygameweb.config.User login with Flask-security-forkpygameweb.user
pygameweb/templates/securityUsing:* `flask-security-fork <https://flask-security-fork.readthedocs.io/en/latest/quickstart.html>`_Navigation with flask-navpygameweb.nav
pygameweb.page.modelsUsing:* `flask-nav <http://pythonhosted.org/flask-nav/>`_
* `flask-bootstrap <https://pythonhosted.org/Flask-Bootstrap/nav.html>`_Dashboard is an overviewof all sorts of things happening in the pygame worlds around the interwebs.https://pygame.org/dashboardIt’s a 7000px wide webpage offering a summary of what’s happening.Projects people are working on,
videos folks are making,
tweets twits are… tweeting,
questions asked and answered.To caching things weuseFlask-Cachingpygameweb.cache
pygameweb.news.viewsWith with a @cache decorator, and/or markup in a template.ReleasesStep by step release instructions below.Commits tomasterbranch do a dev  deploy to pypi.Commits tomastertestbranch do a dev deploy to pypi.Commits to a tag do a real deploy to pypi.Prereleaseshttps://packaging.python.org/tutorials/distributing-packages/#pre-release-versioningPre releases should be named like this:` # pygameweb/__init__.py __version__ = '0.0.2' `Which is one version ahead of of the last tagged release.Release tags should be like ‘0.0.2’, and match thepygameweb/__init__.py __version__.Preparing a release in a branch.It’s a good idea to start a branch first, and make any necessary changes
for the release.` git checkout-bv0.0.2 vi pygameweb/__init__.py __version__ = '0.0.2' git commit-m"Version 0.0.2" `Change log, drafting a release.Github ‘releases’ are done as well.
You can start drafting the release notes in there before the tag.https://help.github.com/articles/creating-releases/You can make the release notes with the help of the changes since last release.https://github.com/pygame/pygameweb/compare/0.0.1…mastergit log 0.0.1…masterTagging a releaseWhen the release is tagged, pushing it starts the deploy to pypi off.` git tag-a0.0.2 git push origin 0.0.2 `Note: do not tag pre releases
(these are made on commits tomaster/mastertest).After the tag is pushed, then you can do the release
in github from your draft release.Back to dev version.If we were at 0.0.2 before, now we want to be at 0.0.3.dev` vi pygameweb/__init__.py __version__ = '0.0.3.dev' `Merge the release branch into master, and push that up.