Skip to content

Commit

Permalink
Added proper support for pre-release tags and fixed a few minor issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
cnobile2012 committed Dec 16, 2023
1 parent ad0d3ca commit c6b8e1b
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 22 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
TODAY = $(shell date +"%Y-%m-%dT%H:%M:%S.%N%:z")
PPREFIX = $(shell pwd)
BASE_DIR = $(shell echo $${PWD\#\#*/})
TEST_TAG = # Define the rc<version>
PACKAGE_DIR = $(BASE_DIR)-$(VERSION)$(TEST_TAG)
PR_TAG = # Define the rc<version>
PACKAGE_DIR = $(BASE_DIR)-$(VERSION)$(PR_TAG)
APP_NAME = sunrisesunset
DOCS = $(PREFIX)/docs
RM_REGEX = '(^.*.pyc$$)|(^.*.wsgic$$)|(^.*~$$)|(.*\#$$)|(^.*,cover$$)'
Expand Down Expand Up @@ -44,8 +44,8 @@ sphinx : clean
# To add a pre-release candidate such as 'rc1' to a test package name an
# environment variable needs to be set that setup.py can read.
#
# make build TEST_TAG=rc1
# make upload-test TEST_TAG=rc1
# make build PR_TAG=rc1
# make upload-test PR_TAG=rc1
#
# The tarball could then be named sunrisesunset-2.0.0rc1.tar.gz
#
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,5 @@ month, and day needs to be entered.
Sunset: 2023-12-16 19:00:39.782789-05:00
Is night: False
Test 24 hours
Test 24 hours for every 20 minutes.
...
2 changes: 1 addition & 1 deletion include.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
# Django Dynamic Column version info.
MAJORVERSION = 1
MINORVERSION = 0
PATCHLEVEL = 1
PATCHLEVEL = 2
VERSION = ${MAJORVERSION}.${MINORVERSION}.${PATCHLEVEL}
12 changes: 10 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# -*- coding: utf-8 -*-
"""
Setup a pip environment.
"""
__docformat__ = "restructuredtext en"

import os
import re
from setuptools import setup

filepath = os.path.dirname(__file__)

def version():
"""
Find the version.
Expand All @@ -13,7 +19,7 @@ def version():
"""
regex = r'(?m)(^{}[\s]*=[\s]*(?P<ver>\d*)$)'

with open(os.path.join(os.path.dirname(__file__), 'include.mk')) as f:
with open(os.path.join(filepath, 'include.mk')) as f:
ver = f.read()

major = re.search(regex.format('MAJORVERSION'), ver).group('ver')
Expand All @@ -23,7 +29,9 @@ def version():
env_value = os.environ.get('PR_TAG', '')
return f"{major}.{minor}.{patch}{env_value}"

with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as readme:
filename = os.path.join(filepath, 'README.rst')

with open(filename, mode='r', encoding='UTF-8') as readme:
README = readme.read()

# Allow setup.py to be run from any path.
Expand Down
4 changes: 4 additions & 0 deletions sunrisesunset/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
#
# sunrisesunset/__init__.py
#
"""
Alow the import of SunriseSunset without having to import the actual file.
"""
__docformat__ = "restructuredtext en"

from .sunrisesunset import SunriseSunset

Expand Down
31 changes: 17 additions & 14 deletions sunrisesunset/sunrisesunset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
#
# sunrisesunset.py
#
# This code is valid for dates from 1901 to 2099, and will not calculate
# sunrise/sunset times for latitudes above/below 63/-63 degrees.
#
# No external packages are used when using the class SunriseSunset. If you
# run the tests you will need to install pytz as shown below or use your
# package installer if it's available.
#
#----------------------------------
#
# Contributions by:
# Darryl Smith -- Noticed a bug with atan fixed with atan2.
#
"""
This code is valid for dates from 1901 to 2099, and will not calculate
sunrise/sunset times for latitudes above/below 63/-63 degrees.
No external packages are used when using the class SunriseSunset. If you
run the tests you will need to install pytz, geopy, and timezonefinder as
shown below or use your package installer if it's available.
----------------------------------
Contributions by:
Darryl Smith -- Noticed a bug with atan fixed with atan2.
"""
__docformat__ = "restructuredtext en"


import datetime
from math import degrees, radians, atan2, cos, sin, pi, sqrt, fabs
Expand Down Expand Up @@ -270,11 +272,12 @@ def __get_rise_set(date, lat=35.9513, lon=-83.9142, zenith='official'):

# Get sunrise sunset for every hour of the day using the
# default zenith.
print("\nTest 24 hours")
minutes = 20
print(f"\nTest 24 hours for every {minutes} minutes.")

for hour in range(24):
# Every 20 minutes for an hour.
for minute in range(0, 60, 20):
for minute in range(0, 60, minutes):
date = dt.replace(hour=hour, minute=minute,
second=0, microsecond=0)
__get_rise_set(date, lat=lat, lon=lon)
Expand Down

0 comments on commit c6b8e1b

Please sign in to comment.