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.