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

build: update install constraints on numpy and qt packages #1157

Merged
merged 3 commits into from
Jul 18, 2024
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
4 changes: 2 additions & 2 deletions .azure-pipelines/pyinstaller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ parameters:
type: string

steps:
- {task: UsePythonVersion@0, inputs: {versionSpec: '3.9', architecture: x64}}
- {task: UsePythonVersion@0, inputs: {versionSpec: '3.11', architecture: x64}}
- template: pip_cache.yaml
parameters:
key: pyinstaller | requirements/constraints_py3.9.txt | "$(Agent.OS)" | "$(PY)"
path: ${{ parameters.cache_dir }}
- bash: |
python -m pip install -U pip wheel setuptools
displayName: install libs
- bash: python -m pip install .[pyinstaller] -c requirements/constraints_py3.9.txt
- bash: python -m pip install .[pyinstaller] -c requirements/constraints_py3.11.txt
displayName: install partseg
- bash: |
python build_utils/create_and_pack_executable.py --no-simple-zip
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test_prereleases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: [windows-2022, macos-12, ubuntu-22.04]
python: [3.9]
platform: [windows-2022, macos-14, ubuntu-22.04]
python: [3.12]
steps:
- uses: actions/checkout@v4

Expand Down
18 changes: 18 additions & 0 deletions build_utils/pyproject_toml_to_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,27 @@
base_dir = Path(__file__).parent.parent
pyproject_toml = base_dir / "pyproject.toml"


def drop_line(line):
if "python_version < '3.10'" in line:
return False

if "python_version < '3.11'" in line: # noqa: SIM103
return False

return True
Comment on lines +9 to +16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optimize the conditional statements in drop_line.

You can combine the conditions into a single statement for better readability and performance.

- def drop_line(line):
-    if "python_version < '3.10'" in line:
-        return False
-    if "python_version < '3.11'" in line:  # noqa: SIM103
-        return False
-    return True
+ def drop_line(line):
+    if "python_version < '3.10'" in line or "python_version < '3.11'" in line:  # noqa: SIM103
+        return False
+    return True
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def drop_line(line):
if "python_version < '3.10'" in line:
return False
if "python_version < '3.11'" in line: # noqa: SIM103
return False
return True
def drop_line(line):
if "python_version < '3.10'" in line or "python_version < '3.11'" in line: # noqa: SIM103
return False
return True



def remove_specifier(line: str):
if ";" in line:
return line.split(";", maxsplit=1)[0]
return line


with pyproject_toml.open("rb") as f:
data = tomllib.load(f)
dependencies = data["project"]["dependencies"]
dependencies = map(remove_specifier, filter(drop_line, dependencies))
dependencies_str = "\n".join([f" - {v}" for v in dependencies])
dependencies_str = dependencies_str.replace("qtconsole", "qtconsole-base")
print(dependencies_str)
2 changes: 1 addition & 1 deletion package/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def bundle_test_dir():

@pytest.fixture()
def image(tmp_path):
data = np.zeros([20, 20, 20, 2], dtype=np.uint8)
data = np.zeros([20, 20, 20, 2], dtype=np.uint16)
data[10:-1, 1:-1, 1:-1, 0] = 20
data[1:10, 1:-1, 1:-1, 1] = 20
data[1:-1, 1:5, 1:-1, 1] = 20
Expand Down
11 changes: 8 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ dependencies = [
"mahotas>=1.4.10",
"napari>=0.4.14",
"nme>=0.1.7",
"numpy>=1.18.5",
"numpy>=1.18.5 ; python_version >= '3.10'",
"numpy>=1.18.5, <2 ; python_version < '3.10'",
"oiffile>=2020.1.18",
"openpyxl>=2.5.7",
"packaging>=20.0",
Expand Down Expand Up @@ -119,22 +120,26 @@ pyinstaller_base = [
"pydantic",
]
pyqt = [
"PyQt5!=5.15.0,>=5.12.3",
"PartSeg[pyqt5]",
]
pyqt5 = [
"PyQt5!=5.15.0,>=5.12.3",
"napari[pyqt5]",
]
pyqt6 = [
"PyQt6",
"napari[pyqt6]",
]
pyside = [
"PySide2!=5.15.0,>=5.12.3",
"PartSeg[pyside2]",
]
pyside2 = [
"PySide2!=5.15.0,>=5.12.3",
"napari[pyside]",
]
pyside6 = [
"PySide6",
"napari[pyside6_experimental]",
]
test = [
"coverage",
Expand Down
Loading