Skip to main content

Cosmicly

Tests

Cosmicly is a Python package that answers the important questions in life:

  • How much would I weigh on Jupiter?
  • How old would I be on Mercury?
  • What time is it on Mars right now?
  • How long would it take to drive to Neptune?

It uses real orbital periods, gravity, and solar day lengths for the eight planets and Earth's Moon, so the numbers are (mostly) real, even if the questions are strange.

Install

pip install cosmicly

cosmicly on PyPI · Requires Python 3.11 or newer.

Install from source (for contributors)

You need Python 3.11 or newer and Pipenv. Run these commands in a terminal:

git clone https://github.com/software-students-fall2026/python-package-exercise-LCDJ.git
cd python-package-exercise-LCDJ
pipenv install --dev
pipenv run python -m pip install -e .

The editable install lets Python import cosmicly from src and pick up your changes immediately. The package includes its planetary data and needs no environment variables or database.

Use cosmicly

Save these examples in a Python file and run it with python your_script.py (or pipenv run python your_script.py if you installed from source). For an interactive tour of the package, run the included example program:

pipenv run python example.py

Age and weight

age_on_planet converts Earth years to years on the destination using its orbital period. earth_age calculates your age in Earth years from a birthdate. weight_on_planet scales an Earth weight in "w" mode and calculates weight in newtons from a mass in kilograms in "m" mode.

from cosmicly import age_on_planet, earth_age
from cosmicly.planetary_weight import weight_on_planet

print(age_on_planet(20, "mercury"))            # 83.0 Mercury years
print(earth_age("2000-01-01"))                 # Age in Earth years as of today
print(weight_on_planet("w", 70, "mars"))       # 26.43 in the input weight unit
print(weight_on_planet("m", 70, "moon"))       # 112.0 newtons

Planetary clocks and comparisons

relative_time returns an HH:MM:SS reading on a simulated planetary clock. It starts the Earth and destination clocks together at midnight and uses the destination's solar day length. Pass a datetime for a fixed reference reading or omit it to use the current local time. compare_planets returns your age and weight on two different destinations as a dictionary.

from datetime import datetime

from cosmicly import compare_planets, relative_time

print(relative_time("mars"))                             # Simulated time now
print(relative_time("mars", datetime(2026, 1, 1, 12)))     # 11:40:44

comparison = compare_planets("mars", "jupiter", "2000-01-01", 70)
print(comparison["mars"]["age"])
print(comparison["jupiter"]["weight"])

Travel from Earth

distance_from_earth gives the distance to a planet in km. Without a date it uses the closest approach; with a date ("YYYY-MM-DD" or a date) it uses the real distance on that day, since planets move. travel_at_speed gives the travel time at any speed in km/h, and drive_to, fly_to, and light_speed_to use car, plane, and light speed. arrival_age tells you how old you'll be when you arrive. format_duration turns seconds into readable text.

from cosmicly.planetary_travel import (
    arrival_age,
    distance_from_earth,
    drive_to,
    fly_to,
    format_duration,
    light_speed_to,
    travel_at_speed,
)

print(distance_from_earth("moon"))             # 384400 km
print(travel_at_speed("mars", 40_000))         # Travel time at 40,000 km/h
print(drive_to("mars"))                        # 89 years at 100 km/h
print(drive_to("mars", "2026-11-10"))          # 232 years, real distance that day
print(fly_to("moon"))                          # 18 days at 900 km/h
print(light_speed_to("mars"))                  # 4 minutes
print(arrival_age("mars", 100, 20))            # 109.44, your age when you arrive
print(format_duration(3600))                   # 1 hour

Build and test

Run these commands from the repository root after installing the development dependencies:

pipenv run python -m build
pipenv run python -m pytest
pipenv run python -m pytest --cov=cosmicly --cov-report=term-missing

The build writes a wheel and a source archive to dist/. The tests live in tests/. GitHub Actions builds the package and runs the tests on pull requests targeting main. Tests workflow

Team

Data sources

The package stores orbital periods, gravity, distances from the Sun, and solar day lengths in data.py. NASA Planetary Fact Sheet · NASA Mars24

Metadata

Release files for cosmicly 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cosmicly 0.1.1
File Size Uploaded Provenance Actions
cosmicly-0.1.1.tar.gz 27.8 kB Without provenance Details for cosmicly-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cosmicly 0.1.1
File Interpreter ABI Platform Actions
cosmicly-0.1.1-py3-none-any.whl Python 3 none any Details for cosmicly-0.1.1-py3-none-any.whl

Total release size: 49.6 kB

Release files / cosmicly-0.1.1.tar.gz

Download URL cosmicly-0.1.1.tar.gz
Size 27.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ff08e3482b6645bcacaac2826e3a7abeca42c5819617f5194809727fba94b201
BLAKE2b-256 checksum
How to use checksums
db792928879d774b37fd6283ee5727e4863635d122e04df667217dad3075abe4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.4

Release files / cosmicly-0.1.1-py3-none-any.whl

Download URL cosmicly-0.1.1-py3-none-any.whl
Size 21.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8fc9c7b47624efab8f8ae8632fbc555ae7ed1e45fe976d99249a9baadcf5e927
BLAKE2b-256 checksum
How to use checksums
3df42b94a3f144fa1bf1ce1d6f84a2cb39a9d6fa0cadaecf1d88aabbdac48787
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.4

Security for cosmicly 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page