11# PyHP-Interpreter ![ Tests] ( https://github.com/Deric-W/PyHP/workflows/Tests/badge.svg ) [ ![ codecov] ( https://codecov.io/gh/Deric-W/PyHP/branch/master/graph/badge.svg?token=SA72E6KGXT )] ( https://codecov.io/gh/Deric-W/PyHP ) [ ![ License: GPL v3] ( https://img.shields.io/badge/License-GPLv3-blue.svg )] ( https://www.gnu.org/licenses/gpl-3.0 )
22
3- The PyHP Interpreter is a package that allows you to embed Python code like PHP code into HTML and other text files.
4- The script is called either by the configuration of the web server or a shebang and communicates with the web server via CGI.
3+ PyHP is a package that allows you to embed Python code like PHP code into HTML and other text files.
4+ A script is called either by the configuration of the web server or a shebang and communicates with the web server via CGI.
55
66## Features:
77
@@ -14,10 +14,8 @@ The script is called either by the configuration of the web server or a shebang
1414## How it works:
1515
1616 - Python code is contained within the ` <?pyhp ` and ` ?> ` tags (like PHP)
17- - the program is called like a interpreter, with the filepath as cli parameter
18- - if no filepath is given, the program is reading from stdin
19- - if the ` -c ` or ` --caching ` is given, the cache will be enabled and the file will additionally be preprocessed if needed
20- and cached in cache_path/absolute/path/of/filename.cache
17+ - the program is called like a interpreter, with a name as cli parameter
18+ - if no name is given, the program is reading from stdin, else it is using the name to load code from the backend configured in pyhp.toml
2119 - python code is allowed to have a starting indentation for better readability inside (for example) HTML files
2220 - the following PHP features are available as methods of the ` PyHP ` class (available from the outside in pyhp.libpyhp):
2321 - ` $_SERVER ` as ` SERVER `
@@ -34,21 +32,23 @@ The script is called either by the configuration of the web server or a shebang
3432 - ` setcookie ` with an additional ` samesite ` keyword argument
3533 - ` setrawcookie ` also with an additional ` samesite ` keyword argument
3634 - ` register_shutdown_function `
37-
38-
39- ## Cache Handlers
35+
36+ ## Config file
37+
38+ - is valid toml
39+ - is looked for in these locations (no merging takes place, the first file wins):
40+ - the path given by the ` -c ` or ` --config ` cli argument
41+ - the path pointed to by the ` PYHPCONFIG ` environment variable
42+ - ` ~/.config/pyhp.toml `
43+ - ` /etc/pyhp.toml `
44+ - raises a ` RuntimeError ` if not found
4045
41- - are responsible for saving/loading/renewing caches
42- - are python scripts with the following contents:
43- - the ` Handler ` class, wich takes the cache path, absolute file path and ` caching ` section of the config file as
44- initialization parameters and provides the following methods:
45- - ` is_available ` , wich returns a boolean indicating if the handler can be used
46- - ` is_outdated ` , wich returns a boolean indicating if the cache needs to be renewed
47- - ` save ` , wich takes an code object as an argument and saves it in the cache
48- - ` load ` , wich loads an code object from the cache
49- - ` close ` , wich does cleanup tasks and gets called when used as a context manager
50- - note that code objects have to support the pickle protocol
51- - examples are available in the * cache_handlers* directory
46+ ## Backends
47+
48+ - implement code retrieval or decorate other backends to add i.a. caching
49+ - act as containers for CodeSources
50+ - form a hierarchy configured in pyhp.toml
51+ - are contained inside ` pyhp.backends `
5252
5353 ## Installation
5454
@@ -58,22 +58,15 @@ The script is called either by the configuration of the web server or a shebang
5858 ### Just as python package
5959 1 . build the * pyhp-core* python package with ` python3 setup.py bdist_wheel `
6060 2 . Done! You can now install the wheel contained in the * dist* directory with pip
61-
62- ### As application
63- If you just installed the python package, then you have to provide ` --config ` with every call of ` python3 -m pyhp `
64- and can't use the caching feature.
65- To stop this, you can build a debian package or install PyHP manually.
66-
67- #### Debian package
61+
62+ ### Debian package
6863 1 . build the * pyhp-core* python package with ` python3 setup.py bdist_wheel `
6964 2 . go to the * debian* directory and execute ` ./build_deb.sh `
7065 3 . enter a package version, the path of the * pyhp-core* wheel and the pip command you wish to use
7166 4 . Done! You can now install the debian package with ` sudo dpkg -i pyhp_<package version>_all.deb `
72-
73- #### Manually
67+
68+ ### Manually
7469 1 . install the * pyhp-core* python package
75- 2 . copy * pyhp.conf* to * /etc*
76- 3 . copy * cache_handlers* to * /lib/pyhp/*
77- 4 . copy * debian/pyhp* to a directoy in your PATH
78- 5 . Done! You can now use the ` pyhp ` command
79-
70+ 2 . copy * pyhp.toml* to one of the config file locations
71+ 3 . Done! You can now use the ` pyhp ` command
72+
0 commit comments