Skip to content

Commit c46fbd3

Browse files
Update installation, fix some warning move to src layout (#93)
- I have transitioned from setup.py to pyproject.toml . #89 - Changed the layout from flat to source. [See here for advantages](https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/) - Updated the installation description in the README.md - Fixed a couple of deprecation and future warnings, reported in #91 --------- Co-authored-by: Julian Belina <j.belina@fz-juelich.de>
1 parent fc0a9d4 commit c46fbd3

25 files changed

+171
-133
lines changed

.github/workflows/daily_tests.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,7 @@ jobs:
3434
- name: Install dependencies
3535
run: |
3636
python -m pip install --upgrade pip
37-
pip install pytest
38-
pip install pytest-cov
39-
pip install codecov
40-
pip install -r requirements.txt
41-
pip install --no-cache-dir -e .
37+
pip install --no-cache-dir -e .[dev]
4238
4339
- name: Test with pytest
4440
working-directory: ./test/

.github/workflows/test_on_push_and_pull.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@ jobs:
2929
- name: Install dependencies
3030
run: |
3131
python -m pip install --upgrade pip
32-
pip install pytest
33-
pip install pytest-cov
34-
pip install codecov
35-
pip install -r requirements.txt
36-
pip install --no-cache-dir -e .
32+
pip install --no-cache-dir -e .[dev]
3733
3834
- name: Test with pytest
3935
working-directory: ./test/
@@ -58,11 +54,7 @@ jobs:
5854
- name: Install dependencies
5955
run: |
6056
python -m pip install numpy==${{matrix.python-numpy-version.numpy}} --upgrade pip
61-
pip install pytest
62-
pip install pytest-cov
63-
pip install codecov
64-
pip install -r requirements.txt
65-
pip install --no-cache-dir -e .
57+
pip install --no-cache-dir -e .[dev]
6658
6759
- name: Test with pytest
6860
working-directory: ./test/

.readthedocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ build:
1111

1212
python:
1313
install:
14+
- requirements: requirements.txt
1415
- requirements: requirements_dev.txt
1516
system_packages: false

README.md

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,50 @@ The documentation of the tsam code can be found [**here**](https://tsam.readthed
1919

2020

2121
## Installation
22+
It is recommended to install tsam within its own environment. If you are no familiar with python environments, plaese consider to read some [external documentation](https://realpython.com/python-virtual-environments-a-primer/). In the following we assume you have a [mamba](https://mamba.readthedocs.io/en/latest/installation/mamba-installation.html) or [conda](https://www.anaconda.com/) installation. All conda and mamba command are interchangeable.
23+
24+
### Direct Installations from Package Manager Repositories
25+
26+
If you want to prevent any possible dependency conflicts create a new environment using the following command:
27+
28+
mamba create -n tsam_env python pip
29+
30+
Activate an existing or the newly create environment afterward
31+
32+
mamba activate tsam_env
33+
2234
Directly install via pip from pypi as follows:
2335

2436
pip install tsam
2537

26-
of install from conda forge with the following command:
38+
or install from conda forge with the following command:
2739

2840
conda install tsam -c conda-forge
2941

42+
### Local Installation for Development
3043
Alternatively, clone a local copy of the repository to your computer
3144

3245
git clone https://github.com/FZJ-IEK3-VSA/tsam.git
33-
34-
Then install tsam via pip as follow
35-
46+
47+
Change the directory of your shell into the root folder of the repository
48+
3649
cd tsam
37-
pip install .
38-
39-
Or install directly via python as
4050

41-
python setup.py install
51+
For development, it is recommended to install tsam into its own environment using conda e.g.
52+
53+
conda env create --file=requirement.yml
54+
55+
Afterward activate the environment
56+
57+
conda activate tsam_env
58+
59+
Then install tsam via pip as follows
60+
61+
62+
pip install -e .[dev]
4263

43-
In order to use the k-medoids clustering, make sure that you have installed a MILP solver. As default [HiGHS](https://github.com/ERGO-Code/HiGHS) is used. Nevertheless, in case you have access to a license we recommend commercial solvers (e.g. Gurobi or CPLEX) since they have a better performance.
64+
### Installation of MILP Solver for k-medoids
65+
In order to use the k-medoids clustering, make sure that you have installed a MILP solver. As default [HiGHS](https://github.com/ERGO-Code/HiGHS) is installed and used. Nevertheless, in case you have access to a license we recommend commercial solvers (e.g. Gurobi or CPLEX) since they have a better performance.
4466

4567
### Developer installation
4668

pyproject.toml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
[build-system]
2+
requires = ["setuptools>=64.0.0", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
6+
[project]
7+
name = "tsam"
8+
version = "2.3.6"
9+
description = "Time series aggregation module (tsam) to create typical periods"
10+
authors = [
11+
{ name = "Leander Kotzur", email = "leander.kotzur@googlemail.com" },
12+
{ name = "Maximilian Hoffmann", email = "maximilian.hoffmann@julumni.fz-juelich.de" },
13+
]
14+
maintainers = [
15+
{name = "Julian Belina", email = "j.belina@fz-juelich.de"}
16+
]
17+
license = { file = "LICENSE.txt" }
18+
keywords = ["clustering", "optimization"]
19+
requires-python = ">=3.9,<3.13"
20+
readme = "README.md"
21+
classifiers=[
22+
"Development Status :: 4 - Beta",
23+
"Intended Audience :: End Users/Desktop",
24+
"Intended Audience :: Science/Research",
25+
"License :: OSI Approved :: MIT License",
26+
"Natural Language :: English",
27+
"Operating System :: OS Independent",
28+
"Programming Language :: Python",
29+
"Programming Language :: Python :: 2",
30+
"Programming Language :: Python :: 3",
31+
"Topic :: Scientific/Engineering :: Mathematics",
32+
"Topic :: Software Development :: Libraries :: Python Modules",
33+
]
34+
dynamic = ["dependencies", "optional-dependencies"]
35+
36+
37+
[tool.setuptools.packages.find]
38+
where = ["src"]
39+
40+
[tool.setuptools.dynamic]
41+
dependencies = {file = ["requirements.txt"]}
42+
optional-dependencies = {dev = { file = ["requirements_dev.txt"] }}
43+
44+
45+
#Configureation options
46+
# https://docs.pytest.org/en/7.1.x/reference/reference.html#configuration-options
47+
48+
[tool.pytest.ini_options]
49+
testpaths = ["test"] # Sets the path where to look for tests
50+
pythonpath =["test"] # Sets the path which should be prepended to pythonpath relative to the root folder
51+
console_output_style = "count"
52+
53+

requirements.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
name: tsam
1+
name: tsam_env
22
channels:
33
- conda-forge
44
dependencies:
55
- python>=3.9,<3.13
66
- pip
7-
- pip:
8-
- -r requirements.txt

requirements_dev.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
-r requirements.txt
2-
31
# Testing
42
pytest
53
pytest-cov
4+
codecov
65

76
# Documentation
87
sphinx

requirements_dev.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 37 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)