At the Python User Group Berlin, I lead a talk/discussion about free-of-charge tools for open-source development based on what we use GSoC. The whole content was in an Etherpad and people could add their ideas.
Because there are a lot of tools, I thought, I would share it with you. Maybe it is of use. Here is the talk:
Python Users Berlin 2016/07/14 Talk & Discussion
START: 19:15
Agenda 1min END: 19:15
======
– Example library
– What is code
– Version Control
– Python Package Index
– …, see headings
– discussion: write down, what does not fit into my structure
Example Library (2min) 19:17
======================
What is Code (2min) 19:19
===================
.. note:: This frames our discussion
– Source files .py, .pyw
– tests
– documentation
– quality
– readability
– bugs and problems
– <3
Configurationsfiles plain Text for editing
Version Control (2min) 19:21
======================
.. note:: Sharing and Collaboration
– no Version Control:
– Dropbox
– Google drive
– Telekom cloud
– ftp, windows share
– Version Control Tools:
– git
– gitweb own server
–
– mecurial
– svn
– perforce (proprietary)
Python Package Index (3min) 19:24
—————————
.. note:: Shipping to the users
hosts python packages you develop.
Example: “knittingpattern” package
pip
Installation from Pypi:
$ python3 -m pip install knittingpattern # Linux
> py -3.4 -m pip install knittingpattern # Windows
Documentation upload included!
Documentation (3min) 19:27
====================
.. note:: Inform users
I came across a talk:
Documentation can be:
– tutorials
– how to
– introduction to the community/development process
– code documentation!!!
– chat
–
Building the documentation (3min) 19:30
———————————
Formats:
– HTML
– PDF
– reRST
– EPUB
– doc strings in source code
– test?
Tools:
– Sphinx
– doxygen
– doc strings
– standard how to put in docstrings in Python
–
Example: Sphinx 3min 19:33
~~~~~~~~~~~~~~~
– Used for Python
– Used for knittingpattern
Python file:
Documentation file with sphinx.ext.autodoc:
Built documentation:
See the return type str, Intersphinx can reference across documentations.
Intersphinx uses objects inventory, hosted with the documentation:
Testing the documentation:
– TODO: link
– evertying is included in the docs
– everything that is public is documented
syntax
– numpy
– google
– sphinx
Hosting the Documentation (3min) 19:36
——————————–
Tools:
– pythonhosted
only latest version
– readthedocs.io
several branches, versions, languages
– wiki pages
–
Code Testing 2min 19:38
============
.. note:: Tests show the presence of mistakes, not their absence.
What can be tested:
– features
– style: pep8, pylint,
– documentation
– complexity
–
Testing Features with unit tests 4min 19:42
——————————–
code:
def fib(i): …
Tools with different styles
– unittest
import unittest
from fibonacci import fib
class FibonacciTest(unittest.TestCase):
def testCalculation(self):
self.assertEqual(fib(0), 0)
self.assertEqual(fib(1), 1)
self.assertEqual(fib(5), 5)
self.assertEqual(fib(10), 55)
self.assertEqual(fib(20), 6765)
if __name__ == “__main__”:
unittest.main()
– doctest
import doctest
def fib(n):
“””
Calculates the n-th Fibonacci number iteratively
>>> fib(0)
0
>>> fib(1)
1
>>> fib(10)
55
>>> fib(15)
610
>>>
“””
a, b = 0, 1
for i in range(n):
a, b = b, a + b
return a
if __name__ == “__main__”:
doctest.testmod()
– pytest (works with unittest)
import pytest
from fibonacci import fib
@pytest.mark.parametrize(“parameter,value”,[(0, 0), (1, 1), (10, 55), (15, 610)])
def test_fibonacci(parameter, value):
assert fib(parameter) == value
– nose tests?
– …
– pyhumber
– assert in code, PyHamcrest
– Behaviour driven development
– human test
Automated Test Run & Continuous Integration 2min 19:44
===========================================
.. note::
Several branches:
– production branch always works
– feature branches
– automated test before feature is put into production
Tools running tests 6min 19:50
——————-
– Travis CI for Mac, Ubuntu
– Appveyor for Windows
Host yourself:
– buildbot
– Hudson
– Jenkins
– Teamcity
– circle CI
+ selenium for website test
–
– …?????!!!!!!
Tools for code quality 4min 19:54
———————-
– landscape
complexity, style, documentation
– libraries are available separately
– flake8
– destinate
– pep257
– codeclimate
code duplication, code coverage
– libraries are available separately
– PyCharm
– integrated what landscape has
– + complexity
Bugs, Issues, Pull Requests, Milestones 4min 19:58
=======================================
.. note:: this is also a way to get people into the project
1. find bug
2. open issue if big bug, discuss
3. create pull request
4. merge
5. deploy
– github
issue tracker
– waffle.io – scrumboard
merge several github issues tracker
– Redmine
– JIRA
– trac
– github issues + zenhub integrated in github
– gitlab
1. propose change
2. test
3. someone reviews the code
– X people needed
QT company uses it
Localization 2min 20:00
============
crowdin.com
Crowdsourced translation tool:
Discussion
– spellchecker is integrated in PyCharm
– character set
– new vocabulary
– not for continuous integration (CI)
– Emacs
–
– pylint plugin
– not all languages?
– readthedocs
– add github project,
– hosts docs
– sphinx-plugin?
– PyCon testing talk:
– Hypothesis package
– tries to break your code
– throws in a lot of edge cases (huge number, nothing, …)
-> find obscure edge cases
Did someone create a Pylint plugin
– question:
– cyclomatic code complexity
– which metrics tools do you know?
–
Virtual Environment:
nobody should install everything in the system
-> switch between different python versions
– python3-venv
– slightly different than virtual-env(more mature)
Beginners:
Windows:
install Anaconda
You must be logged in to post a comment.