Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrated to uv #109

Merged
merged 11 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
version: 2.1

orbs:
codecov: codecov/[email protected]
# orbs:
# codecov: codecov/[email protected]

jobs:
test:
machine:
image: ubuntu-2004:202010-01
image: ubuntu-2004:2024.05.1
steps:
- checkout:
path: UBCRocketGroundStation
Expand All @@ -25,17 +25,9 @@ jobs:
name: Send unit tests to codecov
command: |
cd UBCRocketGroundStation
curl -Os https://uploader.codecov.io/latest/linux/codecov
curl -Os https://cli.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov -Z -f test_reports/unit-test-coverage.xml -F unit
cd ..
- run:
name: Send integ tests to codecov
command: |
cd UBCRocketGroundStation
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov -Z -f test_reports/integ-test-coverage.xml -F integration
./codecov do-upload -s test_coverage
cd ..

workflows:
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7"]
python-version: ["3.12"]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4.2.2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5.3.0
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
python -m pip install --upgrade uv
uv sync
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v11.5
uses: tj-actions/changed-files@v45.0.3
- name: Analysing the code with pylint
run: |
for file in ${{ steps.changed-files.outputs.all_modified_files }}; do
if [[ -f $file && $file == *.py ]]
then
echo $file
pylint $file
uv run pylint $file
fi
done
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ coverage.xml
.hypothesis/
.pytest_cache/

# Local Pytest settings
.vscode/

# Translations
*.mo
*.pot
Expand Down
21 changes: 11 additions & 10 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
GLOBAL_PYTHON = sys.executable

VENV_BIN_DIR = os.path.join(LOCAL, {
'linux': 'venv/bin/',
'win32': 'venv/Scripts/',
'darwin': 'venv/bin/'
'linux': '.venv/bin/',
'win32': '.venv/Scripts/',
'darwin': '.venv/bin/'
}[sys.platform])

EXECUTABLE_FILE_EXTENSION = {
Expand All @@ -50,8 +50,6 @@
'darwin': 'python3'
}[sys.platform] + EXECUTABLE_FILE_EXTENSION)

VENV_PIP = os.path.join(VENV_BIN_DIR, 'pip' + EXECUTABLE_FILE_EXTENSION)

VENV_PYINSTALLER = os.path.join(VENV_BIN_DIR, 'pyinstaller' + EXECUTABLE_FILE_EXTENSION)

BUILD_OUTPUT = os.path.join(LOCAL, 'dist/', EXECUTABLE_NAME + EXECUTABLE_FILE_EXTENSION)
Expand Down Expand Up @@ -89,16 +87,18 @@ def parent_dir(path):
return path

def setup_step():
_run(GLOBAL_PYTHON, ['-m', 'pip', 'install', '--upgrade', 'uv'])

print("Creating venv...")

_run(GLOBAL_PYTHON, ['-m', 'venv', 'venv'])
_run(GLOBAL_PYTHON, ['-m', 'uv', 'venv'])

print("Printing some venv debug info...")
_run(VENV_PYTHON, ['--version'])
_run(VENV_PYTHON, ['-c', '"import sys; print(sys.executable)"'])

print("Installing requirements in venv...")
_run(VENV_PIP, ['install', '-r', 'requirements.txt'])
_run(GLOBAL_PYTHON, ['-m', 'uv', 'sync'])

print("Downloading external requirements...")
for url, file in EXTERNAL_DEPENDENCIES.items():
Expand All @@ -118,7 +118,8 @@ def build_step():
print("Running PyInstaller...")
hidden_imports = [f"--hidden-import={i}" for i in HIDDEN_IMPORTS]
data_files = [f"--add-data={i}{PYINSTALLER_SEPARATOR}{parent_dir(i)}" for i in DATA_FILES]
splash = f"--splash {SPLASH_IMAGE}" if sys.platform != 'darwin' else "" # Splash not currently supported on MacOS
#No tkinter support for python 3.12
splash = "" #f"--splash {SPLASH_IMAGE}" if sys.platform != 'darwin' else "" # Splash not currently supported on MacOS
_run(VENV_PYINSTALLER, ['--onefile',
ENTRY_POINT,
'--console',
Expand Down Expand Up @@ -171,8 +172,8 @@ def main(cmd_args):


if __name__ == '__main__':
if not (sys.version_info[0] == 3 and sys.version_info[1] == 7):
raise Exception("Python version is not 3.7")
if not (sys.version_info[0] == 3 and sys.version_info[1] == 12):
raise Exception("Python version is not 3.12")

if _is_venv():
raise Exception("Running in a virtual environment")
Expand Down
26 changes: 15 additions & 11 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ set -o verbose

sudo apt-get update -y

# Install missing packages for qt - libxcb-iccm4.so not found
sudo apt-get install libxcb-xinerama0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xkb1 libxcb-shape0 libxkbcommon-x11-0

# Needed for unit testing with qt https://github.com/pytest-dev/pytest-qt/issues/293
sudo apt-get install -y xvfb libxkbcommon-x11-0
sudo Xvfb :1 -screen 0 1024x768x24 </dev/null &
Expand All @@ -20,8 +23,8 @@ export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"

# Start setting up Python for GS
sudo apt-get install -y tk-dev
env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.7.9
pyenv global 3.7.9
env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install -s 3.12
pyenv global 3.12
python --version
python -m pip install --upgrade pip setuptools wheel

Expand All @@ -47,20 +50,21 @@ cd ../../..
cd UBCRocketGroundStation

# Unit tests & integration tests
source venv/bin/activate
source .venv/bin/activate
mkdir test_reports
mkdir test_coverage

# Unit
coverage run --omit 'venv/*' -m pytest --durations=0 --junitxml=test_reports/unit-test-results.xml --ignore=tests/integration_tests tests
coverage report --omit 'venv/*'
coverage xml -o test_reports/unit-test-coverage.xml
head test_reports/unit-test-coverage.xml
coverage run --omit '.venv/*' -m pytest --durations=0 --junitxml=test_reports/unit-test-results.xml --ignore=tests/integration_tests tests
coverage report --omit '.venv/*'
coverage xml -o test_coverage/unit-test-coverage.xml
head test_coverage/unit-test-coverage.xml

# Integration
coverage run --omit 'venv/*' -m pytest --durations=0 --junitxml=test_reports/integ-test-results.xml tests/integration_tests
coverage report --omit 'venv/*'
coverage xml -o test_reports/integ-test-coverage.xml
head test_reports/integ-test-coverage.xml
coverage run --omit '.venv/*' -m pytest --durations=0 --junitxml=test_reports/integ-test-results.xml tests/integration_tests
coverage report --omit '.venv/*'
coverage xml -o test_coverage/integ-test-coverage.xml
head test_coverage/integ-test-coverage.xml

deactivate

Expand Down
28 changes: 28 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[project]
name = "ubcrocketgroundstation"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"coverage==7.6.1",
"mapbox==0.18.1",
"matplotlib==3.9.2",
"numpy==2.1.2",
"orhelper==0.1.3",
"pillow==10.4.0",
"pyinstaller==6.10",
"pylint==3.3.1",
"pyserial==3.5",
"pytest-mock==3.14.0",
"pytest-qt==4.4.0",
"pytest==8.3.3",
"pyqt5==5.15.11",
"setuptools==75.1.0",
"sortedcontainers==2.4.0",
"pyqt5-qt5==5.15.2",
"digi-xbee",
]

[tool.uv.sources]
digi-xbee = { git = "https://github.com/digidotcom/xbee-python", rev = "1.1.1" }
16 changes: 0 additions & 16 deletions requirements.txt

This file was deleted.

4 changes: 2 additions & 2 deletions tests/test_mapbox_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@ def test_gen_stitched_map(self, ubc_tile_grid):
"jpeg", # Needed to make sure MPL doesn't use Pillow and return decimals.
)

ubc_tile_grid.downloadArrayImages()
ubc_tile_grid.downloadArrayImages(overwrite=True)
stitched_map = ubc_tile_grid.genStitchedMap()

# assert_allclose because linux vs. windows can decode the images slightly differently
# https://github.com/python-pillow/Pillow/issues/3833
# https://github.com/python-pillow/Pillow/issues/4686
numpy.testing.assert_allclose(hennings_image[:,:,:3], stitched_map[:,:,:3], rtol=0, atol=20) # Some systems return alpha channels for one and not the other, needs to be removed before comparison
numpy.testing.assert_allclose(hennings_image.astype(numpy.float64)[:,:,:3] * 255, stitched_map[:,:,:3], rtol=0, atol=20) # Some systems return alpha channels for one and not the other, needs to be removed before comparison


def test_point_to_tile(ubc_point_1):
Expand Down
Binary file modified tests/test_mapbox_utils/41322_89729.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/test_mapbox_utils/output_18_41321-41323_89729-89730.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading