From 287e6cd816eafe6bdb9543d7cd7684c50f3727d9 Mon Sep 17 00:00:00 2001 From: giovaniceotto Date: Sat, 31 Dec 2022 17:48:21 -0300 Subject: [PATCH 1/3] ENH: make timezonefinder optional --- docs/user/requirements.rst | 24 +++++++++++++++++++----- rocketpy/EnvironmentAnalysis.py | 11 ++++++++++- setup.py | 6 ++++-- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/docs/user/requirements.rst b/docs/user/requirements.rst index 63b419607..c24b73193 100644 --- a/docs/user/requirements.rst +++ b/docs/user/requirements.rst @@ -7,9 +7,10 @@ But read further if this is not your case! Python Version -------------- -RocketPy was made to run on Python 3.6+. +RocketPy supports Python 3.7 and above. +Support for Python 3.11 is still limited by some dependencies. Sorry, there are currently no plans to support earlier versions. -If you really need to run RocketPy on Python 3.5 or earlier, feel free to submit an issue and we will see what we can do! +If you really need to run RocketPy on Python 3.6 or earlier, feel free to submit an issue and we will see what we can do! Required Packages ----------------- @@ -20,17 +21,16 @@ The following packages are needed in order to run RocketPy: - Numpy >= 1.0 - Scipy >= 1.0 - Matplotlib >= 3.0 -- netCDF4 >= 1.4 (optional, requires Cython) +- netCDF4 >= 1.4 - windrose >= 1.6.8 - requests - pytz -- timezonefinder - simplekml - ipywidgets >= 7.6.3 - jsonpickle -All of these packages, with the exception of netCDF4, should be automatically installed when RocketPy is installed using either ``pip`` or ``conda``. +All of these packages, are automatically installed when RocketPy is installed using either ``pip`` or ``conda``. However, in case the user wants to install these packages manually, they can do so by following the instructions bellow. Installing Required Packages Using ``pip`` @@ -64,6 +64,20 @@ To update Scipy and install netCDF4 using Conda, the following code is used: conda install "scipy>=1.0" conda install -c anaconda "netcdf4>=1.4" + +Optional Packages +----------------- + +Optionally, you can install timezonefinder to allow for automatic timezone detection when performing Enviornment Analysis. +This can be done by running the following line of code in your preferred terminal: + +.. code-block:: shell + + pip install timezonefinder + +Keep in mind that this package is not required to run RocketPy, but it can be useful if you want to perform Environment Analysis. +Furthermore, timezonefinder can only be used with Python 3.8+. + Useful Packages --------------- diff --git a/rocketpy/EnvironmentAnalysis.py b/rocketpy/EnvironmentAnalysis.py index 8eeacbc0f..4f2099f40 100644 --- a/rocketpy/EnvironmentAnalysis.py +++ b/rocketpy/EnvironmentAnalysis.py @@ -22,7 +22,6 @@ from matplotlib.animation import FuncAnimation from matplotlib.animation import PillowWriter as ImageWriter from scipy import stats -from timezonefinder import TimezoneFinder from windrose import WindroseAxes from rocketpy.Environment import Environment @@ -421,6 +420,16 @@ def __localize_input_dates(self): def __find_preferred_timezone(self): if self.preferred_timezone is None: + try: + import timezonefinder as TimezoneFinder + except ImportError: + raise ImportError( + "The timezonefinder package is required to automatically " + + "determine local timezone based on lat,lon coordinates. " + + "Please specify the desired timezone using the `timezone` " + + "argument when initializing the EnvironmentAnalysis class " + + "or install timezonefinder with `pip install timezonefinder`." + ) # Use local timezone based on lat lon pair tf = TimezoneFinder() self.preferred_timezone = pytz.timezone( diff --git a/setup.py b/setup.py index b94d4e669..326692187 100644 --- a/setup.py +++ b/setup.py @@ -15,10 +15,12 @@ "ipywidgets>=7.6.3", "requests", "pytz", - "timezonefinder", "simplekml", "jsonpickle", ], + extras_require={ + "timezonefinder": ["timezonefinder"], + }, maintainer="RocketPy Developers", author="Giovani Hidalgo Ceotto", author_email="ghceotto@gmail.com", @@ -32,5 +34,5 @@ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ], - python_requires=">=3.6", + python_requires=">=3.7", ) From 6ff9642d2eea3bfd5f764654756a9db4c4a269a3 Mon Sep 17 00:00:00 2001 From: giovaniceotto Date: Sat, 31 Dec 2022 17:59:51 -0300 Subject: [PATCH 2/3] STY: Apply black formatting --- rocketpy/EnvironmentAnalysis.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rocketpy/EnvironmentAnalysis.py b/rocketpy/EnvironmentAnalysis.py index 4f2099f40..e318e043c 100644 --- a/rocketpy/EnvironmentAnalysis.py +++ b/rocketpy/EnvironmentAnalysis.py @@ -424,11 +424,11 @@ def __find_preferred_timezone(self): import timezonefinder as TimezoneFinder except ImportError: raise ImportError( - "The timezonefinder package is required to automatically " + - "determine local timezone based on lat,lon coordinates. " + - "Please specify the desired timezone using the `timezone` " + - "argument when initializing the EnvironmentAnalysis class " + - "or install timezonefinder with `pip install timezonefinder`." + "The timezonefinder package is required to automatically " + + "determine local timezone based on lat,lon coordinates. " + + "Please specify the desired timezone using the `timezone` " + + "argument when initializing the EnvironmentAnalysis class " + + "or install timezonefinder with `pip install timezonefinder`." ) # Use local timezone based on lat lon pair tf = TimezoneFinder() From 203d0f07577b208338bd3ad61260fbcfb52d3f92 Mon Sep 17 00:00:00 2001 From: Giovani Hidalgo Ceotto Date: Tue, 10 Jan 2023 13:49:59 -0300 Subject: [PATCH 3/3] TST: change GitHub actions from setup.py to pip --- .github/workflows/test_pytest.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test_pytest.yaml b/.github/workflows/test_pytest.yaml index b775a3dd3..d8bd00f70 100644 --- a/.github/workflows/test_pytest.yaml +++ b/.github/workflows/test_pytest.yaml @@ -22,11 +22,10 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements.txt pip install -r requirements_test.txt - name: Build RocketPy run: | - python setup.py install + pip install -e . - name: Test with pytest run: | pytest