Skip to content

Commit

Permalink
Rewrite GUI branch with reorganize_package branch
Browse files Browse the repository at this point in the history
The original package folder organization has been restored.
  • Loading branch information
lorisercole committed Nov 15, 2019
1 parent b289fc3 commit e806de9
Show file tree
Hide file tree
Showing 69 changed files with 91 additions and 198 deletions.
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ Here are a few guidelines to consider when contributing.
- When you are done with a branch and want to **merge** it to `develop`, submit a *Pull request*. Unless it is a simple fix, and especially if it is a new functionality, this will help to keep the code clean and find potential bugs beforehand. Also, it will help to standardize the style.
- Before updating the `develop` branch, make **tests**!
- Try to make **commits** as specific as possible, and document the changes.
- note that some files are copied inside the source tree by the script copy_readmes_in_packages.sh (it is not possible to use symbolic links to build the python package)
- this repository has two python packages inside it: **thermocepstrum**, the full library and the command line interface, that is compatible with python 2.7 and 3.x, and **thermocepstrum_gui**, that contains the GUI only, it depends on **thermocepstrum** and it is NOT python 2.7 compatible.
- This repository contains two python packages:
- **thermocepstrum**, the full library and the command line interface, that is compatible with Python 2.7 and 3.x.
- **thermocepstrum_gui**, that contains the GUI only, it depends on **thermocepstrum** and it is *NOT* Python 2.7 compatible.


## WISH LIST
Expand Down
11 changes: 5 additions & 6 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
recursive-include examples *
include thermocepstrum/utils/plot_style.mplstyle
include thermocepstrum/setup.json
include thermocepstrum_gui/assets/icon.gif
include thermocepstrum_gui/assets/languages.json
include LICENSE.txt
include thermocepstrum/README.md
include thermocepstrum/README_GUI.md
include thermocepstrum/metadata.json
include thermocepstrum/utils/plot_style.mplstyle
exclude thermocepstrum/utils/blocks.py
exclude thermocepstrum/utils/blockanalysis.py
prune thermocepstrum/old_src
include thermocepstrum_gui/README_GUI.md
include thermocepstrum_gui/assets/icon.gif
include thermocepstrum_gui/assets/languages.json
36 changes: 15 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,32 @@ See the [`examples/example_commandline_NaCl`](examples/example_commandline_NaCl/
### Requirements
#### only cepstral analysis (command line interface)
- Python 2.7 or 3.x
- Numpy
- Scipy
- Matplotlib
- numpy
- ncipy
- matplotlib
#### graphical user interface
- all the requirements of cepstral analysis
- python 3 only
- Python 3 only
- tkinter
- future-fstrings
- pillow (you may need to run `pip install pillow --upgrade` )
- pillow (you may need upgrade it)
- tk-html-widgets
- markdown2

### Installation
We provide two python packages. The core library and the command line interface are in the subdirectory `thermocepstrum`, while the GUI is in the `thermocepstrum_gui` subdirectory. Remember that the GUI requires python 3, while the library and the command line interface don't. That's why we have two packages.
You can simply pip-install thermocepstrum with `pip install thermocepstrum` from the pypi repository.

You can simply pip-install thermocepstrum downloading it from PyPI with `pip install thermocepstrum`.

Alternatively:

1. Clone this repository: `git clone https://github.com/lorisercole/thermocepstrum.git`
2. cd into the new directory created by git
* system where `setup.sh` does work:
1. run the bash script `setup.sh` and you are done (skip next steps).
* system where `setup.sh` does not work:
1. copy the files `README.md README_GUI.md LICENSE.txt` in the source folders `thermocepstrum/thermocepstrum` and `thermocepstrum_gui/thermocepstrum_gui/`
2. `cd thermocepstrum; pip install .`
3. `cd thermocepstrum_gui; pip install`

The copy is needed because during python packaging it is not possible to include files from parent directories, and we want to have only a single version of the READMEs in the project tree.
2. Install the package with pip (dependencies will be automatically downloaded). For example:
```
cd thermocepstrum
pip install .
```
You are done! You can check that the installation is working by trying to run the command `thermocepstrum-analysis`.

You are done! You can check that the installation is working by trying to run the command `thermocepstrum-analysis`.
The graphical user interface is started with the command `thermocepstrum-gui` (only if you installed it).
If you use Python 3, the Graphical User Interface will be installed and can be started with the command `thermocepstrum-gui`.

### Issues
You are strongly encouraged to report any issue on the [official](https://github.com/lorisercole/thermocepstrum/issues) GitHub issues page.

You are strongly encouraged to report any issue on the [official](https://github.com/lorisercole/thermocepstrum/issues) GitHub issues page.
3 changes: 0 additions & 3 deletions copy_readmes_in_packages.sh

This file was deleted.

2 changes: 1 addition & 1 deletion examples/example_cepstrum_doublecomp_NaCl.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
" import thermocepstrum as tc\n",
"except ImportError:\n",
" from sys import path\n",
" path.append('../thermocepstrum')\n",
" path.append('..')\n",
" import thermocepstrum as tc\n",
"\n",
"c = plt.rcParams['axes.prop_cycle'].by_key()['color']"
Expand Down
2 changes: 1 addition & 1 deletion examples/example_cepstrum_singlecomp_silica.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
" import thermocepstrum as tc\n",
"except ImportError:\n",
" from sys import path\n",
" path.append('../thermocepstrum')\n",
" path.append('..')\n",
" import thermocepstrum as tc\n",
"\n",
"c = plt.rcParams['axes.prop_cycle'].by_key()['color']"
Expand Down
2 changes: 1 addition & 1 deletion examples/example_commandline_NaCl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Symply run, after installing the package, the following command (see `command.sh
thermocepstrum-analysis ../data/NaCl.dat -k flux -j 'vcm[1]' -t 5.0 -V 65013.301261 -w 0.1 --FSTAR 14.0 -r
```
If the package is not installed you can run this instead:
`../../thermocepstrum/thermocepstrum/analysis.py ../data/NaCl.dat -k flux -j 'vcm[1]' -t 5.0 -V 65013.301261 -w 0.1 --FSTAR 14.0 -r`
`../../thermocepstrum/analysis.py ../data/NaCl.dat -k flux -j 'vcm[1]' -t 5.0 -V 65013.301261 -w 0.1 --FSTAR 14.0 -r`

The options have the following meaning:
* `-k flux` use the columns with header `flux` as the energy flux
Expand Down
2 changes: 1 addition & 1 deletion examples/example_commandline_NaCl/command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
thermocepstrum-analysis ../data/NaCl.dat -k flux -j 'vcm[1]' -t 5.0 -V 65013.301261 -w 0.1 --FSTAR 14.0 -r

# if thermocepstrum is not pip installed use:
#../../thermocepstrum/thermocepstrum/analysis.py ../data/NaCl.dat -k flux -j 'vcm[1]' -t 5.0 -V 65013.301261 -w 0.1 --FSTAR 14.0 -r
#../../thermocepstrum/analysis.py ../data/NaCl.dat -k flux -j 'vcm[1]' -t 5.0 -V 65013.301261 -w 0.1 --FSTAR 14.0 -r
4 changes: 2 additions & 2 deletions thermocepstrum/thermocepstrum/setup.json → setup.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
},
"entry_points": {
"console_scripts": [
"thermocepstrum-analysis = thermocepstrum.analysis:main"
"thermocepstrum-analysis=thermocepstrum.analysis:main"
]
},
"gui_version" : "0.0.2a",
"dev_state" : "alpha",
"release_date" : "NOT REL.",
"credits" : "developed at SISSA, Via Bonomea, 265 - 34136 Trieste ITALY"

}
50 changes: 50 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-

from __future__ import absolute_import
from setuptools import setup, find_packages
from os import path
import sys
import json

GUI_dependencies = [
"future-fstrings",
"markdown2",
"pillow>=5.4.0",
"tk-html-widgets",
"uncertainties"
]

if sys.version_info[0] == 2:
INSTALL_GUI = False
sys.stderr.write("************* GUI does not support Python 2: it will not be installed. That's a pity! *************")
elif sys.version_info[0] == 3:
INSTALL_GUI = True


if __name__ == '__main__':
THIS_FOLDER = path.split(path.abspath(__file__))[0]

with open(path.join(THIS_FOLDER, 'README.md'), 'r') as fh:
long_description = fh.read()

with open(path.join(THIS_FOLDER, 'setup.json'), 'r') as info:
SETUP_JSON = json.load(info)

if INSTALL_GUI:
exclude_packages = []
SETUP_JSON['install_requires'] += GUI_dependencies
SETUP_JSON['entry_points']['console_scripts'] += ["thermocepstrum-gui = thermocepstrum_gui.main:run"]
with open(path.join(THIS_FOLDER, 'thermocepstrum/metadata.json'), 'w') as fh:
json.dump(SETUP_JSON, fh)
else:
exclude_packages = ['thermocepstrum_gui*']

setup(include_package_data=True,
packages=find_packages(exclude=exclude_packages),
long_description=long_description,
long_description_content_type='text/markdown',
# setup_requires=['reentry'],
**SETUP_JSON)

# https://packaging.python.org/guides/distributing-packages-using-setuptools/#setup-args
# https://setuptools.readthedocs.io/en/latest/setuptools.html#including-data-files
8 changes: 0 additions & 8 deletions setup.sh

This file was deleted.

File renamed without changes.
1 change: 1 addition & 0 deletions tests/data
File renamed without changes.
6 changes: 0 additions & 6 deletions thermocepstrum/MANIFEST.in

This file was deleted.

1 change: 1 addition & 0 deletions thermocepstrum/README.md
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 0 additions & 24 deletions thermocepstrum/setup.py

This file was deleted.

1 change: 0 additions & 1 deletion thermocepstrum/tests/data

This file was deleted.

11 changes: 0 additions & 11 deletions thermocepstrum/thermocepstrum/MANIFEST.in

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 0 additions & 6 deletions thermocepstrum_gui/MANIFEST.in

This file was deleted.

1 change: 1 addition & 0 deletions thermocepstrum_gui/README_GUI.md
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@
from pkg_resources import resource_stream, resource_string
import json

with resource_stream('thermocepstrum_gui', 'setup.json') as JS:
with resource_stream('thermocepstrum', 'metadata.json') as JS:
METADATA = json.load(JS)

with resource_stream('thermocepstrum', 'setup.json') as JS:
METADATAtc = json.load(JS)

with resource_stream(__name__, 'languages.json') as JS:
LANGUAGES = json.load(JS)

ICON = resource_string(__name__, 'icon.gif')

README_MD = resource_string('thermocepstrum_gui', 'README.md')
README_MD = resource_string('thermocepstrum', 'README.md')
README_GUI_MD = resource_string('thermocepstrum_gui', 'README_GUI.md')
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from thermocepstrum_gui.interfaces import *
from thermocepstrum_gui.utils.custom_widgets import *
from thermocepstrum_gui.assets import ICON, METADATA, METADATAtc, LANGUAGES
from thermocepstrum_gui.assets import ICON, METADATA, LANGUAGES
# Verify that thermocepstrum is installed
try:
import thermocepstrum
Expand Down Expand Up @@ -120,11 +120,11 @@ def show_software_info(self):
"""
print('------------------- Thermocepstrum GUI -------------------')
print('')
print('\t\t\tGUI version: {}'.format(METADATA['version']))
print('\t\t\tThermocepstrum version: {}'.format(METADATAtc['version']))
print('\t\t\tGUI version: {}'.format(METADATA['gui_version']))
print('\t\t\tThermocepstrum version: {}'.format(METADATA['version']))
print('\t\t\tDev state: {}'.format(METADATA['dev_state']))
print('\t\t\tLast release: {}'.format(METADATA['release_date']))
print('\t\t\tDevelopers: {}'.format(METADATAtc['author']))
print('\t\t\tDevelopers: {}'.format(METADATA['author']))
print('\t\t\tURL: {}'.format(METADATA['url']))
print('')
print('This software is an open-source project licensed under {}'.format(METADATA['license']))
Expand Down
24 changes: 0 additions & 24 deletions thermocepstrum_gui/setup.py

This file was deleted.

File renamed without changes.
11 changes: 0 additions & 11 deletions thermocepstrum_gui/thermocepstrum_gui/MANIFEST.in

This file was deleted.

57 changes: 0 additions & 57 deletions thermocepstrum_gui/thermocepstrum_gui/setup.json

This file was deleted.

File renamed without changes.
File renamed without changes.
Loading

0 comments on commit e806de9

Please sign in to comment.