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

feat: Differentiate packages #2390

Draft
wants to merge 11 commits into
base: develop
Choose a base branch
from
Draft
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
5 changes: 5 additions & 0 deletions conda_recipe/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
localbuild is mainly a copy of the build instructions from
https://github.com/conda-forge/mss-feedstock/tree/master/recipe

You may want to copy this directory to a different directory on your system
and alter it for your needs.
7 changes: 7 additions & 0 deletions conda_recipe/bld.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mkdir "%PREFIX%\Menu"
copy /Y "%RECIPE_DIR%\menu.json" "%PREFIX%\Menu\%PKG_NAME%_menu.json"
copy /Y "%RECIPE_DIR%\msui.ico" "%PREFIX%\Menu\msui.ico"

; conda-build issue 5311, currently we can't build for windows with pip install
%PYTHON% setup.py install --single-version-externally-managed --record record.txt
if errorlevel 1 exit 1
7 changes: 7 additions & 0 deletions conda_recipe/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

mkdir -p "${PREFIX}/Menu"
cp "${RECIPE_DIR}/menu.json" "${PREFIX}/Menu/${PKG_NAME}_menu.json"
cp "${RECIPE_DIR}/msui.png" "${PREFIX}/Menu/msui.png"

"${PYTHON}" -m pip install . --no-deps -vv
19 changes: 19 additions & 0 deletions conda_recipe/build_mswms_setuppy.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
diff --git a/setup.py b/setup.py
index c0f80484..31408355 100644
--- a/setup.py
+++ b/setup.py
@@ -34,14 +34,8 @@ long_description = open('README.md').read()
execfile('mslib/version.py')

console_scripts = [
- "mscolab = mslib.mscolab.mscolab:main",
- "mss = mslib.msui.mss:main",
- "mssautoplot = mslib.utils.mssautoplot:main",
- "msui = mslib.msui.msui:main",
"mswms = mslib.mswms.mswms:main",
"mswms_demodata = mslib.mswms.demodata:main"]
-if os.name != 'nt':
- console_scripts.append('msidp = mslib.msidp.idp:main')

setup(
name="mss",
54 changes: 54 additions & 0 deletions conda_recipe/menu.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"$schema": "https://json-schema.org/draft-07/schema",
"$id": "https://schemas.conda.io/menuinst-1.schema.json",
"menu_name": "Mission Support System",
"menu_items": [
{
"name": "MSUI ({{ ENV_NAME }})",
"description": "Mission Support System MSUI",
"activate": true,
"icon": "{{ MENU_DIR }}/msui.{{ ICON_EXT }}",
"command": [
"{{ PYTHON }}",
"{{ PREFIX }}/bin/msui"
],
"platforms": {
"win": {
"command": [
"{{ PYTHON }}",
"{{ SCRIPTS_DIR }}/msui-script.py"
],
"file_extensions": [".menuinst"]
},
"linux": {
"Categories": ["Internet", "Science"],
"Keywords": ["documentation", "information"],
"StartupNotify": true,
"MimeType": ["application/x-menuinst"],
"glob_patterns": {
"application/x-menuinst": "*.menuinst"
}
},
"osx": {
"CFBundleDocumentTypes": [
{
"CFBundleTypeName": "org.conda.menuinst.msui",
"CFBundleTypeRole": "Viewer",
"LSItemContentTypes": ["org.conda.menuinst.main-file-uti"],
"LSHandlerRank": "Default"
}
],
"UTExportedTypeDeclarations": [
{
"UTTypeConformsTo": ["public.data", "public.content"],
"UTTypeIdentifier": "org.conda.menuinst.main-file-uti",
"UTTypeTagSpecification": {
"public.filename-extension": ["menuinst"]
}
}
]
}
}
}
]
}
91 changes: 91 additions & 0 deletions conda_recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@

{% set module = environ.get('MODULE', 'mss') %}
{% set project = load_file_data('requirements.d/mscolab.toml', from_recipe_dir=False).get('project') %}
{% set name = project.get('name') %}
{% set summary = project.get('description') %}

{% set version = project.get('version') %}
{% set maintainers = project.get('maintainers') %}

{% set source_patches = project.get('source_patches') %}

{% set build_deps = project.get('build_dependencies') %}
{% set host_deps = project.get('host_dependencies') %}
{% set run_deps = project.get('dependencies') %}
{% set run_constrained = project.get('run_constrained') %}


{% set test_imports = project.get('test_imports') %}
{% set test_commands = project.get('test_commands') %}

package:
name: {{ name }}
version: {{ version }}

source:
path: ../
patches:
{% for patch in source_patches %}
- {{ patch }}
{% endfor %}

build:
number: 0

requirements:
build:
{% for dep in build_deps %}
- {{ dep }}
{% endfor %}
host:
{% for dep in host_deps %}
- {{ dep }}
{% endfor %}
run:
{% for dep in run_deps %}
- {{ dep }}
{% endfor %}
run_constrained:
{% for dep in run_constrained %}
- {{ dep }}
{% endfor %}

test:
imports:
{% for imp in test_imports %}
- {{ imp }}
{% endfor %}
commands:
{% for cmd in test_commands %}
- {{ cmd }}
{% endfor %}
about:
summary: {{ summary }}
home: https://github.com/open-mss/MSS
license: Apache-2.0
license_family: APACHE
license_file: LICENSE
description: |
MSS - Mission Support System

Documentation:
* https://mss.rtfd.io
* https://gmd.copernicus.org/articles/15/8983/2022/gmd-15-8983-2022.pdf
* http://www.geosci-model-dev.net/5/55/2012/gmd-5-55-2012.pdf

Software for planning research Aircraft Missions.
For discussion of the possibilites of the research flights,
the Mission Support System (MSS) was developed.
This software helps to review a big amount of metereological and
model project by viewing the forecasted parameters of interest along possible regions
of a proposed flight path. Data and possible flight paths can
be displayed on a hoizontal view (map projection) or on a vertical
view (along the proposed flight path). Flight paths can be constructed
and modified on these views. Exchange through a waypoint table is also possible.

extra:
recipe-maintainers:
{% for maintainer in maintainers %}
- {{ maintainer.get('name') }}
{% endfor %}

Binary file added conda_recipe/msui.ico
Binary file not shown.
Binary file added conda_recipe/msui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
86 changes: 51 additions & 35 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,47 +36,57 @@
import pytest
import fs
import shutil
import keyring
from mslib.mswms.demodata import DataFiles
try:
import keyring
except ModuleNotFoundError:
keyring = None
try: # mscolab
from mslib.mswms.demodata import DataFiles
except ModuleNotFoundError:
DataFiles = None
import tests.constants as constants
from mslib.utils.loggerdef import configure_mpl_logger

matplotlib_logger = configure_mpl_logger()

# This import must come after importing tests.constants due to MSUI_CONFIG_PATH being set there
from mslib.utils.config import read_config_file
try:
# This import must come after importing tests.constants due to MSUI_CONFIG_PATH being set there
from mslib.utils.config import read_config_file
except ModuleNotFoundError:
read_config_file = None


class TestKeyring(keyring.backend.KeyringBackend):
"""A test keyring which always outputs the same password
from Runtime Configuration
https://pypi.org/project/keyring/#third-party-backends
"""
priority = 1
if keyring is not None:
class TestKeyring(keyring.backend.KeyringBackend):
"""A test keyring which always outputs the same password
from Runtime Configuration
https://pypi.org/project/keyring/#third-party-backends
"""
priority = 1

passwords = {}
passwords = {}

def reset(self):
self.passwords = {}
def reset(self):
self.passwords = {}

def set_password(self, servicename, username, password):
self.passwords[servicename + username] = password
def set_password(self, servicename, username, password):
self.passwords[servicename + username] = password

def get_password(self, servicename, username):
return self.passwords.get(servicename + username, "password from TestKeyring")
def get_password(self, servicename, username):
return self.passwords.get(servicename + username, "password from TestKeyring")

def delete_password(self, servicename, username):
if servicename + username in self.passwords:
del self.passwords[servicename + username]
def delete_password(self, servicename, username):
if servicename + username in self.passwords:
del self.passwords[servicename + username]


# set the keyring for keyring lib
keyring.set_keyring(TestKeyring())
# set the keyring for keyring lib
keyring.set_keyring(TestKeyring())


@pytest.fixture(autouse=True)
def keyring_reset():
keyring.get_keyring().reset()
@pytest.fixture(autouse=True)
def keyring_reset():
keyring.get_keyring().reset()


def generate_initial_config():
Expand All @@ -89,7 +99,7 @@ def generate_initial_config():
sample_path = os.path.join(os.path.dirname(__file__), "tests", "data")
shutil.copy(os.path.join(sample_path, "example.ftml"), constants.ROOT_DIR)

if not constants.SERVER_CONFIG_FS.exists(constants.SERVER_CONFIG_FILE):
if DataFiles is not None and not constants.SERVER_CONFIG_FS.exists(constants.SERVER_CONFIG_FILE):
print('\n configure testdata')
# ToDo check pytest tmpdir_factory
examples = DataFiles(data_fs=constants.DATA_FS,
Expand Down Expand Up @@ -211,16 +221,20 @@ def _load_module(module_name, path):
sys.modules[module_name] = module
spec.loader.exec_module(module)


_load_module("mswms_settings", constants.SERVER_CONFIG_FILE_PATH)
if DataFiles is not None:
_load_module("mswms_settings", constants.SERVER_CONFIG_FILE_PATH)
_load_module("mscolab_settings", path)

try: # mscolab
generate_initial_config()
except TypeError:
pass

generate_initial_config()


# This import must come after the call to generate_initial_config, otherwise SQLAlchemy will have a wrong database path
from tests.utils import create_msui_settings_file
try:
# This import must come after the call to generate_initial_config, otherwise SQLAlchemy will have a wrong database path
from tests.utils import create_msui_settings_file
except ModuleNotFoundError:
create_msui_settings_file = None


@pytest.fixture(autouse=True)
Expand All @@ -234,8 +248,10 @@ def reset_config():
constants.ROOT_FS.removedir(e)

generate_initial_config()
create_msui_settings_file("{}")
read_config_file()
if create_msui_settings_file is not None:
create_msui_settings_file("{}")
if read_config_file is not None:
read_config_file()


# Make fixtures available everywhere
Expand Down
12 changes: 0 additions & 12 deletions mslib/mscolab/mscolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
add_all_users_to_all_operations, delete_user
from mslib.mscolab.utils import create_files
from mslib.utils import setup_logging
from mslib.utils.qt import Worker, Updater


def handle_start(args):
Expand Down Expand Up @@ -355,7 +354,6 @@ def handle_sso_metadata_init(repo_exists):
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--version", help="show version", action="store_true", default=False)
parser.add_argument("--update", help="Updates MSS to the newest version", action="store_true", default=False)

subparsers = parser.add_subparsers(help='Available actions', dest='action')

Expand Down Expand Up @@ -405,16 +403,6 @@ def main():
except git.exc.InvalidGitRepositoryError:
repo_exists = False

updater = Updater()
if args.update:
updater.on_update_available.connect(lambda old, new: updater.update_mss())
updater.on_log_update.connect(lambda s: print(s.replace("\n", "")))
updater.on_status_update.connect(lambda s: print(s.replace("\n", "")))
updater.run()
while Worker.workers:
list(Worker.workers)[0].wait()
sys.exit()

if args.action == "start":
handle_start(args)

Expand Down
3 changes: 2 additions & 1 deletion mslib/msui/flighttrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@

from mslib import __version__
from mslib.utils.units import units
from mslib.utils.coordinate import find_location, path_points, get_distance
from mslib.utils.coordinate import path_points, get_distance
from mslib.utils.locations import find_location
from mslib.utils import thermolib
from mslib.utils.config import config_loader, save_settings_qsettings, load_settings_qsettings
from mslib.utils.config import MSUIDefaultConfig as mss_default
Expand Down
3 changes: 2 additions & 1 deletion mslib/msui/mpl_pathinteractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
import matplotlib.patches as mpatches
from PyQt5 import QtCore, QtWidgets

from mslib.utils.coordinate import get_distance, find_location, latlon_points, path_points
from mslib.utils.coordinate import get_distance, latlon_points, path_points
from mslib.utils.locations import find_location
from mslib.utils.units import units
from mslib.utils.thermolib import pressure2flightlevel
from mslib.msui import flighttrack as ft
Expand Down
11 changes: 0 additions & 11 deletions mslib/mswms/mswms.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

from mslib import __version__
from mslib.utils import setup_logging
from mslib.utils.qt import Updater, Worker
from mslib.mswms.wms import app as application


Expand Down Expand Up @@ -87,16 +86,6 @@ def main():
print("Version:", __version__)
sys.exit()

updater = Updater()
if args.update:
updater.on_update_available.connect(lambda old, new: updater.update_mss())
updater.on_log_update.connect(lambda s: print(s.replace("\n", "")))
updater.on_status_update.connect(lambda s: print(s.replace("\n", "")))
updater.run()
while Worker.workers:
list(Worker.workers)[0].wait()
sys.exit()

setup_logging(args)

# keep the import after the version check. This creates all layers.
Expand Down
Loading
Loading