Mechaphlowers
Physical calculation package for the mechanics and geometry of overhead power lines.
User
Environment
Mechaphlowers is using uv for project, python version and dependencies management. You can use uv which is very similar to pip. You can also use other tools compatible with pip.
See uv documentation to install it.
You need a compatible python version. You may have to install it manually (e.g. with pyenv). Then you may create a virtualenv, install dependencies and activate the env:
1 2 | |
Tip
You would probably use an editor, make sure you configure it to use the same virtual environment you created (it will probably autodetect it) so that you can get autocompletion and inline errors. Here some links for VSCode and PyCharm.
Set up mechaphlowers
Install the package.
1 | |
Use it ! You can report to the user guide section or go to our tutorials notebook jupyter server to try it.
1 2 | |
Developers
Environment
You need to install the project with all the development and documentation packages:
1 2 3 | |
Checks and rules
Format and linter
Once dev dependencies are installed, you may format and lint python files like this:
1 2 | |
Use following command if you only want to check if files are correctly formatted:
1 | |
You may automatically fix some linting errors:
1 | |
Tip: if using VSCode/VSCodium, you may also use Ruff extension.
How to check typing
In order to check type hints consistency, you may run:
1 | |
How to test
1 2 | |
Run all checks in one
A Makefile provide a fast access to those different checks.
You may run every check mentioned above with just one command:
1 | |
Requirements
Lock file
The generation of the lock file is important.
Do not forget to update it with:
1 2 | |
Installation from lock file only
When syncing, uv can update the lock file. But it can be an unwanted behavior. In this case use:
1 | |
Pip compatibility
Requirements can be extracted with pip compile. See here for more information.
Build the library
Framework
We are using the pdm backend to build the package.
Version
The versioning is linked with the tag. To build a local version, you can add a tag, build version and then delete tag.
The tag is expected to have the following form: v0.1.2 and support alpha and beta version v0.1.2a0.
1 2 3 | |
The variable PACKAGE_BUILD_TEST can be used to add the .devXversion.
1 2 3 4 | |
Build
In order to build the library (wheel and tar.gz archive):
1 | |
You can check the build option to control the output folder or the desired output file types.
How to serve the documentation
You can build and serve the documentation using or make docs:
1 | |
Testing in a browser via pyodide
You may test your pyodide package using pyodide console in a browser.
Download pyodide
Download a version of Pyodide from the releases page, extract it and serve it with a web server:
1 2 3 4 | |
Pyodide console is then available at http://localhost:8000/console.html
Test in pyodide console
Copy needed wheels to pyodide folder. Then, in pyodide console:
1 2 3 | |