nix-community / nixpkgs-pytools

Tools for removing the tedious nature of creating nixpkgs derivations [maintainer=@costrouc]
MIT License
45 stars 9 forks source link

ValueError: could not determine extension of package #13

Closed tbenst closed 1 year ago

tbenst commented 4 years ago

Such a great package--thanks for this!

here's the error:

❯ python-package-init --nixpkgs-root .  test-tube                              
Fetching package="test-tube" version="stable"
Traceback (most recent call last):
  File "/nix/store/ddc5pd1f8iasdikwq7l2mxs427g14687-python3.7-nixpkgs-pytools-1.3.0/bin/.python-package-init-wrapped", line 9, in <module>
    sys.exit(main())
  File "/nix/store/ddc5pd1f8iasdikwq7l2mxs427g14687-python3.7-nixpkgs-pytools-1.3.0/lib/python3.7/site-packages/nixpkgs_pytools/python_package_init.py", line 34, in main
    args.nixpkgs_root,
  File "/nix/store/ddc5pd1f8iasdikwq7l2mxs427g14687-python3.7-nixpkgs-pytools-1.3.0/lib/python3.7/site-packages/nixpkgs_pytools/python_package_init.py", line 66, in initialize_package
    metadata = package_json_to_metadata(data, package_name, version)
  File "/nix/store/ddc5pd1f8iasdikwq7l2mxs427g14687-python3.7-nixpkgs-pytools-1.3.0/lib/python3.7/site-packages/nixpkgs_pytools/python_package_init.py", line 111, in package_json_to_metadata
    package_version,
  File "/nix/store/ddc5pd1f8iasdikwq7l2mxs427g14687-python3.7-nixpkgs-pytools-1.3.0/lib/python3.7/site-packages/nixpkgs_pytools/utils.py", line 10, in determine_filename_extension
    raise ValueError("could not determine extension of package: {filename}".format(filename=filename))
ValueError: could not determine extension of package: test_tube-0.7.5.tar.gz
makefu commented 4 years ago

looks like the package name test-tube does not match what is found on pypi (test_tube).

Update: seems like the offending code is:

        "extension": determine_filename_extension(
            package_release_json["filename"], # "test_tube-0.7.5.tar.gz"
            package_json["info"]["name"], # "test-tube"
            package_version, # 0.7.5
        ),

Source: https://pypi.org/pypi/test-tube/json

The package info and the release info do not fit nicely ...

alexvorobiev commented 4 years ago

I am getting this error (I think for the same reason) on a couple other packages: rsconnect-python, rsconnect-jupyter...

makefu commented 4 years ago

that is really unfortunate and as you said there are a couple of packages which do this. On Error we could perform a second lookup in the pypi overview page or we could simply guess the name by replacing the first - with a _. Pull-Requests are highly appreciated for this issue :)

tbenst commented 4 years ago

I believe this is the same issue encountered here, to make sure that insight is shared both ways :) https://github.com/DavHau/pypi-crawlers/issues/5#issuecomment-653484997

makefu commented 1 year ago

be sure to check out nix-init, it handles a lot of these cases better