Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1838467 - python-astral fails to build with Python 3.9: ValueError: Sun never reaches 6.0 degrees below the horizon, at this location
Summary: python-astral fails to build with Python 3.9: ValueError: Sun never reaches 6...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: python-astral
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Fabian Affolter
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: F33FTBFS PYTHON39
TreeView+ depends on / blocked
 
Reported: 2020-05-21 08:31 UTC by Miro Hrončok
Modified: 2020-06-11 11:48 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-06-11 11:48:18 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Miro Hrončok 2020-05-21 08:31:41 UTC
python-astral fails to build with Python 3.9.0b1.

=================================== FAILURES ===================================
______________________________ test_AllLocations _______________________________

observer = Observer(latitude=64.16666666666667, longitude=-51.583333333333336, elevation=0.0)
date = datetime.date(2020, 5, 21), depression = <Depression.CIVIL: 6.0>
tzinfo = <UTC>

    def dawn(
        observer: Observer,
        date: Optional[datetime.date] = None,
        depression: Union[float, Depression] = Depression.CIVIL,
        tzinfo: datetime.tzinfo = pytz.utc,
    ) -> datetime.datetime:
        """Calculate dawn time.
    
        Args:
            observer:   Observer to calculate dawn for
            date:       Date to calculate for. Default is today's date in the timezone `tzinfo`.
            depression: Number of degrees below the horizon to use to calculate dawn.
                        Default is for Civil dawn i.e. 6.0
            tzinfo:     Timezone to return times in. Default is UTC.
    
        Returns:
            Date and time at which dawn occurs.
    
        Raises:
            ValueError: if dawn does not occur on the specified date
        """
        if date is None:
            date = today(tzinfo)
    
        dep: float = 0.0
        if isinstance(depression, Depression):
            dep = depression.value
        else:
            dep = depression
    
        try:
>           return time_of_transit(
                observer, date, 90.0 + dep, SunDirection.RISING
            ).astimezone(tzinfo)

../../BUILDROOT/python-astral-2.1-1.fc33.x86_64/usr/lib/python3.9/site-packages/astral/sun.py:734: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

observer = Observer(latitude=64.16666666666667, longitude=-51.583333333333336, elevation=0.0)
date = datetime.date(2020, 5, 21), zenith = 96.0
direction = <SunDirection.RISING: 1>

    def time_of_transit(
        observer: Observer, date: datetime.date, zenith: float, direction: SunDirection
    ) -> datetime.datetime:
        """Calculate the time in the UTC timezone when the sun transits the specificed zenith
    
        Args:
            observer: An observer viewing the sun at a specific, latitude, longitude and elevation
            date: The date to calculate for
            zenith: The zenith angle for which to calculate the transit time
            direction: The direction that the sun is traversing
    
        Returns:
            the time when the sun transits the specificed zenith
        """
        if observer.latitude > 89.8:
            latitude = 89.8
        elif observer.latitude < -89.8:
            latitude = -89.8
        else:
            latitude = observer.latitude
    
        adjustment_for_elevation = 0.0
        if isinstance(observer.elevation, float) and observer.elevation > 0.0:
            adjustment_for_elevation = adjust_to_horizon(observer.elevation)
        elif isinstance(observer.elevation, tuple):
            adjustment_for_elevation = adjust_to_obscuring_feature(observer.elevation)
    
        adjustment_for_refraction = refraction_at_zenith(zenith + adjustment_for_elevation)
    
        jd = julianday(date)
        t = jday_to_jcentury(jd)
        solarDec = sun_declination(t)
    
>       hourangle = hour_angle(
            latitude,
            solarDec,
            zenith + adjustment_for_elevation - adjustment_for_refraction,
            direction,
        )

../../BUILDROOT/python-astral-2.1-1.fc33.x86_64/usr/lib/python3.9/site-packages/astral/sun.py:355: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

latitude = 64.16666666666667, declination = 20.23388643880472
zenith = 95.9450968313411, direction = <SunDirection.RISING: 1>

    def hour_angle(
        latitude: float, declination: float, zenith: float, direction: SunDirection
    ) -> float:
        """Calculate the hour angle of the sun
    
        See https://en.wikipedia.org/wiki/Hour_angle#Solar_hour_angle
    
        Args:
            latitude: The latitude of the obersver
            declination: The declination of the sun
            zenith: The zenith angle of the sun
            direction: The direction of traversal of the sun
    
        Raises:
            ValueError
        """
    
        latitude_rad = radians(latitude)
        declination_rad = radians(declination)
        zenith_rad = radians(zenith)
    
        # n = cos(zenith_rad)
        # d = cos(latitude_rad) * cos(declination_rad)
        # t = tan(latitude_rad) * tan(declination_rad)
        # h = (n / d) - t
    
        h = (cos(zenith_rad) - sin(latitude_rad) * sin(declination_rad)) / (
            cos(latitude_rad) * cos(declination_rad)
        )
    
>       HA = acos(h)
E       ValueError: math domain error

../../BUILDROOT/python-astral-2.1-1.fc33.x86_64/usr/lib/python3.9/site-packages/astral/sun.py:253: ValueError

The above exception was the direct cause of the following exception:

test_database = {'africa': {'abuja': [LocationInfo(name='Abuja', region='Nigeria', timezone='Africa/Lagos', latitude=9.083333333333334..., region='Faroe Islands', timezone='Atlantic/Faroe', latitude=62.083333333333336, longitude=-6.933333333333334)]}, ...}

    def test_AllLocations(test_database):
        for location in all_locations(test_database):
>           sun(location.observer)

src/test/test_all.py:6: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../BUILDROOT/python-astral-2.1-1.fc33.x86_64/usr/lib/python3.9/site-packages/astral/sun.py:1120: in sun
    "dawn": dawn(observer, date, dawn_dusk_depression, tzinfo),
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

observer = Observer(latitude=64.16666666666667, longitude=-51.583333333333336, elevation=0.0)
date = datetime.date(2020, 5, 21), depression = <Depression.CIVIL: 6.0>
tzinfo = <UTC>

    def dawn(
        observer: Observer,
        date: Optional[datetime.date] = None,
        depression: Union[float, Depression] = Depression.CIVIL,
        tzinfo: datetime.tzinfo = pytz.utc,
    ) -> datetime.datetime:
        """Calculate dawn time.
    
        Args:
            observer:   Observer to calculate dawn for
            date:       Date to calculate for. Default is today's date in the timezone `tzinfo`.
            depression: Number of degrees below the horizon to use to calculate dawn.
                        Default is for Civil dawn i.e. 6.0
            tzinfo:     Timezone to return times in. Default is UTC.
    
        Returns:
            Date and time at which dawn occurs.
    
        Raises:
            ValueError: if dawn does not occur on the specified date
        """
        if date is None:
            date = today(tzinfo)
    
        dep: float = 0.0
        if isinstance(depression, Depression):
            dep = depression.value
        else:
            dep = depression
    
        try:
            return time_of_transit(
                observer, date, 90.0 + dep, SunDirection.RISING
            ).astimezone(tzinfo)
        except ValueError as exc:
            if exc.args[0] == "math domain error":
>               raise ValueError(
                    f"Sun never reaches {dep} degrees below the horizon, at this location."
                ) from exc
E               ValueError: Sun never reaches 6.0 degrees below the horizon, at this location.

../../BUILDROOT/python-astral-2.1-1.fc33.x86_64/usr/lib/python3.9/site-packages/astral/sun.py:739: ValueError
===================== 1 failed, 264 passed in 1.38 seconds =====================

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.9/fedora-rawhide-x86_64/01396551-python-astral/

For all our attempts to build python-astral with Python 3.9, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.9/package/python-astral/

Testing and mass rebuild of packages is happening in copr. You can follow these instructions to test locally in mock if your package builds with Python 3.9:
https://copr.fedorainfracloud.org/coprs/g/python/python3.9/

Let us know here if you have any questions.

Python 3.9 will be included in Fedora 33. To make that update smoother, we're building Fedora packages with early pre-releases of Python 3.9.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires), so if this package is required a lot, it's important for us to get it fixed soon.
We'd appreciate help from the people who know this package best, but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Miro Hrončok 2020-05-25 13:02:05 UTC
This comment is mass posted to all bugs blocking the Python 3.9 tracker, sorry if it is not 100 % relevant. When in doubt, please ask.


The Python 3.9 rebuild is in progress in a Koji side tag.

If you fix this bug, please don't rebuild the package in regular rawhide, but do it in the side tag with:

    $ fedpkg build --target=f33-python

The rebuild is progressing slowly and it is possible this package won't have all the required build dependencies yet. If that's the case, please just leave the fix committed and pushed and we will eventually rebuild it for you.

You are not asked to go and try rebuild all the missing dependencies yourself. If you know there is a bootstrap loop in the dependencies, let me know and we can untangle it together.

If you want to test your fix or reproduce the failure, you can still use the Copr repo mentioned in the initial comment of this bug: https://copr.fedorainfracloud.org/coprs/g/python/python3.9/

Comment 2 Miro Hrončok 2020-05-29 07:11:55 UTC
Python 3.9 update: The f33-python side tag is currently being merged.

New builds in f33-python are no longer possible, but python3 is not yet updated to Python 3.9 in rawhide. You can check when Python is Python 3.9 with:

    $ koji wait-repo f33-build --build python3.9-3.9.0~b1-3.fc3

And build the packages normally after that.

Comment 3 Miro Hrončok 2020-06-11 11:48:18 UTC
This is a bulk close of Python 3.9 bugzillas of packages that successfully built.
If this remained open for a reason, I am sorry and feel free to reopen.


Note You need to log in before you can comment on or make changes to this bug.