|
|
This page provides a guideline in how to build the NetCDF-Creator application from scratch on your own machine using Python. The building of the application is based on `fbs` developed by Michael Herrmann (see his [website](https://build-system.fman.io/) and an example on his [github page](https://github.com/mherrmann/fbs-tutorial) for further information)
|
|
|
This page provides a guideline on how to build the NetCDF-Creator application from scratch on your own machine using Python. The building of the application is based on `fbs` developed by Michael Herrmann (see his [website](https://build-system.fman.io/) and an example on his [github page](https://github.com/mherrmann/fbs-tutorial) for further information).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Setup Python
|
|
|
# A) Setup Python
|
|
|
|
|
|
## 1. Installing Python
|
|
|
|
|
|
If you already have Anaconda installed skip this step and continue with step 2.
|
|
|
|
|
|
If only installing python for this purpose get the last miniconda release for python3.6 from <https://repo.anaconda.com/miniconda/> which is `Miniconda3-4.5.4`. Download and install.
|
|
|
In case you are only installing python for this purpose get the last Miniconda release for python3.6 from <https://repo.anaconda.com/miniconda/> which is `Miniconda3-4.5.4`. Download and install for your respective platform.
|
|
|
|
|
|
## 2. Python3.6 Virtual environment
|
|
|
## 2. Virtual environment
|
|
|
|
|
|
Open a terminal (Anaconda Prompt for Windows) and create a virtual environment with python3.6.
|
|
|
Open a terminal (_Anaconda Prompt_ <img src="icons/windows-brands.svg" height="15">), create a virtual environment for python3.6 and active it:
|
|
|
|
|
|
```plaintext
|
|
|
```
|
|
|
conda create -n myenv python=3.6
|
|
|
conda activate myenv
|
|
|
```
|
|
|
|
|
|
# Clone the NetCDF-Creator repository
|
|
|
You can download the repository as a .zip file or clone it using `git`:
|
|
|
```plaintext
|
|
|
# B) Clone the NetCDF-Creator repository
|
|
|
You can download the repository as a `.zip` file or clone it using `git`:
|
|
|
```
|
|
|
git clone git@gitlab.com:ykern/netcdf-creator.git
|
|
|
```
|
|
|
|
|
|
# Install required Python packages
|
|
|
# C) Install required Python packages
|
|
|
|
|
|
```
|
|
|
conda install numpy scipy netcdf4 natsort
|
|
|
conda install -c conda-forge mergedeep compliance-checker xmltodict
|
|
|
```
|
|
|
|
|
|
## Linux <img src="icons/linux-brands.svg" height="30">
|
|
|
## Linux <img src="icons/linux-brands.svg" height="30">
|
|
|
|
|
|
## Mac <img src="icons/apple-brands.svg" height="30">
|
|
|
## Mac <img src="icons/apple-brands.svg" height="30">
|
|
|
|
|
|
## Windows <img src="icons/windows-brands.svg" height="30">
|
|
|
## Windows <img src="icons/windows-brands.svg" height="30">
|
|
|
|
|
|
```
|
|
|
pip install fbs==0.8.9
|
... | ... | @@ -45,7 +45,7 @@ conda install -c conda-forge pyside2==5.12.4 |
|
|
conda install pywin32
|
|
|
```
|
|
|
|
|
|
# Compile and run application
|
|
|
# D) Compile and run application
|
|
|
|
|
|
It should now be possible to run NetCDF-Creator using the command
|
|
|
|
... | ... | @@ -53,32 +53,32 @@ It should now be possible to run NetCDF-Creator using the command |
|
|
fbs run
|
|
|
```
|
|
|
|
|
|
Note: you need to be in the home directory of the `src` folder since fbs requires that folder and its structure in order to function.
|
|
|
Note: you need to navigate to the home directory of the `src/` directory because `fbs` requires this folder and its structure in order to function.
|
|
|
|
|
|
# Tweaks for freezing
|
|
|
# E) Tweaks for freezing
|
|
|
|
|
|
In order to build a stand-alone version of the NetCDF-Creator application a few tweaks are necessary. Tweak files are located in the `tweaks` folder. For this you need to locate the `site-packages` directory of your environment. This is usually located as following:
|
|
|
In order to build a stand-alone version of the NetCDF-Creator application a few tweaks are necessary. Tweak files are located in the `tweaks/` directory of the repository. For this you need to locate the `site-packages/` directory of your environment. It is usually located as following:
|
|
|
|
|
|
- Windows: `...\AppData\Local\conda\conda\envs\py36\lib\site-packages\`
|
|
|
- [ ] Mac TODO
|
|
|
- [ ] Linux TODO
|
|
|
|
|
|
The quickest is to just replace the files as described. However, in case the files change there is also instructions to do the changes manually.
|
|
|
The quickest is to just replace the files as described. However, in case the original packages change there are also instructions to apply the tweaks manually.
|
|
|
|
|
|
## 1. cf_units
|
|
|
|
|
|
- **FILE** `__init__.py`
|
|
|
- **PATH** `site-packages/cf_units/__init__.py`
|
|
|
- **FIX** locate udunits2.xml in ressources of application
|
|
|
- **EDIT** Locate udunits2.xml in resource directory of application.
|
|
|
|
|
|
Quick fix: Replace `__init__.py` with `tweaks/cf_units/__init__.py`
|
|
|
Replace `__init__.py` with `tweaks/cf_units/__init__.py`
|
|
|
|
|
|
<details>
|
|
|
<summary>Manual fix</summary>
|
|
|
<summary>Manual edit</summary>
|
|
|
|
|
|
In line 190 replace:
|
|
|
|
|
|
```plaintext
|
|
|
```
|
|
|
_alt_xml_path = config.get_option(
|
|
|
'System', 'udunits2_xml_path',
|
|
|
default=os.path.join(sys.prefix, 'share', 'udunits',
|
... | ... | @@ -87,7 +87,7 @@ In line 190 replace: |
|
|
|
|
|
with the following:
|
|
|
|
|
|
```plaintext
|
|
|
```
|
|
|
# START EDIT
|
|
|
#_alt_xml_path = config.get_option(
|
|
|
# 'System', 'udunits2_xml_path',
|
... | ... | @@ -108,12 +108,12 @@ with the following: |
|
|
### cf.py
|
|
|
* **FILE** `cf.py`
|
|
|
* **PATH** `site-packages/compliance_checker/cf/cf.py`
|
|
|
* **FIX** get XML table version from appdata folder
|
|
|
* **EDIT** Get XML table version from Appdata directory.
|
|
|
|
|
|
Quick fix: Replace `cf.py` with `tweaks/compliance_checker/cf.py`
|
|
|
Replace `cf.py` with `tweaks/compliance_checker/cf.py`
|
|
|
|
|
|
<details>
|
|
|
<summary>Manual fix</summary>
|
|
|
<summary>Manual edit</summary>
|
|
|
|
|
|
Starting in line 681 replace:
|
|
|
```
|
... | ... | @@ -174,11 +174,11 @@ with the following: |
|
|
### runner.py
|
|
|
- **FILE** `runner.py`
|
|
|
- **PATH** `site-packages/compliance_checker/runner.py`
|
|
|
- **FIX** take checkers from ressources because fbs seems not to copy the needed libraries
|
|
|
- **EDIT** Take checkers from resource directory because `fbs` seems not to copy the required libraries for it by itself.
|
|
|
|
|
|
Quick fix: Replace `runner.py` with `tweaks/compliance_checker/runner.py`
|
|
|
Replace `runner.py` with `tweaks/compliance_checker/runner.py`
|
|
|
<details>
|
|
|
<summary>Manual fix</summary>
|
|
|
<summary>Manual edit</summary>
|
|
|
|
|
|
Add the following after line 62 (`cs = CheckSuite(options=options or {})`)
|
|
|
```
|
... | ... | @@ -198,11 +198,11 @@ Add the following after line 62 (`cs = CheckSuite(options=options or {})`) |
|
|
## 3. fbs
|
|
|
- **FILE** `hook-PySide2.py`
|
|
|
- **PATH** `site-packages/fbs/freeze/hooks/hook-PySide2.py`
|
|
|
- **FIX** Include PySide2 correctly
|
|
|
- **EDIT** Include PySide2 path correctly.
|
|
|
|
|
|
Quick fix: Replace `hook-PySide2.py` with `tweaks/fbs/hook-PySide2.py`
|
|
|
Replace `hook-PySide2.py` with `tweaks/fbs/hook-PySide2.py`
|
|
|
<details>
|
|
|
<summary>Manual fix</summary>
|
|
|
<summary>Manual edit</summary>
|
|
|
|
|
|
Change the line 23 and 37 lines like the following:
|
|
|
```
|
... | ... | @@ -216,11 +216,11 @@ Change the line 23 and 37 lines like the following: |
|
|
### Pyproj hook
|
|
|
- **FILE** `hook-pyproj.py`
|
|
|
- **PATH** `site-packages/pyinstaller/hooks/hook-pyproj.py`
|
|
|
- **FIX** collect all relevant files during freeze
|
|
|
- **EDIT** Collect all relevant files during freeze.
|
|
|
|
|
|
Quick fix: Replace `hook-pendulum.py` with `tweaks/pyinstaller/hook-pendulum.py`
|
|
|
Replace `hook-pendulum.py` with `tweaks/pyinstaller/hook-pendulum.py`
|
|
|
<details>
|
|
|
<summary>Manual fix</summary>
|
|
|
<summary>Manual edit</summary>
|
|
|
|
|
|
Replace line 12:
|
|
|
```
|
... | ... | @@ -232,17 +232,17 @@ datas = collect_data_files('pyproj', include_py_files=True) |
|
|
### Pendulum hook
|
|
|
- **FILE** `hook-pendulum.py`
|
|
|
- **PATH** `site-packages/pyinstaller/hooks/hook-pendulum.py`
|
|
|
- **FIX** new hook
|
|
|
- **EDIT** New hook.
|
|
|
Copy `hook-pendulum.py` from `tweaks/pyinstaller/` and paste into `site-packages/pyinstaller/hooks/`
|
|
|
|
|
|
## 5. pyproj
|
|
|
- **FILE**: __init__.py
|
|
|
- **PATH**: site-packages/pyproj/__init__.py
|
|
|
- **FIX**: locate "proj" data dir correctly
|
|
|
- **FILE** `__init__.py`
|
|
|
- **PATH** `site-packages/pyproj/__init__.py`
|
|
|
- **EDIT** Locate `proj/` data directory correctly.
|
|
|
|
|
|
Quick fix: Replace `__init__.py` with `tweaks/pyproj/__init__.py`
|
|
|
Replace `__init__.py` with `tweaks/pyproj/__init__.py`
|
|
|
<details>
|
|
|
<summary>Manual fix</summary>
|
|
|
<summary>Manual edit</summary>
|
|
|
|
|
|
Add the following code after line 48:
|
|
|
```
|
... | ... | @@ -260,14 +260,14 @@ If this still raises an error the `proj` directory might be missing in the resou |
|
|
|
|
|
</details>
|
|
|
|
|
|
# Freeze application
|
|
|
# F) Freeze application
|
|
|
Now run the following code to freeze the application
|
|
|
```
|
|
|
fbs freeze
|
|
|
```
|
|
|
(`fbs freeze --debug` for debug information during freezing)
|
|
|
You can run `fbs freeze --debug` for more detailed debug information during freezing.
|
|
|
|
|
|
## Windows
|
|
|
## Windows <img src="icons/windows-brands.svg" height="30">
|
|
|
<details>
|
|
|
<summary>If you get an error that `msvcr100.dll` is not found on your PATH check the following:</summary>
|
|
|
|
... | ... | @@ -285,12 +285,12 @@ setx /M path "%path%;C:\Windows\SysWOW64" |
|
|
|
|
|
</details>
|
|
|
|
|
|
# Build distributable installer
|
|
|
The following command create a platform specific installer for a stand-alone installation of the application:
|
|
|
# G) Create installer
|
|
|
The following command creates a platform specific installer for a stand-alone installation of the application which can easily be distributed:
|
|
|
```
|
|
|
fbs installer
|
|
|
```
|
|
|
## Windows
|
|
|
## Windows <img src="icons/windows-brands.svg" height="30">
|
|
|
Requires the NSIS package ([download](https://nsis.sourceforge.io/Main_Page)) and a link in the PATH variable to the NSIS directory (usually `C:\Program Files (x86)\NSIS`. To append to PATH in this terminal session run:
|
|
|
```
|
|
|
set PATH=%PATH%;C:\Program Files (x86)\NSIS
|
... | ... | |
... | ... | |