Skip to content

Commit b25b38b

Browse files
committed
Add more info on Python code and the bin directory
1 parent f422812 commit b25b38b

File tree

2 files changed

+62
-2
lines changed

2 files changed

+62
-2
lines changed

doc/.template.coding.ipynb

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,15 @@
263263
"(For reference, the whole file is also available [at GitHub](https://github.com/salilab/imp_coding_tutorial/tree/main/modules/foo/pyext/swig.i-in))."
264264
]
265265
},
266+
{
267+
"cell_type": "markdown",
268+
"metadata": {},
269+
"source": [
270+
"> You can also add arbitrary Python code to your module. This is added to the `swig.i-in` file using the SWIG `%pythoncode` directive. See the [PMI module](https://github.com/salilab/pmi/blob/develop/pyext/swig.i-in) for an example.\n",
271+
">\n",
272+
"> You can also add entire Python submodules by adding Python files to the `pyext/src` subdirectory. For example the file `pyext/src/my_python.py` can be imported in Python using `import IMP.foo.my_python`. This is also [used in the PMI module](https://github.com/salilab/pmi/tree/develop/pyext/src)."
273+
]
274+
},
266275
{
267276
"cell_type": "markdown",
268277
"metadata": {},
@@ -361,6 +370,17 @@
361370
"(For reference, the whole file is also available [at GitHub](https://github.com/salilab/imp_coding_tutorial/tree/main/modules/foo/test/test_restraint.py))."
362371
]
363372
},
373+
{
374+
"cell_type": "markdown",
375+
"metadata": {},
376+
"source": [
377+
"# bin directory (command line tools) {#bin}\n",
378+
"\n",
379+
"IMP modules can include command line tools. We don't include any such tools in this module, but to add a tool, add a C++ or Python file to the `bin` directory. The tool will be compiled if needed and then installed with the rest of IMP in the binary directory (e.g. `/usr/local/bin`). See the [FoXS module](https://github.com/salilab/imp/tree/develop/modules/foxs/bin) for an example C++ command line tool and the [em module](https://github.com/salilab/imp/tree/develop/modules/em/bin) for example Python tools.\n",
380+
"\n",
381+
"> Usually command line tools are all installed in the same directory, so take care to give each program a fairly unique name so as not to conflict with other IMP programs or the operating system itself."
382+
]
383+
},
364384
{
365385
"cell_type": "markdown",
366386
"metadata": {},
@@ -387,6 +407,15 @@
387407
"(For reference, the whole file is also available [at GitHub](https://github.com/salilab/imp_coding_tutorial/tree/main/modules/foo/dependencies.py))."
388408
]
389409
},
410+
{
411+
"cell_type": "markdown",
412+
"metadata": {},
413+
"source": [
414+
"# Pure Python modules {#pyonly}\n",
415+
"\n",
416+
"If there is no C++ code in your module at all - i.e. it is pure Python - then you can speed up building of your module by marking it as Python only. This is done by adding `python_only = True` to the `dependencies.py` file. SWIG is not used in Python-only modules; instead, put any Python code you want in the top-level module in the `pyext/src/__init__.py` file. For an example, see the [IMP.test module](https://github.com/salilab/imp/tree/develop/modules/test). See the [IMP manual](@ref pyonlymod) for more information."
417+
]
418+
},
390419
{
391420
"cell_type": "markdown",
392421
"metadata": {},
@@ -579,7 +608,7 @@
579608
"name": "python",
580609
"nbconvert_exporter": "python",
581610
"pygments_lexer": "ipython3",
582-
"version": "3.11.4"
611+
"version": "3.12.1"
583612
}
584613
},
585614
"nbformat": 4,

doc/coding.ipynb

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
" - [pyext directory (Python interface)](#pyext)\n",
1818
" - [Documentation](#documentation)\n",
1919
" - [test directory (test cases)](#test)\n",
20+
" - [bin directory (command line tools)](#bin)\n",
2021
" - [Dependencies](#depends)\n",
22+
" - [Pure Python modules](#pyonly)\n",
2123
" - [Source control](#sourcecontrol)\n",
2224
" - [Build and test](#buildtest)\n",
2325
" - [Automatic testing](#autotest)\n",
@@ -276,6 +278,15 @@
276278
"(For reference, the whole file is also available [at GitHub](https://github.com/salilab/imp_coding_tutorial/tree/main/modules/foo/pyext/swig.i-in))."
277279
]
278280
},
281+
{
282+
"cell_type": "markdown",
283+
"metadata": {},
284+
"source": [
285+
"> You can also add arbitrary Python code to your module. This is added to the `swig.i-in` file using the SWIG `%pythoncode` directive. See the [PMI module](https://github.com/salilab/pmi/blob/develop/pyext/swig.i-in) for an example.\n",
286+
">\n",
287+
"> You can also add entire Python submodules by adding Python files to the `pyext/src` subdirectory. For example the file `pyext/src/my_python.py` can be imported in Python using `import IMP.foo.my_python`. This is also [used in the PMI module](https://github.com/salilab/pmi/tree/develop/pyext/src)."
288+
]
289+
},
279290
{
280291
"cell_type": "markdown",
281292
"metadata": {},
@@ -374,6 +385,17 @@
374385
"(For reference, the whole file is also available [at GitHub](https://github.com/salilab/imp_coding_tutorial/tree/main/modules/foo/test/test_restraint.py))."
375386
]
376387
},
388+
{
389+
"cell_type": "markdown",
390+
"metadata": {},
391+
"source": [
392+
"# bin directory (command line tools)<a id=\"bin\"></a>\n",
393+
"\n",
394+
"IMP modules can include command line tools. We don't include any such tools in this module, but to add a tool, add a C++ or Python file to the `bin` directory. The tool will be compiled if needed and then installed with the rest of IMP in the binary directory (e.g. `/usr/local/bin`). See the [FoXS module](https://github.com/salilab/imp/tree/develop/modules/foxs/bin) for an example C++ command line tool and the [em module](https://github.com/salilab/imp/tree/develop/modules/em/bin) for example Python tools.\n",
395+
"\n",
396+
"> Usually command line tools are all installed in the same directory, so take care to give each program a fairly unique name so as not to conflict with other IMP programs or the operating system itself."
397+
]
398+
},
377399
{
378400
"cell_type": "markdown",
379401
"metadata": {},
@@ -400,6 +422,15 @@
400422
"(For reference, the whole file is also available [at GitHub](https://github.com/salilab/imp_coding_tutorial/tree/main/modules/foo/dependencies.py))."
401423
]
402424
},
425+
{
426+
"cell_type": "markdown",
427+
"metadata": {},
428+
"source": [
429+
"# Pure Python modules<a id=\"pyonly\"></a>\n",
430+
"\n",
431+
"If there is no C++ code in your module at all - i.e. it is pure Python - then you can speed up building of your module by marking it as Python only. This is done by adding `python_only = True` to the `dependencies.py` file. SWIG is not used in Python-only modules; instead, put any Python code you want in the top-level module in the `pyext/src/__init__.py` file. For an example, see the [IMP.test module](https://github.com/salilab/imp/tree/develop/modules/test). See the [IMP manual](https://integrativemodeling.org/2.20.1/doc/manual/pyonlymod.html) for more information."
432+
]
433+
},
403434
{
404435
"cell_type": "markdown",
405436
"metadata": {},
@@ -592,7 +623,7 @@
592623
"name": "python",
593624
"nbconvert_exporter": "python",
594625
"pygments_lexer": "ipython3",
595-
"version": "3.11.4"
626+
"version": "3.12.1"
596627
}
597628
},
598629
"nbformat": 4,

0 commit comments

Comments
 (0)