mirror of
https://github.com/cosinekitty/astronomy.git
synced 2026-05-19 06:17:03 -04:00
More Python/pip package cleanup : version 2.0.17.
Generate astronomy.py directly in the package directory.
I realized it doesn't make sense to generate it in the
parent directory and then copy it; just generate it where
it will end up anyway.
Updated documentation so people know they can just do
pip install astronomy-engine
to install Astronomy Engine in their Python project.
Removed the GitHub Actions status badge because it is redundant with
the checkmark/X indicator.
Now that private symbols are no longer exported, I had to
fix a couple of places where the unit tests still accessed them.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
<img src="https://raw.githubusercontent.com/cosinekitty/astronomy/master/astronomy_engine_logo.png" width="640">
|
||||
|
||||
[](https://github.com/cosinekitty/astronomy/actions)
|
||||
[](https://www.npmjs.com/package/astronomy-engine)
|
||||
[](https://badge.fury.io/py/astronomy-engine)
|
||||
|
||||
|
||||
@@ -851,7 +851,7 @@ static int GenerateSource(void)
|
||||
CHECK(GenerateCode(CODEGEN_LANGUAGE_C, "../source/c/astronomy.c", "template/astronomy.c", "output"));
|
||||
CHECK(GenerateCode(CODEGEN_LANGUAGE_CSHARP, "../source/csharp/astronomy.cs", "template/astronomy.cs", "output"));
|
||||
CHECK(GenerateCode(CODEGEN_LANGUAGE_JS, "../source/js/astronomy.ts", "template/astronomy.ts", "output"));
|
||||
CHECK(GenerateCode(CODEGEN_LANGUAGE_PYTHON, "../source/python/astronomy.py", "template/astronomy.py", "output"));
|
||||
CHECK(GenerateCode(CODEGEN_LANGUAGE_PYTHON, "../source/python/astronomy/astronomy.py", "template/astronomy.py", "output"));
|
||||
fail:
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ echo "Generating target code."
|
||||
./generate source || Fail "Problem generating target code."
|
||||
|
||||
echo "Trimming trailing whitespace in target code."
|
||||
for file in ../source/c/astronomy.c ../source/js/astronomy.ts ../source/python/astronomy.py ../source/csharp/astronomy.cs; do
|
||||
for file in ../source/c/astronomy.c ../source/js/astronomy.ts ../source/python/astronomy/astronomy.py ../source/csharp/astronomy.cs; do
|
||||
node trimspace.js ${file} || Fail "Cannot trim whitespace from target file: ${file}"
|
||||
done
|
||||
|
||||
@@ -111,12 +111,12 @@ else
|
||||
fi
|
||||
|
||||
echo "Generating Python documentation."
|
||||
python3 pydown/pydown.py pydown/py_prefix.md ../source/python/astronomy.py ../source/python/README.md || Fail "Error generating Markdown from Python source."
|
||||
python3 pydown/pydown.py pydown/py_prefix.md ../source/python/astronomy/astronomy.py ../source/python/README.md || Fail "Error generating Markdown from Python source."
|
||||
./check_internal_links.py ../source/python/README.md || exit 1
|
||||
|
||||
echo "Making redundant copies of source in demo folders."
|
||||
cp -v ../source/js/astronomy.browser.js ../demo/browser/ || exit $?
|
||||
cp -v ../source/js/astronomy.js ../demo/nodejs/ || exit $?
|
||||
cp -v ../source/python/astronomy.py ../demo/python/ || exit $?
|
||||
cp -v ../source/python/astronomy/astronomy.py ../demo/python/ || exit $?
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -25,7 +25,7 @@ if errorlevel 1 (
|
||||
)
|
||||
|
||||
echo.Trimming trailing whitespace in target code.
|
||||
for %%f in (..\source\c\astronomy.c ..\source\js\astronomy.js ..\source\python\astronomy.py ..\source\csharp\astronomy.cs) do (
|
||||
for %%f in (..\source\c\astronomy.c ..\source\js\astronomy.js ..\source\python\astronomy\astronomy.py ..\source\csharp\astronomy.cs) do (
|
||||
node trimspace.js %%f
|
||||
if errorlevel 1 (exit /b 1)
|
||||
)
|
||||
@@ -194,7 +194,7 @@ if exist disable_generate_c_docs (
|
||||
)
|
||||
|
||||
echo.Generating Python documentation.
|
||||
pydown\pydown.py pydown\py_prefix.md ..\source\python\astronomy.py ..\source\python\README.md
|
||||
pydown\pydown.py pydown\py_prefix.md ..\source\python\astronomy\astronomy.py ..\source\python\README.md
|
||||
if errorlevel 1 (exit /b 1)
|
||||
|
||||
echo.Making redundant copies of source in demo folders.
|
||||
@@ -205,7 +205,7 @@ if errorlevel 1 (exit /b 1)
|
||||
copy ..\source\js\astronomy.js ..\demo\nodejs\
|
||||
if errorlevel 1 (exit /b 1)
|
||||
|
||||
copy ..\source\python\astronomy.py ..\demo\python\
|
||||
copy ..\source\python\astronomy\astronomy.py ..\demo\python\
|
||||
if errorlevel 1 (exit /b 1)
|
||||
|
||||
exit /b 0
|
||||
|
||||
@@ -7,8 +7,22 @@ See the [home page](https://github.com/cosinekitty/astronomy) for more info.
|
||||
---
|
||||
|
||||
## Quick Start
|
||||
To include Astronomy Engine in your own Python program, all you need is
|
||||
the file `astronomy.py` from this directory.
|
||||
To include Astronomy Engine in your own Python program,
|
||||
you can use the [astronomy-engine](https://pypi.org/project/astronomy-engine/) package:
|
||||
|
||||
```
|
||||
pip install astronomy-engine
|
||||
```
|
||||
|
||||
Alternatively, you can copy the file [astronomy/astronomy.py](astronomy/astronomy.py)
|
||||
into your project directory.
|
||||
|
||||
With either approach, add the following line toward the top of your program:
|
||||
|
||||
```python
|
||||
import astronomy
|
||||
```
|
||||
|
||||
|
||||
To get started quickly, here are some [examples](../../demo/python/).
|
||||
|
||||
|
||||
@@ -1143,12 +1143,24 @@ def Refraction():
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------
|
||||
|
||||
PlanetOrbitalPeriod = {
|
||||
astronomy.Body.Mercury: 87.969,
|
||||
astronomy.Body.Venus: 224.701,
|
||||
astronomy.Body.Earth: 365.256,
|
||||
astronomy.Body.Mars: 686.980,
|
||||
astronomy.Body.Jupiter: 4332.589,
|
||||
astronomy.Body.Saturn: 10759.22,
|
||||
astronomy.Body.Uranus: 30685.4,
|
||||
astronomy.Body.Neptune: 60189.0,
|
||||
astronomy.Body.Pluto: 90560.0
|
||||
}
|
||||
|
||||
def PlanetApsis():
|
||||
start_time = astronomy.Time.Make(1700, 1, 1, 0, 0, 0)
|
||||
body = astronomy.Body.Mercury
|
||||
while body.value <= astronomy.Body.Pluto.value:
|
||||
count = 1
|
||||
period = astronomy._PlanetOrbitalPeriod[body.value]
|
||||
period = PlanetOrbitalPeriod[body]
|
||||
filename = os.path.join('apsides', 'apsis_{}.txt'.format(body.value))
|
||||
min_interval = -1.0
|
||||
max_diff_days = 0.0
|
||||
@@ -1254,7 +1266,6 @@ def LunarEclipseIssue78():
|
||||
#-----------------------------------------------------------------------------------------------------------
|
||||
|
||||
def LunarEclipse():
|
||||
astronomy._CalcMoonCount = 0
|
||||
filename = 'eclipse/lunar_eclipse.txt'
|
||||
with open(filename, 'rt') as infile:
|
||||
eclipse = astronomy.SearchLunarEclipse(astronomy.Time.Make(1701, 1, 1, 0, 0, 0))
|
||||
@@ -1343,7 +1354,7 @@ def LunarEclipse():
|
||||
# calculate for next iteration
|
||||
|
||||
eclipse = astronomy.NextLunarEclipse(eclipse.peak)
|
||||
print("PY LunarEclipse: PASS (verified {}, skipped {}, max_diff_minutes = {}, avg_diff_minutes = {}, moon calcs = {})".format(lnum, skip_count, max_diff_minutes, (sum_diff_minutes / diff_count), astronomy._CalcMoonCount))
|
||||
print("PY LunarEclipse: PASS (verified {}, skipped {}, max_diff_minutes = {}, avg_diff_minutes = {})".format(lnum, skip_count, max_diff_minutes, (sum_diff_minutes / diff_count)))
|
||||
return 0
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -8,7 +8,7 @@ Fail()
|
||||
[[ "$1" == "" || "$1" == "-v" ]] || Fail "Invalid command line options."
|
||||
|
||||
python3 --version || Fail "Cannot print python version"
|
||||
python3 -m pylint --init-hook="import sys; sys.setrecursionlimit(2000)" ../source/python/astronomy.py || Fail "pylint detected problems"
|
||||
python3 -m pylint --init-hook="import sys; sys.setrecursionlimit(2000)" ../source/python/astronomy/astronomy.py || Fail "pylint detected problems"
|
||||
python3 test.py $1 all || Fail "Failed Python unit tests."
|
||||
for file in temp/py_longitude_*.txt; do
|
||||
./generate $1 check ${file} || Fail "Failed verification of file ${file}"
|
||||
|
||||
@@ -7,8 +7,22 @@ See the [home page](https://github.com/cosinekitty/astronomy) for more info.
|
||||
---
|
||||
|
||||
## Quick Start
|
||||
To include Astronomy Engine in your own Python program, all you need is
|
||||
the file `astronomy.py` from this directory.
|
||||
To include Astronomy Engine in your own Python program,
|
||||
you can use the [astronomy-engine](https://pypi.org/project/astronomy-engine/) package:
|
||||
|
||||
```
|
||||
pip install astronomy-engine
|
||||
```
|
||||
|
||||
Alternatively, you can copy the file [astronomy/astronomy.py](astronomy/astronomy.py)
|
||||
into your project directory.
|
||||
|
||||
With either approach, add the following line toward the top of your program:
|
||||
|
||||
```python
|
||||
import astronomy
|
||||
```
|
||||
|
||||
|
||||
To get started quickly, here are some [examples](../../demo/python/).
|
||||
|
||||
|
||||
1
source/python/astronomy/.gitignore
vendored
1
source/python/astronomy/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
astronomy.py
|
||||
@@ -1,6 +1,5 @@
|
||||
#!/bin/bash
|
||||
rm -f dist/*
|
||||
cp -v astronomy.py astronomy/astronomy.py || exit $?
|
||||
python3 -m build || exit $?
|
||||
python3 -m twine upload --repository astronomy-engine dist/* || exit $?
|
||||
exit 0
|
||||
|
||||
@@ -2,7 +2,7 @@ from setuptools import setup
|
||||
|
||||
setup(
|
||||
name='astronomy-engine',
|
||||
version='2.0.16',
|
||||
version='2.0.17',
|
||||
description='Astronomy calculation for Sun, Moon, and planets.',
|
||||
long_description=open('README.md').read(),
|
||||
long_description_content_type='text/markdown',
|
||||
|
||||
Reference in New Issue
Block a user