Написал pip пакет под версию 2.7. Все работает как надо.
Сейчас пытаюсь перевести под 3.* версию и ловлю ошибку при проверке
python3 setup.py check.
Структура пакета:
├── gendocs.sh
├── LICENSE
├── MANIFEST.in
├── pygetwallpapers
│ ├── __init__.py <-- Вот в этом файле ошибка импорта модуля pgw
│ ├── pgw.py
│ ├── pgw_tools
│ │ ├── constants.py
│ │ ├── functions.py
│ │ └── __init__.py
│ └── spiders
│ ├── __init__.py
│ └── wallpaperscraft.py
├── README.md
├── README.rst
└── setup.py
Вот его содержимое:
#!/usr/bin/python3
# -*- coding: utf-8
from pgw import run
from pgw_tools.constants import PKG
__all__ = ['run', 'PKG']
__name__ = "pygetwallpapers"
__doc__ = """Main package for pygetwallpapers"""
При всем при этом до смены интерпритатора все работало нормально.
Содержимое setup.py:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))
from distutils.core import setup
from pkgutil import walk_packages
def find_packages(path="", prefix=""):
yield prefix
prefix = prefix + "."
for _, name, ispkg in walk_packages(path, prefix):
if ispkg:
yield name
from pygetwallpapers import PKG
NAME = PKG['NAME']
VERSION = PKG['VERSION']
AUTHOR = PKG['AUTHOR']
AUTHOR_EMAIL = PKG['AUTHOR_EMAIL']
LICENSE = PKG['LICENSE']
URL = PKG['GITHUB_URL']
DESCRIPTION = "Package for download wallpapers from websites. Read help: %s" % PKG[
'GITHUB_URL']
try:
README = open(os.path.join(os.path.dirname(__file__), 'README.rst')).read()
except:
README = open(os.path.join(os.path.dirname(__file__), 'README.md')).read()
setup(
name=NAME,
version=VERSION,
description=DESCRIPTION,
long_description=README,
author=AUTHOR,
author_email=AUTHOR_EMAIL,
license=LICENSE,
url=URL,
packages=list(find_packages(os.path.dirname(__file__), NAME)),
include_package_data=True,
install_requires=['grab==0.6.30'],
keywords=[PKG['BIN_NAME'], PKG['NAME'], 'python get image', 'python load image',
'python get wallpapers', 'load wallpapers', 'wallpaper', 'get wallpapers', 'wallpapers download'],
entry_points={
"console_scripts":
["%s = %s:run" % (PKG['BIN_NAME'], PKG['NAME'])]
},
classifiers=[
'Environment :: Console',
'Intended Audience :: Developers',
'Intended Audience :: End Users/Desktop',
'License :: OSI Approved :: MIT License',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Natural Language :: English',
'Natural Language :: Russian',
'Topic :: Internet :: WWW/HTTP :: Site Management :: Link Checking'
]
)
Текст ошибки:
Traceback (most recent call last):
File "setup.py", line 19, in <module>
from pygetwallpapers import PKG
File "/github/pygetwallpapers/pygetwallpapers/__init__.py", line 4, in <module>
from pgw import run
ImportError: No module named 'pgw'