LoginSignup
2
2

More than 3 years have passed since last update.

conda skeletonで`No source urls found for XXXXX`というエラーが出る場合

Last updated at Posted at 2019-06-09

背景

PyPIに登録した自作パッケージmylibraryを、condaパッケージに変換して、condaに登録したいです。

以下のサイトを参考にして、condaパッケージの作成を試みました。
https://qiita.com/iisaka51/items/5828a50744be209705d0

環境

  • conda 4.6.14
  • python 3.6.6
  • Xubuntu 18.04

遭遇した問題

conda skeletonコマンドを実行したら、以下のエラーが発生しました。

$ conda skeleton pypi mylibrary

Leaving build/test directories:
  Work:
 /home/vagrant/miniconda3/conda-bld/skeleton_1560081893777/work 
  Test:
 /home/vagrant/miniconda3/conda-bld/skeleton_1560081893777/test_tmp 
Leaving build/test environments:
  Test:
source activate  /home/vagrant/miniconda3/conda-bld/skeleton_1560081893777/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho 
  Build:
source activate  /home/vagrant/miniconda3/conda-bld/skeleton_1560081893777/_build_env 

Error: No source urls found for mylibrary

mylibraryのソースのURLがないそうです。

エラーの原因を調査

conda-buildのソースを確認

"No source urls found for"でGoogle検索したところ、conda_build関係のソースが見つかりました。

conda-build/conda_build/skeletons/pypi.py
    data = pypi_data['info'] if not is_url else {}

    # PyPI will typically have several downloads (source, wheels) for one
    # package/version.
    urls = [url for url in pypi_data['releases'][version]] if not is_url else [package]

    if not is_url and not all_urls:
        # Try to find source urls
        urls = [url for url in urls if url['packagetype'] == 'sdist']

    if not urls:
        # Try harder for a download location
        if data.get('download_url'):
            urls = [defaultdict(str, {'url': data['download_url']})]
            if not urls[0]['url']:
                # The package doesn't have a url, or maybe it only has a wheel.
                sys.exit("Error: Could not build recipe for %s. "
                    "Could not find any valid urls." % package)
            U = parse_url(urls[0]['url'])
            if not U.path:
                sys.exit("Error: Could not parse url for %s: %s" %
                    (package, U))
            urls[0]['filename'] = U.path.rsplit('/')[-1]
            fragment = U.fragment or ''
            digest = fragment.split("=")
        else:
            sys.exit("Error: No source urls found for %s" % package)

PyPIから取得した情報にdownload_urlがないと、"No source urls found for"というエラーが出るようです。

download_urlを調査

Pythonの公式ドキュメントには、download_urlは「パッケージをダウンロードできる場所」と記載されています。
https://docs.python.org/ja/3/distutils/setupscript.html#additional-meta-data

自作パッケージmylibrarysetup.pyには、download_urlを指定していませんでした。
参考にしていたサイトでは、conda skeleton pypi autopepa8を実行しています。しかしautopepa8setup.pyにもdownload_urlはありませんでした。

PyPIの"Download file"参照

PyPIで、autopepa8"Download file"を見てみると、tar.gzが登録されています。

image.png

私が作成したmylibraryにはwhlファイルはありますが、tar.gzはありません。
どうやら、tar.gzがPyPIにアップロードされていないことが、原因のようです。

原因

PyPIにアップロードする際python setup.py bdist_wheelだけを実行していて、python setup.py sdistを実行していないことが原因でした。

解決方法

PyPIに登録する際は、python setup.py sdist bdist_wheelを実行して、sdistとwheelをPyPIにアップロードするようにしました。
その状態でconda skeletonを実行したら、エラーはなくなりmeta.yamlが生成されました。

参考サイト

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2