From 143797755f13b0abf469381dbca0cdd4269ff98e Mon Sep 17 00:00:00 2001 From: "Mads M. Pedersen" <mmpe@dtu.dk> Date: Thu, 31 Aug 2023 07:01:05 +0000 Subject: [PATCH] remove unused dependencies and move other to extra. install via pip install... --- .gitlab-ci.yml | 47 ++++------ docs/source/installation.rst | 26 ++--- examples/02_generate_dlc_with_definition.py | 28 ------ examples/dlc_definition.py | 10 -- pyproject.toml | 20 ++-- requirements.txt | 20 ---- setup.cfg | 94 ------------------- setup.py | 28 +++--- tests/test_examples.py | 2 +- .../examples}/01_modify_htcfile.py | 0 {examples => wetb/examples}/read-h2-hs2.py | 0 wetb/utils/timing.py | 1 - 12 files changed, 57 insertions(+), 219 deletions(-) delete mode 100644 examples/02_generate_dlc_with_definition.py delete mode 100644 examples/dlc_definition.py delete mode 100644 requirements.txt delete mode 100644 setup.cfg rename {examples => wetb/examples}/01_modify_htcfile.py (100%) rename {examples => wetb/examples}/read-h2-hs2.py (100%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c7221bb5..53b91b53 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -13,10 +13,12 @@ test: test # except: # - test_pypi + variables: + GIT_SUBMODULE_STRATEGY: recursive before_script: - - git submodule sync --recursive - - git submodule update --init --recursive - - python -m pip install . + #- git submodule sync --recursive + #- git submodule update --init --recursive + - python -m pip install .[all] - pip3 install pytest mock click script: - python3 -m pytest --cov-report term-missing:skip-covered --cov-report xml:coverage.xml --cov=wetb @@ -81,37 +83,24 @@ upload_package_local: # ===== BUILD WHEELS AND UPLOAD TO PYPI ===== -pypi_linux: - stage: - deploy - only: - - tags - - test_pypi - script: - - apt-get update - - pip install -e . --upgrade - - python3 -m pip install -U setuptools wheel - - python3 setup.py sdist bdist_wheel - - python3 -m pip install -U twine - - python3 -c 'from git_utils import rename_dist_file; rename_dist_file()' - - twine upload dist/* -u $TWINE_USERNAME -p $TWINE_PASSWORD - #- twine upload --repository-url https://test.pypi.org/legacy/ dist/* -u $TWINE_USERNAME -p $TWINE_PASSWORD # for testing purposes +upload_package_pypi: + image: continuumio/anaconda3:latest tags: - - python - + - docker, linux, shared + stage: deploy + needs: + - job: build_poetry_wheel + artifacts: true + - job: test + artifacts: false -pypi_windows: - stage: - deploy + script: + - pip install twine + - twine upload dist/* -u $TWINE_USERNAME -p $TWINE_PASSWORD only: - tags - test_pypi - script: - - c:/Anaconda3/envs/WindEnergyToolbox/python.exe setup.py bdist_wheel - - twine upload dist/* -u %TWINE_USERNAME% -p %TWINE_PASSWORD% - #- twine upload --repository-url https://test.pypi.org/legacy/ dist/* -u %TWINE_USERNAME% -p %TWINE_PASSWORD% # for testing purposes - tags: - - CPAV_old + build_poetry_wheel: stage: build diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 8a3939d5..57fac54d 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -4,21 +4,9 @@ Installation =========================== -Install C++ compilers (Windows) --------------------------------- - -Your computer must have a C++ compiler installed in order to install -``wetb``. Windows users can follow the instructions on -`this page <https://wiki.python.org/moin/WindowsCompilers>`_ under -the section "14.2 standalone". - - Normal user -------------------------------- -You must first have installed a C++ compiler before you can use these -commands. See section above. - * Quick install:: pip install wetb @@ -30,6 +18,14 @@ commands. See section above. * Update an installation to the most recent version:: pip install --upgrade wetb + +* Install with dependencies needed by prepost + + pip install wetb[prepost] + +* Install with all dependencies + + pip install wetb[all] **NOTE**. Dependency conflicts can arise if you do not install ``wetb`` into a clean environment. In particular, your installation @@ -47,5 +43,9 @@ Clone the repository and install a local editable copy:: git clone https://gitlab.windenergy.dtu.dk/toolbox/WindEnergyToolbox.git cd WindEnergyToolbox - pip install -e . + pip install -e .[all] + + + + diff --git a/examples/02_generate_dlc_with_definition.py b/examples/02_generate_dlc_with_definition.py deleted file mode 100644 index c6d398ea..00000000 --- a/examples/02_generate_dlc_with_definition.py +++ /dev/null @@ -1,28 +0,0 @@ -from wetb.hawc2.hawc2_input_writer import HAWC2InputWriter -from wetb.hawc2.tests import test_files -import os - - -def main(): - if __name__ == '__main__': - - # ====================================================================== - # load master htc file path - # ====================================================================== - path = os.path.dirname(test_files.__file__) + "/simulation_setup/DTU10MWRef6.0/" - htc_base_file = path + 'htc/DTU_10MW_RWT.htc' - - h2writer = HAWC2InputWriter(htc_base_file) - - # ====================================================================== - # Set DLC definition module filename - # ====================================================================== - definition_file = 'dlc_definition.py' - - #======================================================================= - # Generate htc files from definition file, and print list of simulations - #======================================================================= - df = h2writer.from_definition(definition_file) - print(df) - -main() \ No newline at end of file diff --git a/examples/dlc_definition.py b/examples/dlc_definition.py deleted file mode 100644 index 329ba87a..00000000 --- a/examples/dlc_definition.py +++ /dev/null @@ -1,10 +0,0 @@ - -constants = {'simulation.time_stop':100} - -variables = {'wind.wsp': [4, 6, 8], - 'wind.tint': [0.1, 0.15, 0.2]} - -functions = {'Name': lambda x: 'sim_wsp' + str(x['wind.wsp']) + '_ti' + str(x['wind.tint'])} - - - diff --git a/pyproject.toml b/pyproject.toml index 3820f3a9..95e01699 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,30 +8,32 @@ readme = "README.md" [tool.poetry.dependencies] click = "^8.0.4" -Cython = "^0.29.35" +Cython = {version="^0.29.35", optional=true} h5py = "^3.1.0" Jinja2 = "^3.0.3" lxml = "^4.9.2" matplotlib = "^3.3.4" mock = "^5.0.2" numpy = ">=1.4" -openpyxl = "^3.1.2" +openpyxl = { version = "^3.1.2", optional = true } pandas = "^1.1.5" -paramiko = "^3.2.0" -pbr = "^5.11.1" +paramiko = {version="^3.2.0", optional = true} psutil = "^5.9.5" pytest = "^7.0.1" pytest-cov = "^4.0.0" python = "^3.6" scipy = ">=0.9.0" -six = "^1.16.0" -sshtunnel = "^0.4.0" -tables = "^3.7.0" +sshtunnel = {version="^0.4.0", optional = true} +tables = {version="^3.7.0", optional=true} tqdm = "^4.64.1" -wafo = "^0.1.2" -xlwt = "^1.3.0" +wafo = {version="^0.1.2", optional=true} +xlwt = {version="^1.3.0", optional=true} XlsxWriter = "^3.1.2" +[tool.poetry.extras] +prepost = ["openpyxl", "tables", "wafo", "xlwt", "Cython"] +all = ["openpyxl", "tables", "wafo", "xlwt", "Cython", "paramiko", "sshtunnel"] + [build-system] requires = ["poetry-core"] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 7795909e..00000000 --- a/requirements.txt +++ /dev/null @@ -1,20 +0,0 @@ -# Add your requirements here like: -six -cython -numpy>=1.4 -scipy>=0.9 -matplotlib -pytest -xlwt -openpyxl -h5py -pandas -tables -paramiko -psutil -pbr -pytest-cov -sshtunnel -xlsxwriter -mock - diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index cfc3aa88..00000000 --- a/setup.cfg +++ /dev/null @@ -1,94 +0,0 @@ -[metadata] -name = wetb -summary = Wind Energy Toolbox -author = DTU Wind Energy -author-email = mmpe@dtu.dk -license = GPLv3 -home-page = https://gitlab.windenergy.dtu.dk/toolbox/WindEnergyToolbox -description-file = README -# Add here all kinds of additional classifiers as defined under -# https://pypi.python.org/pypi?%3Aaction=list_classifiers -#classifiers = Development Status :: 4 - Beta, -# Programming Language :: Python, -# Programming Language :: Python :: 2.7, -# Programming Language :: Python :: 3, -# Programming Language :: Python :: 3.3, -# Programming Language :: Python :: 3.4, -# Programming Language :: Python :: 3.5, -# Programming Language :: Python :: 3.6, -# Environment :: Console, -# Intended Audience :: Education, -# Intended Audience :: Science/Research, -# License :: OSI Approved :: GPL License, -# Operating System :: OS Independent, -# Operating System :: POSIX :: Linux, -# Operating System :: Unix, -# Operating System :: MacOS, -# Operating System :: Microsoft :: Windows -# Topic :: Scientific/Engineering :: Mathematics -# -[entry_points] -# Add here console scripts like: -# console_scripts = -# hello_world = wetb.module:function -# as well as other entry_points. - - -[files] -# Add here 'data_files', 'packages' or 'namespace_packages'. -# Additional data files are defined as key value pairs of source and target: -packages = - wetb -# data_files = -# share/wetb_docs = docs/* - -[extras] -# Add here additional requirements for extra features, like: -# PDF = -# ReportLab>=1.2 -# RXP -#ALL = -# django -# cookiecutter - -[test] -# py.test options when running `python setup.py test` -#addopts = tests - -[tool:pytest] -# Options for py.test: -# Specify command line options as you would do when invoking py.test directly. -# e.g. --cov-report html (or xml) for html/xml output or --junitxml junit.xml -# in order to write a coverage file that can be read by Jenkins. -#addopts = -# --cov wetb --cov-report term-missing -# --verbose -python_files = WindEnergyToolbox/wetb/* - -[aliases] -docs = build_sphinx - -[bdist_wheel] -# Use this option if your package is pure-python -universal = 0 - -[build_sphinx] -# Options for Sphinx build -source_dir = docs -build_dir = docs/_build - -[pbr] -# Let pbr run sphinx-apidoc -autodoc_tree_index_modules = True -# autodoc_tree_excludes = ... -# Let pbr itself generate the apidoc -# autodoc_index_modules = True -# autodoc_exclude_modules = ... -# Convert warnings to errors -# warnerrors = True - -[devpi:upload] -# Options for the devpi: PyPI serer and packaging tool -# VCS export must be deactivated since we are using setuptools-scm -no-vcs = 1 -formats = bdist_wheel diff --git a/setup.py b/setup.py index 4578360a..f6c3b1cf 100644 --- a/setup.py +++ b/setup.py @@ -4,6 +4,7 @@ Setup file for wetb. """ +from distutils.extension import Extension import os from git_utils import write_vers import sys @@ -28,9 +29,6 @@ with open("README.md", "r") as fh: long_description = fh.read() -from distutils.extension import Extension - - def setup_package(build_ext_switch=True): # if build_ext_switch: # import numpy as np @@ -51,28 +49,30 @@ def setup_package(build_ext_switch=True): sphinx = ['sphinx'] if needs_sphinx else [] install_requires = ['mock', 'h5py', - #'tables', # Has blosc2 as requirement, fails unless C compiler is present on win32 + # 'tables', # Has blosc2 as requirement, fails unless C compiler is present on win32 'pytest', 'pytest-cov', # 'blosc', # gives an error - has to be pre-installed 'pbr', - 'paramiko', 'scipy', 'pandas', 'matplotlib', 'coverage', - 'xlwt', - 'openpyxl', 'psutil', - 'six', - 'sshtunnel', 'Click', 'jinja2', ] - extras_require={ - 'prepost': [ - 'tables', # requires blosc2 and may not install on 32 bit systems without a C compiler - 'cython', - ] + extras_require = { + 'prepost': [ + 'tables', # requires blosc2 and may not install on 32 bit systems without a C compiler + 'cython', + 'openpyxl', + ], + 'all': ['tables', # requires blosc2 and may not install on 32 bit systems without a C compiler + 'cython', + 'sshtunnel', + 'openpyxl', + 'paramiko', + ] } setup(install_requires=install_requires, diff --git a/tests/test_examples.py b/tests/test_examples.py index b96fc8d8..301b208e 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -6,7 +6,7 @@ import mock import pytest import matplotlib.pyplot as plt import sys -from examples import examples +from wetb import examples from tests.run_main import run_module_main diff --git a/examples/01_modify_htcfile.py b/wetb/examples/01_modify_htcfile.py similarity index 100% rename from examples/01_modify_htcfile.py rename to wetb/examples/01_modify_htcfile.py diff --git a/examples/read-h2-hs2.py b/wetb/examples/read-h2-hs2.py similarity index 100% rename from examples/read-h2-hs2.py rename to wetb/examples/read-h2-hs2.py diff --git a/wetb/utils/timing.py b/wetb/utils/timing.py index ab67d8b1..363d2185 100644 --- a/wetb/utils/timing.py +++ b/wetb/utils/timing.py @@ -1,4 +1,3 @@ -from six import exec_ import time import inspect def get_time(f): -- GitLab