Guide to get a basic development environment

I would like to propose a little guide to get a development environment ready to work for newcomers to tryton.

This guide would be a new web page accessible through a link on “Make your modification.” phrase in Tryton - How to Develop

https://codereview.tryton.org/249431003/

Guide

trytond

Create a virtual environment:

$ cd .. # up folder level where tryton-env repository was cloned
$ python3 -m venv .
$ source bin/activate
$ cd tryton-env

Install dependencies:

(virtual_env) $ pip install werkzeug ldap3 python-stdnum simpleeval cached_property requests stripe csb43 febelfin-coda pyyaml future ofxparse zeep PyPDF2 wheel ldap3 python-stdnum simpleeval cached_property requests stripe csb43 febelfin-coda pyyaml future ofxparse zeep PyPDF2 wrapt python-sql python-dateutil polib genshi relatorio passlib

Test trytond server:

(virtual_env) $ trytond/bin/trytond

Create and initialize database:

$ mkdir -p ~/db
$ touch ~/db/test_db.sqlite
(virtual_env) $ trytond/bin/trytond-admin -d test_db -u ir res -v

tryton

Install requirements:

$ pip install --user pygobject python-dateutil

Test tryton client:

$ tryton/bin/tryton

sao

In case you want to develop with web client enter directory where sao was unpackaged and install it:

$ npm install
$ grunt

Create symlink to sao:

$ ln -s ~/path/to/directory/where/sao/is/placed www

Finally, test it setting localhost:8000 as the url in your browser.

1 Like

I think we should improve our docs by including some commands.

For example, we can add the following options:

  • On the install section, we can add a from sources section with explains how to use trytond-env with a virtualenv like you sugested
  • On the Setup a database section we should add an example about settinga sqilte database with no configuration section.

And then add links on the how to develop section to this sections.

Is it not better to first create the virtual environment and the clone the source?

It will need to be updated once Build a script to install all modules dependency (#5960) · Issues · Tryton / Tryton · GitLab is pushed.

Also to be removed by tryton installed through 'pip install' does not work (#8408) · Issues · Tryton / Tryton · GitLab

Indeed it is not needed if the path to sao is set into trytond.conf.
I personally use:

[web]
root = sao

and I always run trytond from the root of tryton-env.

I do not think we should put documentation about tryton-env in the trytond repository.

Is it really needed? I do not think it is a good advise to use SQLite for developing with running server (it is good for running tests).

So where should we put it? Only on the website?

I think we should improve our docs by adding some examples. I reached this conclusion after comparing our documentation with the flask documentation (which I consider a good one). I find that they always try some code example so the user can test from itself. I think we should include initialy a simple solution that works and then we can start introducing some complex examples.

Probably we can explain that sqlite can be used for testing proposes and then document how to configure postgres. This way the user has two working examples he can choose.

1 Like

I find here is the right place.

I don’t think so 'cause this guide will be accesible from the link “Make your modification” in Tryton - How to Develop where just the step before is a tryton-env repository clone. Moreover this seems to me a tryton sources clone to develop not to install it.

Totally agree. It fits very well.

Yep. But if we want to integrate this guide in another web page accesible from a link on “Make your modification” text in Tryton - How to Develop web page section we’ve to take account the previous step (tryton-env clone).

Other way we can do that as you say if delete “cd” command from the guide and https://codereview.tryton.org/249431003/

Oks

Oks

The goal of this guide is to be the simplest guide so with these steps you don’t need to create any trytond.conf file

I agree Sergi. It will be good to have it as an example in that section as an example of database to use with tests.

Then you can use TRYTOND_WEB__ROOT environment variable.
But I find that it is much more simpler to have a minimal configuration file that can be used for any clone (clone branch) and anywhere.

1 Like

Could it be an option to set the default value for the web root in the config to “sao” like you are using it? The current default value does not seem to be a good choice for me.

The default is the proper value when trytond is installed.
A random relative path could become a security issue.

(virtual_env) $ trytond/bin/trytond-admin -d test_db -u ir res -v

Atfer that, ¿which is the correct way to see from the Tryton Client the modules downloaded? I execute

(virtual_env) $ .hooks/link_modules

but I’m not sure if this is the right way: The README file says that you have to add a hook section in .hg/hgrc file but I don’t see how to deal with this… ¿It must be done after the hg clone? ¿And after that?

  1. hg clone
  2. edit .hg/hgrc as README indicates
  3. hg update create for you the necessary symlinks to tryton cloned modules

Next you can initialize the database and interact with modules from tryton client as usual.

Ok, so now you have made some changes and want to submit those changes to be reviewed and ultimately accepted. You download the upload.py script and execute it as stated on Tryton - How to Develop. But you get the error

Usage: upload.py [options] [-- diff_options] [path…]
See also: upload.py Usage · rietveld-codereview/rietveld Wiki · GitHub

upload.py: error: --oauth2_port option requires an argument

That wiki page isn’t very helpfull. So what needs to be done?

Check it this way:

$ python2 ~/.local/bin/upload.py --oauth2

As is indicate here although it has errata, you must use python2.

But that one will be fixed soon when this review has been approved (although I have to put a little more work from my side to improve it…)

--oauth2 option is no more required. So I removed from the documentation www.tryton.org: 6c2f29f08656

Ok. And… Is it still necessary to use python2 or is python3 compatible?

Not yet, see need a python3 upload.py · Issue #247 · rietveld-codereview/rietveld · GitHub

I’m on Fedora 30 which has default python2. I did now a

python ~/.local/bin/upload.py 

And had wait a bit, you don’t get instant reaction. Be aware of that because I already hit < CTRL> + C to stop the script.
But now I got the question:

New issue subject:

What do I have to fill in? I have already filed an enhancement-bug what should I answer? The issue number or the issue subject? Also which more questions are going to be asked and what should I answer with? Maybe the section “Submit a Change” on the website can be more detailed about that?

P.S. I’m sorry but I want to do it right and also hope with this exercise to lower the barrier on how to start development.

1 Like

You should use the following as subject:

repository: title

Where repository is the name of the repo your patch applies to (normally trytond, tryton or the name of the module) and title is the description of the change that you are submitting and that will be used as commit message.