Skip to content

Commit

Permalink
Merge branch 'main' into return_1_remote_builds_failed
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-cal authored Oct 19, 2023
2 parents 760d557 + 2d59662 commit c2b8cc0
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ craft-archives==1.1.3
craft-cli==2.1.0
craft-grammar==1.1.1
craft-parts==1.25.1
craft-providers==1.15.0
craft-providers==1.18.0
craft-store==2.4.0
Deprecated==1.2.13
distro==1.8.0
Expand Down
2 changes: 1 addition & 1 deletion requirements-devel.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ craft-archives==1.1.3
craft-cli==2.1.0
craft-grammar==1.1.1
craft-parts==1.25.1
craft-providers==1.15.0
craft-providers==1.18.0
craft-store==2.4.0
cryptography==41.0.4
Deprecated==1.2.13
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ craft-archives==1.1.3
craft-cli==2.1.0
craft-grammar==1.1.1
craft-parts==1.25.1
craft-providers==1.15.0
craft-providers==1.18.0
craft-store==2.4.0
cryptography==41.0.4
Deprecated==1.2.13
Expand Down
6 changes: 4 additions & 2 deletions snapcraft/elf/_elf_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,9 @@ def is_linker_compatible(self, *, linker_version: str) -> bool:
"""Determine if the linker will work given the required glibc version."""
version_required = self.get_required_glibc()
# TODO: pkg_resources is deprecated in setuptools>66 (CRAFT-1598)
is_compatible = parse_version(version_required) <= parse_version(linker_version)
parsed_version_required = parse_version(version_required) # type: ignore
parsed_linker_version = parse_version(linker_version) # type: ignore
is_compatible = parsed_version_required <= parsed_linker_version
emit.debug(
f"Check if linker {linker_version!r} works with GLIBC_{version_required} "
f"required by {str(self.path)!r}: {is_compatible}"
Expand All @@ -341,7 +343,7 @@ def get_required_glibc(self) -> str:
continue
version = version[6:]
# TODO: pkg_resources is deprecated in setuptools>66 (CRAFT-1598)
if parse_version(version) > parse_version(version_required):
if parse_version(version) > parse_version(version_required): # type: ignore
version_required = version

self._required_glibc = version_required
Expand Down
6 changes: 4 additions & 2 deletions snapcraft_legacy/plugins/v2/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
It can be used for python projects where you would want to do:
- import python modules with a requirements.txt
- build a python project that has a setup.py
- build a python project that has a setup.py or pyproject.toml file
- install packages straight from pip
This plugin uses the common plugin keywords as well as those for "sources".
Expand Down Expand Up @@ -140,7 +140,9 @@ def get_build_commands(self) -> List[str]:
requirements_cmd = f"pip install {constraints} -U {requirements}"
build_commands.append(requirements_cmd)

build_commands.append(f"[ -f setup.py ] && pip install {constraints} -U .")
build_commands.append(
f"[ -f setup.py -o -f pyproject.toml ] && pip install {constraints} -U ."
)

# Now fix shebangs.
# TODO: replace with snapcraftctl once the two scripts are consolidated
Expand Down
4 changes: 2 additions & 2 deletions tests/legacy/unit/plugins/v2/test_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class Options:
== [
'"${SNAPCRAFT_PYTHON_INTERPRETER}" -m venv ${SNAPCRAFT_PYTHON_VENV_ARGS} "${SNAPCRAFT_PART_INSTALL}"',
'SNAPCRAFT_PYTHON_VENV_INTERP_PATH="${SNAPCRAFT_PART_INSTALL}/bin/${SNAPCRAFT_PYTHON_INTERPRETER}"',
"[ -f setup.py ] && pip install -U .",
"[ -f setup.py -o -f pyproject.toml ] && pip install -U .",
]
+ _FIXUP_BUILD_COMMANDS
)
Expand All @@ -134,7 +134,7 @@ class Options:
'SNAPCRAFT_PYTHON_VENV_INTERP_PATH="${SNAPCRAFT_PART_INSTALL}/bin/${SNAPCRAFT_PYTHON_INTERPRETER}"',
"pip install -c 'constraints.txt' -U pip 'some-pkg; sys_platform != '\"'\"'win32'\"'\"''",
"pip install -c 'constraints.txt' -U -r 'requirements.txt'",
"[ -f setup.py ] && pip install -c 'constraints.txt' -U .",
"[ -f setup.py -o -f pyproject.toml ] && pip install -c 'constraints.txt' -U .",
]
+ _FIXUP_BUILD_COMMANDS
)
1 change: 1 addition & 0 deletions tests/spread/plugins/v2/build-and-run-hello/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ environment:
SNAP/python: python-hello
SNAP/python_multiple_parts: python-hello-multiple-parts
SNAP/python_multiple_parts_staged: python-hello-multiple-parts-staged
SNAP/python_pyproject: python-hello-pyproject
SNAP/python_staged: python-hello-staged-python
SNAP/python_with_stage_package_in_base: python-with-stage-package-in-base
SNAP/python_with_python_package_dep: python-hello-with-python-package-dep
Expand Down
2 changes: 2 additions & 0 deletions tests/spread/plugins/v2/snaps/python-hello-pyproject/hello
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def main():
print("hello world")
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "python_hello_pyproject"
description = "A simple hello world in python"
version = "0.0.1"

[project.scripts]
python-hello-pyproject = "pythonhellopyproject:main"
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: python-hello-pyproject
version: "1.0"
summary: hello world
description: A simple hello world in python using a pyproject.toml.
grade: devel
base: core20
confinement: strict

apps:
python-hello-pyproject:
command: bin/python-hello-pyproject

parts:
hello:
source: .
plugin: python
python-packages:
- pip==20.0.2
2 changes: 1 addition & 1 deletion tests/unit/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def test_project_grade_assignment(self, grade, project_yaml_data):
else:
error = ".*unexpected value; permitted: 'stable', 'devel'"
with pytest.raises(pydantic.ValidationError, match=error):
project.grade = grade
project.grade = grade # type: ignore

def test_project_summary_valid(self, project_yaml_data):
summary = "x" * 78
Expand Down

0 comments on commit c2b8cc0

Please sign in to comment.