Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
procrastinatio committed Jan 4, 2025
1 parent 9983233 commit 0185ca9
Show file tree
Hide file tree
Showing 23 changed files with 2,085 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
*.mo
__pycache__
*.pyc
*.log

.idea
output/Thumbs.db
*.egg-info

# build
dist/
build/

29 changes: 29 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2025, swisstopo
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include src/geocover_qa/data/*.gpkg
include src/geocover_qa/data/*.json
118 changes: 118 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
.PHONY: all clean env env-dev build-conda-base build-conda-gui gui-deps gui-build gui-clean build-pip install test test-pip test-conda

# Variables
CONDA_ENV_NAME = geocover-qa-dev
PYTHON_VERSION = 3.11
PACKAGE_NAME = geocover-qa

# Check if we're in a conda environment
CONDA_PREFIX ?= $(shell echo $$CONDA_PREFIX)
ifdef CONDA_PREFIX
# We're in an activated environment, use direct commands
CONDA_RUN =
else
# We're not in an environment, use conda run
CONDA_RUN = conda run -n $(CONDA_ENV_NAME)
endif

# Help target
help:
@echo "Available targets:"
@echo " make all - Create environment and install package"
@echo " make clean - Remove build artifacts"
@echo " make env - Create basic conda environment"
@echo " make env-dev - Create development environment"
@echo " make build-conda - Build all conda packages"
@echo " make build-pip - Build pip package"
@echo " make gui-deps - Install depencies for building PyQt application"
@echo " make gui-build - Build standalone PyQt GUI application"
@echo " make install - Install package in development mode"
@echo " make test - Run tests"
@echo " make test-pip - Test pip package installation"
@echo " make test-conda - Test conda package installation"
@echo " make full-check - Run full build and test cycle"


all: env install test

# Full build and test cycle
full-check: clean build-pip build-conda test-pip test-conda


lint:
ruff format src/
# Create basic conda environment
env:
conda config --set solver classic
conda create -n $(CONDA_ENV_NAME) python=$(PYTHON_VERSION) -y
$(CONDA_RUN) conda install --solver=classic -c conda-forge -c default -y geopandas matplotlib pandas gdal fiona numpy loguru pyqt

# Create development environment with all tools
env-dev: env
$(CONDA_RUN) conda install -c conda-forge -c default -y ruff flake8 twine conda-build pip build pytest
$(CONDA_RUN) pip install -e ".[dev,gui]"
$(CONDA_RUN) python -m pip install --upgrade build

# Build base conda package without GUI
build-conda-base:
$(CONDA_RUN) conda build . --output-folder dist/conda

# Build GUI conda package
build-conda-gui:
$(CONDA_RUN) conda build .conda/gui --output-folder dist/conda

# Build all conda packages
build-conda: build-conda-base build-conda-gui

# Build pip package
build-pip:
$(CONDA_RUN) python -m build --sdist --wheel --outdir dist/pip

gui-deps:
$(CONDA_RUN) pip install pyinstaller
$(CONDA_RUN) pip install -e ".[gui]"


# Build standalone GUI application
gui-build:
$(CONDA_RUN) pyinstaller gui/geocover-qa.spec --distpath dist/gui --workpath build/gui
gui-clean:
rm -rf build/gui
rm -rf dist/gui
rm -rf *.spec



# Full GUI build process
gui: gui-deps gui-build

# Install package in development mode
install:
$(CONDA_RUN) pip install -e ".[dev,gui]"

# Run tests with pytest
test:
$(CONDA_RUN) pytest tests/ -v

# Test pip package installation
test-pip:
pip install dist/pip/$(PACKAGE_NAME)-*.whl
pytest tests/ -v
pip uninstall -y $(PACKAGE_NAME)

# Test conda package installation
test-conda:
$(CONDA_RUN) conda install -y --use-local $(PACKAGE_NAME)
$(CONDA_RUN) pytest tests/ -v
$(CONDA_RUN) conda remove -y $(PACKAGE_NAME)



# Clean build artifacts and cache
clean: gui-clean
rm -rf build/
rm -rf dist/
rm -rf *.egg-info
rm -rf **/__pycache__
rm -rf .pytest_cache
rm -rf .coverage
Empty file added gui/__init__.py
Empty file.
Binary file added gui/favicon.ico
Binary file not shown.
92 changes: 92 additions & 0 deletions gui/geocover-qa.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# gui/geocover-qa.spec
# -*- mode: python ; coding: utf-8 -*-
import os
import sys
from pathlib import Path
import site
import platform

# Helper function to find GDAL libraries
def find_gdal_files():
if platform.system() == 'Windows':
# Look in common Windows locations
possible_paths = [
os.path.join(sys.prefix, 'Library', 'bin'), # Conda installation
os.path.join(site.getsitepackages()[0], 'osgeo'), # pip installation
]
files = [('gdal*.dll', '.'), ('proj*.dll', '.'), ('geos*.dll', '.')]
else: # POSIX systems (Linux, macOS)
possible_paths = [
'/usr/lib',
'/usr/local/lib',
os.path.join(sys.prefix, 'lib'), # Conda installation
]
files = [('libgdal*.so*', '.'), ('libproj*.so*', '.'), ('libgeos*.so*', '.')]
if platform.system() == 'Darwin': # macOS
files = [(name.replace('.so', '.dylib'), dest) for name, dest in files]

datas = []
for path in possible_paths:
if os.path.exists(path):
for pattern, dest in files:
for file in Path(path).glob(pattern):
datas.append((str(file), dest))
return datas

# Get platform-specific data files
platform_datas = find_gdal_files()


a = Analysis(
['main.py'],
#['main.py', 'utils.py', 'config.py', 'qa_stat.py'],
pathex=[],
binaries=[],
datas=[
# Include your package data
('../src/geocover_qa/data/*.gpkg', 'geocover_qa/data'),
#('data/lots_mapsheets.gpkg', 'data'),
#(r'D:\conda\envs\STANDALONE2\Library\bin\gdal.dll','.')
] + platform_datas, # Add platform-specific files
hiddenimports=['openpyxl.cell._writer', 'geocover_qa', 'geocover_qa.stat', 'geocover_qa.utils','pyqtspinner'],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
optimize=0,
)
pyz = PYZ(a.pure)

splash = Splash(
'splash.png',
always_on_top=True,
binaries=a.binaries,
datas=a.datas,
text_pos=(10, 50),
text_size=10,
text_color='black')

exe = EXE(
pyz,
a.scripts,
splash, # <-- both, splash target
splash.binaries, # <-- and splash binaries
a.binaries,
a.datas,
[],
name='qa_geocover',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon=['favicon.ico'],
)
Loading

0 comments on commit 0185ca9

Please sign in to comment.