# Guide to get a basic development environment

**URL:** https://discuss.tryton.org/t/guide-to-get-a-basic-development-environment/1444
**Category:** Organisation
**Created:** [June 5, 2019, 4:25pm UTC](https://discuss.tryton.org/t/guide-to-get-a-basic-development-environment/1444 "2019-06-05T16:25:36Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![josesalvador](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/josesalvador/32/602_2.png) [@josesalvador](https://discuss.tryton.org/u/josesalvador)
#### Post date: [June 5, 2019, 4:25pm UTC](https://discuss.tryton.org/t/guide-to-get-a-basic-development-environment/1444/1 "2019-06-05T16:25:36Z")

</div>

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://www.tryton.org/develop)

[https://codereview.tryton.org/249431003/](https://codereview.tryton.org/249431003/)

# Guide

## trytond

Create a virtual environment:

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

```

Install dependencies:

```shell
(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:

```shell
(virtual_env) $ trytond/bin/trytond

```

Create and initialize database:

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

```

## tryton

Install requirements:

```shell
$ pip install --user pygobject python-dateutil

```

Test tryton client:

```shell
$ tryton/bin/tryton

```

## sao

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

```shell
$ npm install
$ grunt

```

Create symlink to sao:

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

```

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

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [June 5, 2019, 4:52pm UTC](https://discuss.tryton.org/t/guide-to-get-a-basic-development-environment/1444/2 "2019-06-05T16:52:26Z")

</div>

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

For example, we can add the following options:

- On the [install section](http://docs.tryton.org/projects/server/en/latest/topics/install.html), 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](http://docs.tryton.org/projects/server/en/latest/topics/setup_database.html) 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.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [June 6, 2019, 2:50pm UTC](https://discuss.tryton.org/t/guide-to-get-a-basic-development-environment/1444/3 "2019-06-06T14:50:08Z")

</div>

> [@josesalvador](#):
>
> Create a virtual environment:

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

> [@josesalvador](#):
>
> Install dependencies:

It will need to be updated once [Build a script to install all modules dependency (#5960) · Issues · Tryton / Tryton · GitLab](https://bugs.tryton.org/issue5960) is pushed.

> [@josesalvador](#):
>
> Install requirements:

Also to be removed by [tryton installed through 'pip install' does not work (#8408) · Issues · Tryton / Tryton · GitLab](https://bugs.tryton.org/issue8408)

> [@josesalvador](#):
>
> Create symlink to sao:

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.

> [@pokoli](#):
>
> On the [install section](http://docs.tryton.org/projects/server/en/latest/topics/install.html)

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

> [@pokoli](#):
>
> On the [Setup a database](http://docs.tryton.org/projects/server/en/latest/topics/setup_database.html) section we should add an example about settinga sqilte database with no configuration section.

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).

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [June 6, 2019, 4:41pm UTC](https://discuss.tryton.org/t/guide-to-get-a-basic-development-environment/1444/4 "2019-06-06T16:41:08Z")

</div>

> [@ced](#):
>
> I do not think we should put documentation about tryton-env in the trytond repository.

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

> [@ced](#):
>
> 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).

I think we should improve our docs by adding some examples. I reached this conclusion after comparing our documentation with the [flask documentation](http://flask.pocoo.org/docs/1.0/) (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.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [June 6, 2019, 4:50pm UTC](https://discuss.tryton.org/t/guide-to-get-a-basic-development-environment/1444/5 "2019-06-06T16:50:57Z")

</div>

> [@pokoli](#):
>
> So where should we put it? Only on the website?

I find here is the right place.

---

<div class="post-metadata">

### Author: ![josesalvador](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/josesalvador/32/602_2.png) [@josesalvador](https://discuss.tryton.org/u/josesalvador)
#### Post date: [June 8, 2019, 2:36pm UTC](https://discuss.tryton.org/t/guide-to-get-a-basic-development-environment/1444/6 "2019-06-08T14:36:31Z")

</div>

> [@pokoli](#):
>
> On the [install section](http://docs.tryton.org/projects/server/en/latest/topics/install.html)

I don’t think so 'cause this guide will be accesible from the link “Make your modification” in [Tryton - How to Develop](https://www.tryton.org/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.

> [@pokoli](#):
>
> On the [Setup a database](http://docs.tryton.org/projects/server/en/latest/topics/setup_database.html) section we should add an example about settinga sqilte database with no configuration section.

Totally agree. It fits very well.

---

<div class="post-metadata">

### Author: ![josesalvador](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/josesalvador/32/602_2.png) [@josesalvador](https://discuss.tryton.org/u/josesalvador)
#### Post date: [June 8, 2019, 2:42pm UTC](https://discuss.tryton.org/t/guide-to-get-a-basic-development-environment/1444/7 "2019-06-08T14:42:57Z")

</div>

> [@ced](#):
>
> Is it not better to first create the virtual environment and the clone the source?

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](https://www.tryton.org/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/](http://review)

> [@ced](#):
>
> It will need to be updated once [Issue 5960: Build a script to install all modules dependency - Tryton issue tracker](https://bugs.tryton.org/issue5960) is pushed.

Oks

> [@ced](#):
>
> Also to be removed by [Issue 8408: tryton installed through ‘pip install’ does not work - Tryton issue tracker](https://bugs.tryton.org/issue8408)

Oks

> [@ced](#):
>
> Indeed it is not needed if the path to sao is set into trytond.conf.

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

---

<div class="post-metadata">

### Author: ![josesalvador](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/josesalvador/32/602_2.png) [@josesalvador](https://discuss.tryton.org/u/josesalvador)
#### Post date: [June 8, 2019, 2:44pm UTC](https://discuss.tryton.org/t/guide-to-get-a-basic-development-environment/1444/8 "2019-06-08T14:44:27Z")

</div>

> [@pokoli](#):
>
> I think we should improve our docs by adding some examples. I reached this conclusion after comparing our documentation with the [flask documentation](http://flask.pocoo.org/docs/1.0/) (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

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.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [June 9, 2019, 10:41am UTC](https://discuss.tryton.org/t/guide-to-get-a-basic-development-environment/1444/9 "2019-06-09T10:41:29Z")

</div>

> [@josesalvador](#):
>
> 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

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.

---

<div class="post-metadata">

### Author: ![timitos](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/timitos/32/323_2.png) [@timitos](https://discuss.tryton.org/u/timitos)
#### Post date: [June 11, 2019, 2:54pm UTC](https://discuss.tryton.org/t/guide-to-get-a-basic-development-environment/1444/10 "2019-06-11T14:54:56Z")

</div>

> [@ced](#):
>
> > [@josesalvador](#):
> >
> > 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
> 
> 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.

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.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [June 11, 2019, 2:59pm UTC](https://discuss.tryton.org/t/guide-to-get-a-basic-development-environment/1444/11 "2019-06-11T14:59:22Z")

</div>

> [@timitos](#):
>
> 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.

---

<div class="post-metadata">

### Author: ![jaarias](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/jaarias/32/198_2.png) [@jaarias](https://discuss.tryton.org/u/jaarias)
#### Post date: [June 18, 2019, 10:59am UTC](https://discuss.tryton.org/t/guide-to-get-a-basic-development-environment/1444/12 "2019-06-18T10:59:09Z")

</div>

> (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?

---

<div class="post-metadata">

### Author: ![josesalvador](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/josesalvador/32/602_2.png) [@josesalvador](https://discuss.tryton.org/u/josesalvador)
#### Post date: [June 18, 2019, 11:30am UTC](https://discuss.tryton.org/t/guide-to-get-a-basic-development-environment/1444/13 "2019-06-18T11:30:35Z")

</div>

> [@jaarias](#):
>
> 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](https://hg.tryton.org/tryton-env/file/tip/README)
3. `hg update` create for you the necessary symlinks to tryton cloned modules

Next you can [initialize the database](http://docs.tryton.org/projects/server/en/latest/topics/setup_database.html#topics-setup-database) and interact with modules from tryton client as usual.

---

<div class="post-metadata">

### Author: ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)
#### Post date: [June 20, 2019, 1:51pm UTC](https://discuss.tryton.org/t/guide-to-get-a-basic-development-environment/1444/14 "2019-06-20T13:51:46Z")

</div>

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](https://www.tryton.org/develop). But you get the error

> Usage: upload.py [options] [-- diff\_options] [path…]  
> See also: [upload.py Usage · rietveld-codereview/rietveld Wiki · GitHub](https://github.com/rietveld-codereview/rietveld/wiki/upload.py-Usage)
> 
> upload.py: error: --oauth2\_port option requires an argument

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

---

<div class="post-metadata">

### Author: ![josesalvador](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/josesalvador/32/602_2.png) [@josesalvador](https://discuss.tryton.org/u/josesalvador)
#### Post date: [June 20, 2019, 2:13pm UTC](https://discuss.tryton.org/t/guide-to-get-a-basic-development-environment/1444/15 "2019-06-20T14:13:28Z")

</div>

Check it this way:

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

```

As is indicate [here](https://www.tryton.org/develop) although it has errata, you must use python2.

But that one will be fixed soon when [this review](https://codereview.tryton.org/249431003/diff/287391003/templates/develop.html) has been approved (although I have to put a little more work from my side to improve it…)

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [June 20, 2019, 2:19pm UTC](https://discuss.tryton.org/t/guide-to-get-a-basic-development-environment/1444/16 "2019-06-20T14:19:14Z")

</div>

`--oauth2` option is no more required. So I removed from the documentation [https://hg.tryton.org/www.tryton.org/rev/6c2f29f08656](https://hg.tryton.org/www.tryton.org/rev/6c2f29f08656)

---

<div class="post-metadata">

### Author: ![josesalvador](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/josesalvador/32/602_2.png) [@josesalvador](https://discuss.tryton.org/u/josesalvador)
#### Post date: [June 20, 2019, 2:54pm UTC](https://discuss.tryton.org/t/guide-to-get-a-basic-development-environment/1444/17 "2019-06-20T14:54:12Z")

</div>

> [@ced](#):
>
> `--oauth2` option is no more required.

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

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [June 20, 2019, 2:55pm UTC](https://discuss.tryton.org/t/guide-to-get-a-basic-development-environment/1444/18 "2019-06-20T14:55:40Z")

</div>

> [@josesalvador](#):
>
> is python3 compatible?

Not yet, see [need a python3 upload.py · Issue #247 · rietveld-codereview/rietveld · GitHub](https://github.com/rietveld-codereview/rietveld/issues/247)

---

<div class="post-metadata">

### Author: ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)
#### Post date: [June 20, 2019, 3:17pm UTC](https://discuss.tryton.org/t/guide-to-get-a-basic-development-environment/1444/19 "2019-06-20T15:17:03Z")

</div>

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

```auto
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.

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [June 20, 2019, 4:38pm UTC](https://discuss.tryton.org/t/guide-to-get-a-basic-development-environment/1444/20 "2019-06-20T16:38:11Z")

</div>

> [@edbo](#):
>
> 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?

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.

[Next page](https://discuss.tryton.org/t/guide-to-get-a-basic-development-environment/1444.md?page=2)
