-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
79c5a51
commit b5a53e4
Showing
11 changed files
with
128 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
24.2.0 | ||
24.4.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Copyright 2024 Christopher Barber | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
""" | ||
Utilities for working with wheel files | ||
""" | ||
|
||
import logging | ||
from pathlib import Path | ||
from typing import Optional, Union | ||
from wheel.wheelfile import WheelFile | ||
|
||
__all__ = ["unpack_wheel"] | ||
|
||
def unpack_wheel( | ||
wheel: Union[Path, str], | ||
dest_dir: Union[Path|str], | ||
*, | ||
logger: Optional[logging.Logger] = None | ||
) -> None: | ||
""" | ||
Unpack wheel into specified directory. | ||
Args: | ||
wheel: location of wheel file to unpack | ||
dest_dir: destination directory. | ||
""" | ||
wheel_path = Path(wheel) | ||
dest_path = Path(dest_dir) | ||
dest_path.mkdir(parents=True, exist_ok=True) | ||
|
||
logger = logger or logging.getLogger(__name__) | ||
|
||
with WheelFile(wheel_path) as wf: | ||
for zipinfo in wf.filelist: | ||
extracted = Path(wf.extract(zipinfo, dest_path)) | ||
# copy file permissions (see https://github.com/python/cpython/issues/59999) | ||
# has no effect on Windows | ||
extracted.chmod(zipinfo.external_attr >> 16 & 0o777) | ||
logger.debug("Extracted %s", extracted.relative_to(dest_path)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright 2024 Christopher Barber | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
print("hello world") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,4 +40,5 @@ | |
], | ||
extras_require={'bdev': ['black']}, | ||
packages=["mypkg"], | ||
scripts=["scripts/myscript.py"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Copyright 2024 Christopher Barber | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
""" | ||
Unit tests for the whl2conda.impl.wheel module | ||
""" | ||
import platform | ||
import stat | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from whl2conda.impl.wheel import unpack_wheel | ||
|
||
from ..test_packages import setup_wheel | ||
|
||
def test_unpack_wheel( | ||
tmp_path: Path, | ||
caplog: pytest.LogCaptureFixture, | ||
setup_wheel: Path, | ||
) -> None: | ||
""" | ||
Unit test for unpack_wheel | ||
""" | ||
|
||
unpack_wheel(setup_wheel, tmp_path) | ||
|
||
if not platform.system() == "Windows": | ||
# Regression case for #135 | ||
script_paths = list(tmp_path.rglob("**/scripts/*.py")) | ||
assert script_paths | ||
for script_path in script_paths: | ||
assert script_path.stat().st_mode & stat.S_IXUSR |