wiki@my.terrot.net

Wiki@my.terrot.net is a service provided by Terrot.Net a company of the Terrot Research & Services Group.

Outils pour utilisateurs

Outils du site


python

Ceci est une ancienne révision du document !


Development Environment and librairies

Eclipse

  • pydev
  • mylin

Modules

Please here after the typical list of addition packages I'm using.
Most of same are compliant with pip download installation mode:
pip install <package> or <installation directory>\python.exe -m pip install <package>

  • doxypypy : required for documentation generation
  • pylint: required for code quality
  • openxl : MS Excel & Libreoffice calc files manipulation
  • pyqt5 :
  • py2exe
  • rtcclient : optional RTC management
  • lxml (see below for installation)
  • pywin32 (see below fo installation)

lxml installation instructions

As on Windows download pip lxml installation may failed, use the file pip installation mode:

pywin32 installation instructions

Three install solutions are availble:

  1. use pypiwin32 a pip compliant version of pywin32 but at time I'm writing this lines only the 2.19 is available where the official package is now available in version 2.20
  2. download the installation package from official site direct access to build 220 files
  3. Install form source package

= installation issue workaround = If the install package complains to not find any Python36 amd64 installation, try using the source package

= installation from source package =

  • Download the source package, unzip it
  • Make sure to have latest visual studio SDK installed
    • Choose Start, expand All Programs, Visual Studio, Visual Studio Tools, and then choose a command prompt
  • Make sure your python installation is in PATH
    SET PATH=<python.exe directory path>;%PATH%
  • Run the following command from source directory:\\C:\Apps\Python36\pywin32-220>python setup3.py -q install
  • If your experimented the following issue
> python setup3.pl install
Converting...
Executing...
Building pywin32 3.6.220.0
Traceback (most recent call last):
File "setup3.py", line 16, in <module>
    exec(str(got))
File "<string>", line 1944, in <module>
File "<string>", line 594, in __init__
File "C:\Apps\Python36\lib\ntpath.py", line 75, in join
    path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not NoneType

Setup.py is looking for Visual Studio SDK and is not able to find it (I got this with Visual Studio 15), to workaorinf this you have to manually set the MsSdk environment variable.

  • Search for windows.h in c:\Program Files (x86)\Microsoft SDKs
  • SET MSSdk=c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\
  • Run 'setup3.py -q build' or 'setup3.py -q install' command and waiting a while … (remove the -q to have detailled build) information
  • For a full installation process inclusing COM components do to same configuration and commands from a Command line opened 'as Adminstrator' (right click)
SET PYTHONDIR=C:\Apps\Python36
SET PATH=%PYTHONDIR%;%PATH%
# CD %PYTHONDIR%\pywin32-220
# SET MSSdk=c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\
# python setup3.py -q build
# python setup3.py -q install

Development Rules

Fundamental Rules

RUL_GEN_001 Comments

A comment is there to explain the code not to rephrase it.
Comment shall not contradict the code, update the comment with the code.

RUL_GEN_002 Important Rule

<note tip> If you don't understand why you should not modify a line, DON'T MODIFY IT! </note>

RUL_GEN_003 More Important Rule

Don't modify a line just to make it nicer, better, what ever justification you want, until there is a declared issue or an enhancement or task assigned to you linked with the line.

RUL_GEN_004 Mosy Important Rule

<note warning> In any case, Keep it simple </note>

Coding Rules

RUL_COD_001 : Python version

Python 3.6 is the preferred Python version. If Python2 is required use Python 2.7.<latest>

RUL_COD_002

Follow the Python development guidelines described in PEP008 with the following adaptations

Edition Rule

RUL_COD_003 Tab is not space

Configure your editor to replace TAB character by 4 spaces. If your editor is not enable to replace automatically don't use TAB.

RUL_COD_004 : UTF-8 (deprecated as default in Python3)

Make sure your environment is configured to use only 'UTF-8'.

# -- coding:UTF-8 --
RUL_COD_005 : Activate future features (Python2 only)

Make your Python2 code compliant with Python3 by inserting at least :

from __future__ import unicode_literals
from __future__ import print_function
RUL_COD_006 Indentation

Always use 4 spaces indentation except for function arguments indentation.

Strings

RUL_STR_01 bytes storage (was: str usage)

Python2: Use str only for internal 7 bits characters string or bytes storage
Python3: Use only bytes for bytes storage.

RUL_STR_002 QString usage

Use QString only for Qt API functions and methods, convert results as soon as possible to unicode to be compliant for Python functions.

RUL_STR_003 Use unicode

For all other strings use unicode only strings.

Classes

python.1483464478.txt.gz · Dernière modification : 2017/01/03 18:27 de francois

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki