Skip to content

Commit 7a4c46a

Browse files
authored
fix: properly get locations data (#9)
* Properly get locations data
1 parent 429bb72 commit 7a4c46a

2 files changed

Lines changed: 25 additions & 15 deletions

File tree

Makefile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ run: init ## Run application
1717
uv run python main.py
1818

1919
package: clean init ## Generate Python wheel and macOS App bundle
20-
@echo "Building Python wheel..."
20+
echo "Building Python wheel..."
2121
uv build --wheel
22-
@echo ""
23-
@echo "✓ Wheel created in dist/"
24-
@echo ""
25-
@echo "Building macOS App Bundle with PyInstaller..."
26-
@echo "Installing PyInstaller if needed..."
22+
echo ""
23+
echo "✓ Wheel created in dist/"
24+
echo ""
25+
echo "Building macOS App Bundle with PyInstaller..."
26+
echo "Installing PyInstaller if needed..."
2727
uv pip install pyinstaller
28-
@echo "Creating app bundle..."
28+
echo "Creating app bundle..."
2929
uv run pyinstaller geosetter_lite.spec
30-
@echo ""
31-
@echo "✓ macOS App Bundle created in dist/GeoSetter Lite.app"
30+
echo ""
31+
echo "✓ macOS App Bundle created in dist/GeoSetter Lite.app"

geosetter_lite/services/location_database.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,29 @@ def __init__(self, db_path: Path, csv_path: Path = None):
1818
"""
1919
self.db_path = db_path
2020
self.db_path.parent.mkdir(parents=True, exist_ok=True)
21-
21+
2222
# Auto-detect CSV path if not provided
2323
if csv_path is None:
24-
# Look for world_locations.csv in data directory
25-
module_dir = Path(__file__).parent.parent
26-
self.csv_path = module_dir / "data" / "world_locations.csv"
24+
# Look for world_locations.csv in multiple locations
25+
module_dir = Path(__file__).parent.parent # geosetter_lite package dir
26+
27+
# Priority 1: Check inside package (for installed/built package)
28+
csv_candidate = module_dir / "data" / "world_locations.csv"
29+
30+
if not csv_candidate.exists():
31+
# Priority 2: Check project root data directory (for development mode)
32+
# Go up from geosetter_lite/ to project root
33+
project_root = module_dir.parent
34+
csv_candidate = project_root / "data" / "world_locations.csv"
35+
36+
self.csv_path = csv_candidate
2737
else:
2838
self.csv_path = csv_path
29-
39+
3040
# Initialize database if it doesn't exist
3141
if not self.db_path.exists():
3242
self._initialize_database()
33-
43+
3444
def _initialize_database(self):
3545
"""Create and populate the location database"""
3646
print(f"Initializing location database at {self.db_path}...")

0 commit comments

Comments
 (0)