From 32919da70aedeefe5d052c661a2383334802dc2b Mon Sep 17 00:00:00 2001 From: David Beniamine <david.beniamine@tetras-libre.fr> Date: Wed, 12 Sep 2018 15:36:10 +0200 Subject: [PATCH] Readme up --- Readme.md | 75 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 20 deletions(-) diff --git a/Readme.md b/Readme.md index b85f682..db030e4 100644 --- a/Readme.md +++ b/Readme.md @@ -12,37 +12,72 @@ Do a parallel imap[_unordered](func, tasks) with numProc processes + if debug is set to true, errors are also printed to stderr -## How to use +## Install -### As a subpackage +### pip -```python -from pyParallelRunAndWrite import parallelRunAndWrite as prw -# The following dependencies are only useful for testFunc -import os -from time import sleep -from random import randint - -def testFunc(arg): - ret=str(arg)+str(os.getpid()) - sleep(randint(2,5)) - if(randint(0,100)%2 ==0): - raise Exception("COUCOU"+ret) - return ret - -prw.parallelRunAndWrite(testFunc, range(5), "testplop", numProc=2, errFileName="errors") +```bash +pip3 install git+https://gitlab.tetras-libre.fr/tetras-libre/pyParallelRunAndWrite@master#egg=pyParallelRunAndWrite ``` -### By installing it +### For developpement ```bash +git clone https://gitlab.tetras-libre.fr/tetras-libre/pyParallelRunAndWrite pip3 install -e . ``` -Then : +### As a dependency in your setup.py + +```python +from setuptools.command.install import install +from setuptools.command.develop import develop +from setuptools import setup, find_packages +import pip + +... + +gitDeps = [ +'git+https://gitlab.tetras-libre.fr/tetras-libre/pyParallelRunAndWrite@master#egg=pyParallelRunAndWrite', + ] + + +def customRun(command_subclass): + orig_run = command_subclass.run + + def modified_run(self): + for dep in gitDeps: + pip.main(['install', dep]) + + orig_run(self) + + command_subclass.run = modified_run + return command_subclass + +@customRun +class actionsOnInstall(install): + pass + + +@customRun +class actionsOnDevelop(develop): + pass + +... + +setup( +... + cmdclass={'install': actionsOnInstall, + 'develop': actionsOnDevelop, +... +) + +``` + +## Usage ```python -import parallelRunAndWrite as prw +from parallelRunAndWrite import parallelRunAndWrite as prw # The following dependencies are only useful for testFunc import os from time import sleep -- GitLab