Skip to content

Commit

Permalink
Merge pull request #89 from zuzukin/license-files
Browse files Browse the repository at this point in the history
License files
  • Loading branch information
analog-cbarber authored Sep 14, 2023
2 parents e3c09f3 + 0f4aa45 commit 58fcf96
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 12 deletions.
21 changes: 21 additions & 0 deletions doc/limitations.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,27 @@ whl2conda mywheel-1.2.3-py3-none-any.whl -D foo -A 'foo >=1.2.3,1.2.*'
This will be fixed in a future release
(see [issue 84](https://github.com/zuzukin/whl2conda/issues/84)).

## whl2conda install does not create entry points

The `whl2conda install` command depends on `conda install` to
install the package file, and that apparently does not create
entry points declared in the package. For instance, if you
have a package that normally provides a command line program
`mycli`, that will not be available after this install.

If your package has a suitable main module, then you should still
be able to invoke your program using `python -m`, e.g.:

```bash
python -m mycli
```

This will be fixed in a future release (see [issue #88](https://github.com/zuzukin/whl2conda/issues/88)).

Note that this is only an issue with this installation technique.
There is no problem with packages built by this tool that are
installed from an indexed channel.

## Cannot convert from sdist

Currently, only conversion from wheels is supported. Conversion from python sdist
Expand Down
2 changes: 1 addition & 1 deletion src/whl2conda/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
23.8.8
23.8.9
21 changes: 21 additions & 0 deletions src/whl2conda/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2023 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.
#
"""
Main module allows invocation using `python -m whl2conda`
"""
from .cli.main import main

if __name__ == "__main__":
main()
39 changes: 28 additions & 11 deletions src/whl2conda/api/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,18 +562,35 @@ def _copy_site_packages(self, wheel_dir: Path, conda_dir: Path) -> list[str]:
return rel_files

def _copy_licenses(self, conda_info_dir: Path, wheel_md: MetadataFromWheel) -> None:
if license_files := wheel_md.md.get("license-file"):
from_license_dir = wheel_md.wheel_info_dir.joinpath("licenses")
to_license_dir = conda_info_dir.joinpath("licenses")
for license_file in license_files:
to_license_dir = conda_info_dir / "licenses"
wheel_info_dir = wheel_md.wheel_info_dir
wheel_license_dir = wheel_info_dir / "licenses"
if wheel_license_dir.is_dir():
# just copy directory
shutil.copytree(
wheel_license_dir,
to_license_dir,
dirs_exist_ok=True,
)
else:
# Otherwise look for files in the dist-info dir
# that match the license-file entries. The paths
# of the license-file entries may be relative to
# where the wheel was built and may not directly
# point at the files.
for license_file in wheel_md.md.get("license-file", ()):
# copy license file if it exists
for from_dir in [from_license_dir, wheel_md.wheel_info_dir]:
from_file = from_dir.joinpath(license_file)
if from_file.is_file():
to_file = to_license_dir.joinpath(license_file)
to_license_dir.mkdir(parents=True, exist_ok=True)
shutil.copyfile(from_file, to_file)
break
license_path = Path(license_file)
from_files = [wheel_info_dir / license_path.name]
if not license_path.is_absolute():
from_files.insert(0, wheel_info_dir / license_path)
for from_file in from_files:
if from_file.exists():
to_file = to_license_dir / from_file.relative_to(wheel_info_dir)
if not to_file.exists():
to_file.parent.mkdir(parents=True, exist_ok=True)
shutil.copyfile(from_file, to_file)
break

# pylint: disable=too-many-locals, too-many-statements
def _parse_wheel_metadata(self, wheel_dir: Path) -> MetadataFromWheel:
Expand Down

0 comments on commit 58fcf96

Please sign in to comment.