Skip to content

Commit

Permalink
Merge branch 'python3'
Browse files Browse the repository at this point in the history
This finally ends the long and painful story of trying to maintain two
versions of PyEphem, one for Python 2 and the other for Python 3.
Thanks to the experience that other projects have given me in the last
few years about writing 2+3 compatible code, plus a dozen or so daring C
language #if...#else...#fi calls, I am now back to one code base only.

Conflicts:
	.gitignore
	INSTALL
	MANIFEST.in
	README.rst
	extensions/_libastro.c
	libastro-3.7.5/dbfmt.c
	libastro-3.7.5/formats.c
	libastro-3.7.5/misc.c
	setup.py
	src/ephem/__init__.py
	src/ephem/doc/CHANGELOG.rst
	src/ephem/doc/angle.rst
	src/ephem/doc/coordinates.rst
	src/ephem/doc/date.rst
	src/ephem/doc/examples.rst
	src/ephem/doc/index.rst
	src/ephem/doc/newton.rst
	src/ephem/doc/quick.rst
	src/ephem/doc/radec.rst
	src/ephem/doc/tutorial.rst
	src/ephem/tests/test_angles.py
	src/ephem/tests/test_bodies.py
	src/ephem/tests/test_dates.py
	src/ephem/tests/test_jpl.py
	src/ephem/tests/test_rst.py
	src/ephem/tests/test_satellite.py
	src/ephem/tests/test_usno.py
  • Loading branch information
brandon-rhodes committed May 14, 2014
2 parents 8c29b38 + 5bc157d commit 481e5a8
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -3,7 +3,7 @@
MANIFEST
build
dist
src/ephem/_libastro.so
src/ephem/_libastro*.so
src/ephem/doc/_build
tmp*.py
*.py[co]
Expand Down
18 changes: 6 additions & 12 deletions INSTALL
Expand Up @@ -15,25 +15,19 @@ in this directory for licensing information.

INSTALLING

If you have installed the Python "distribute" package (or the ancient
and outdated "setuptools") and "pip" on your system, then you can
install PyEphem simply by typing:
If you have installed the standard Python package tool "pip", then you
can install PyEphem simply by typing:

pip install pyephem

If for some reason you cannot install "pip", then "distribute" by itself
offers an installer that you can use this way:

easy_install pyephem

Alternately, if you are on a Windows machine, look at the PyEphem web
site and you should find prominent links to an auto-install tool for
Windows.

If, instead, you want to build and install the module yourself, you
only need Python, your C compiler, and the standard Python distutils.
You can run the setup.py script in this directory to build or install
the package. Typically, entering
If instead you want to build and install the module yourself, you only
need Python, your C compiler, and the standard Python distutils. You
can run the setup.py script in this directory to build or install the
package. Typically, entering

python setup.py install

Expand Down
7 changes: 0 additions & 7 deletions README.rst
Expand Up @@ -15,13 +15,6 @@ PyEphem README
.. _Tutorial: http://rhodesmill.org/pyephem/tutorial
.. _PyEphem web site: http://rhodesmill.org/pyephem/

**This version of PyEphem,
named** `pyephem`_ **in the Python Package Index,
is the version for the Python 2.x series.
If you have gone ahead and transitioned to Python 3.0,
then look for the package named** `ephem`_
**instead.**

PyEphem provides an ``ephem`` Python package
for performing high-precision astronomy computations.
The underlying numeric routines are coded in C
Expand Down
5 changes: 3 additions & 2 deletions setup.py
@@ -1,5 +1,4 @@
import os
import sys
from distutils.core import setup, Extension
from glob import glob

Expand All @@ -10,7 +9,7 @@
if line.startswith('__version__'):
__version__ = eval(line.split(None, 2)[2]) # skip '__version__', '='

# The `pyephem' module is built from every .c file in the libastro
# The 'ephem' module is built from every .c file in the libastro
# directory plus ...

libastro_version = '3.7.5'
Expand All @@ -34,6 +33,8 @@ def read(*filenames):
'License :: OSI Approved ::'
' GNU Library or Lesser General Public License (LGPL)',
'Topic :: Scientific/Engineering :: Astronomy',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.0',
],
packages = [ 'ephem', 'ephem.tests' ],
package_dir = { '': 'src' },
Expand Down
16 changes: 14 additions & 2 deletions src/ephem/tests/test_bodies.py
Expand Up @@ -172,10 +172,10 @@ def build(self, bodytype, dbentry, attributes):
setattr(ba, attribute, value)
except TypeError:
raise TestError('cannot modify attribute %s of %r: %s'
% (attribute, ba, sys.exc_info()[1]))
% (attribute, ba, sys.exc_info()[1]))
if not isinstance(bl, bodytype):
raise TestError('ephem database entry returned type %s'
' rather than type %s' % (type(bl), bodytype))
' rather than type %s' % (type(bl), bodytype))

# Now, compare the bodies to see if they are equivalent.
# First test whether they present the right attributes.
Expand Down Expand Up @@ -270,6 +270,18 @@ def test_newlineTLE(self):
'2 20580 28.4694 17.3953 0004117 265.2946 '
'94.7172 14.99359833594524\n')

# TODO: get this failure mode failing again

def OFF_test_badTLE(self):
"""Make sure illegal-character TLE strings are properly caught."""
# based on bug report from Reto Schüttel, 2008 Dec 10
self.assertRaises(ValueError, readtle,
'HST \xfe ', # \xfe is bad char
'1 20580U 90037B 04296.45910607 .00000912 '
' 00000-0 59688-4 0 1902',
'2 20580 28.4694 17.3953 0004117 265.2946 '
'94.7172 14.99359833594524')

# A user reported that Saturn's ring tilt was misbehaving, and there was
# indeed a major error occuring in its calculation. This small test
# should assure that reasonable values are returned from now on.
Expand Down
29 changes: 29 additions & 0 deletions src/ephem/tests/test_locales.py
@@ -0,0 +1,29 @@
#!/usr/bin/env python

import unittest
import ephem
import locale

# Determine whether we can convert values regardless of locale.

class locales_suite(unittest.TestCase):
def setUp(self):
self.old_locale = locale.getlocale(locale.LC_NUMERIC)
locale.setlocale(locale.LC_NUMERIC, 'de_CH.UTF-8')

def tearDown(self):
locale.setlocale(locale.LC_NUMERIC, self.old_locale)

def test_date_creation(self):
self.assertEqual(ephem.date('2008.5'), 39629.5) # instead of 2008.0

def test_satellite_creation(self):
s = ephem.readtle('ISS (ZARYA)',
'1 25544U 98067A 08334.54218750 .00025860 '
'00000-0 20055-3 0 7556',
'2 25544 051.6425 248.8374 0006898 046.3246 '
'303.9711 15.71618375574540594')
self.assertEqual(str(s._raan), '248:50:14.6') # instead of :00:00.0

if __name__ == '__main__':
unittest.main()

0 comments on commit 481e5a8

Please sign in to comment.