Skip to content

Commit c57694f

Browse files
authored
added one more solution
1 parent ab020ba commit c57694f

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

README.md

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# compact testprogram distribution
1+
# Compact testprogram distribution
22

33
Zipapps are a sensible way to be able to distribute test programs with reasonable dependencies.
44

5-
For executing robotframework in order to perform production facility / test floor automated tasks
5+
For executing Robot Framework in order to perform production facility / test floor automated tasks
66
the dependency list becomes.:
77

88
- The operating system
@@ -15,7 +15,7 @@ The only dependency is a python interpreter with a minimum version number, and t
1515
that only zipapp compatible dependencies can be used.
1616

1717
For python versions 3.10 and 3.11 it is recommended to disable zipimport.zipimporter.invalidate_caches
18-
as it has a large performance impact. Disabling it, looses the feature to modify the zipapp during
18+
as it has a large performance impact. Disabling it, loses the feature to modify the zipapp during
1919
runtime...
2020

2121
### Using pdm with pdm-packer
@@ -30,7 +30,7 @@ A python only zipapp without any native code.
3030
```
3131
At this point you are presented with robot output...
3232

33-
### Minimal Zipapp Build (a.k.a. Limbo Mode)
33+
### Minimal zipapp build (a.k.a. Limbo Mode)
3434

3535
let’s reduce the size of the zipapp.:
3636

@@ -75,39 +75,48 @@ close to the size of a python installer (28MBytes), and is a self contained, sin
7575

7676
cx_freeze does use script entry points.
7777

78-
Robotframework does come with a script, which is documented [here](https://robot-framework.readthedocs.io/en/latest/autodoc/robot.html#module-robot.run).
78+
Robot Framework does come with a script, which is documented [here](https://robot-framework.readthedocs.io/en/latest/autodoc/robot.html#module-robot.run).
7979

8080
What is not documented (and as far as I understand from this [discussion](https://github.com/robotframework/robotframework/issues/5384) will not be, this
8181
[pull request](https://github.com/robotframework/robotframework/pull/5390) was provided to remove pythonpathsetter), is that this script needs to live in
82-
the source tree, and can not use an installed robotframework, like in the zipapp/frozenapp/etc use case.
82+
the source tree, and can not use an installed Robot Framework, like in the zipapp/frozenapp/etc use case.
8383

8484
### background
85-
It is possible to use robotframework straight from the source tree, without installation or configuring PYTHONPATH. This feature is not documented in the
85+
It is possible to use Robot Framework straight from the source tree, without installation or configuring PYTHONPATH. This feature is not documented in the
8686
end user documentation, and not explained in the CONTRIBUTING.rst.
8787

88-
This is implemented using the `pythonpathsetter` module which can be loaded by `import pythonpathsetter` when the robotframework is run from the script,
89-
additionally by `import robot.pythonpathsetter` when the script runs inside an environment where robotframework was installed into, and only using
88+
This is implemented using the `pythonpathsetter` module which can be loaded by `import pythonpathsetter` when the Robot Framework is run from the script,
89+
additionally by `import robot.pythonpathsetter` when the script runs inside an environment where Robot Framework was installed into, and only using
9090
`import robot.pythonpathsetter`. This module changes the the `sys.path` at runtime, which can cause severe confusion when debugging dependency issues.
9191

9292
These are the symptoms to look out for.:
93-
1 is that robotframework fails, as pythonpathsetter can not be imported.
93+
1 is that Robot Framework fails, as pythonpathsetter can not be imported.
9494
2 you can use ```import robot; robot.run()``` when debugging from a REPL.
9595

9696
In total at the time of writing there are 34 instances of ```sys.path``` and 89 ```__file__```in the source, all of them bring the risk of causing issues
9797
with zipapp/frozenapp usage. When I went over the source the first time, I missed how the ```pythonpathsetter``` can cause issues.
9898

9999
### solutions
100100
#### make sure pythonpathsetter exits
101-
Install a ```pythonpathsetter.py``` into your environment. Be aware future releases of robotframework will call a ```pythonpathsetter.set_pythonpath```
102-
which is in the source tree where you would expect ```robot.pythonpathsetter.set_pythonpath```. It doesnt need to do anything but if it is missing the code
101+
Install a ```pythonpathsetter.py``` into your environment. Be aware future releases of Robot Framework will call a ```pythonpathsetter.set_pythonpath``` fucntion.
102+
This function is in the source tree where you would expect ```robot.pythonpathsetter.set_pythonpath```. It doesn’t need to do anything but if it is missing the code
103103
will not work. This change is introduced in response to linter messages.
104104

105-
#### do not use robotframework distributed scripts
105+
#### do not use Robot Framework distributed scripts
106106
Provide your own start script.
107107

108+
#### [merge](https://github.com/robotframework/robotframework/pull/5390) (would need to come from upstream)
109+
Apart of improving the situation for frozenapp/zipapp use cases this brings these advantages.:
110+
111+
1) Reduction of total complexity (cyclomatic complexity goes from 18329 to 18307 a delta of 22, number of lines from 58033 to 57967, a delta of 134)
112+
2) The ```pythonpathsetter``` feature is not advertised. It is likely that its most common use is in Robot Framework quality control.
113+
- if that would make testing easier/faster for multiple python installations that might be worth the risk.
114+
- solutions like [uvx](https://docs.astral.sh/uv/) ```uvx --python 3.14 --from . --reinstall robot``` are available, taking care of warehousing the python versions
115+
It is hard to get this point across, but the "unpack into a directory" distribution method is very much outdated by now.
116+
108117
#### do not modify the ```sys.path``` (would need to come from upstream)
109118
Placing this code into the src directory, next to the robot directory of the source distribution. Using this code allows the robot code base to reduce
110-
the modifications of the ```sys.path```, while keeping the feature to use robotframework straight from the source directory.
119+
the modifications of the ```sys.path```, while keeping the feature to use Robot Framework straight from the source directory.
111120

112121
```python
113122
import pathlib
@@ -118,13 +127,13 @@ if __name__ == "__main__":
118127
with source.open() as run:
119128
source_code = run.read()
120129
except Exception as e:
121-
print(f"""run_rf is a tool allowing you to start robotframework from a source tree without installing anything. Exception {e} occurred.
130+
print(f"""run_rf is a tool allowing you to start Robot Framework from a source tree without installing anything. Exception {e} occurred.
122131
123-
This script should not be used outside of robotframework development, and is not part of robotframework itself.""")
132+
This script should not be used outside of Robot Framework development, and is not part of Robot Framework itself.""")
124133
exec(source_code)
125134
```
126135

127-
### consequence
136+
### conclusion
128137
There are alternatives available.
129138

130139
- docker (way more heavy weight, user rights need to be managed)

0 commit comments

Comments
 (0)