Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

import module after pip install wheel

I have a customized built module, lets call it abc, and pip install /local_path/abc-0.1-py3-none-any.whl. Installation is correct,

>>pip install dist/abc-0.1-py3-none-any.whl
Processing ./dist/abc-0.1-py3-none-any.whl
Successfully installed abc-0.1

but I could not import the module. After I ran ppip freeze list and found out the name of module in list is abc @ file:///local_path/abc-0.1-py3-none-any.whl.
my question is how could import the module? Thank you

.
├── requirements.txt
├── setup.py
├── src
│   ├── bin
│   │   ├── __init__.py
│   │   ├── xyz1.py
│   │   ├── xyz2.py
│   │   └── xyz3.py

here is my setup.py

with open("requirements.txt") as f:
    install_requires = f.read()

setup(
    name="abc",
    version="0.1",
    author="galaxyan",
    author_email="[email protected]",
    description="test whell framework",
    packages=find_packages(include=["src"]),
    zip_safe=False,
    install_requires=install_requires,
)

############ update ############
it does not work even change setup.py

with open("requirements.txt") as f:
    install_requires = f.read()

setup(
    name="abc",
    version="0.1",
    author="galaxyan",
    author_email="[email protected]",
    description="test whell framework",
    packages=find_packages(where="src"),
    package_dir={"": "src"},
    zip_safe=False,
    install_requires=install_requires,
)
like image 606
galaxyan Avatar asked Sep 15 '25 03:09

galaxyan


1 Answers

The setup.py is wrong, which means you're building a wheel with no packages actually inside.

Instead of

setup(
    ...
    packages=find_packages(include=["src"]),
    ...
)

Try this:

setup(
    ...
    packages=find_packages(where="src"),
    package_dir={"": "src"},
    ...
)

See Testing & Packaging for more info.

like image 145
wim Avatar answered Sep 17 '25 18:09

wim