Search code examples
setuptoolspython-packagingpyproject.toml

My python package not installing dependent packages when my package is installed


I'm building a python package and have listed all of my dependent packages in a few different places... which I feel is probably redundant to achieve what I'm trying to. When I install my package, my dependencies are not being installed. super grateful for the assistance.

My package structure looks like this

root v
     src
        v
        ... (project files)
        setup.py
        setup.cfg
        requirements
                   v
                   requirements.txt
      pyproject.toml

my setup.py, setup.cfg, and pyproject.toml are pretty much synonymous, below is the content

setup.cfg

[metadata]
name = t-extractlib
version = 0.0.5
author = Trae Moore
author_email = my.email@gmail.com
description = A package standardized for extracting data from PDFs
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/traemoore/extractlib
license = MIT
classifiers =
    Programming Language :: Python :: 3
    License :: OSI Approved :: MIT License
    Operating System :: OS Independent

[options]
packages = find:
install_requires =
    nltk==3.8.1
    PyMuPDF==1.21.1
    camelot-py==0.11.0
    opencv-python==4.7.0.72
    ghostscript==0.7
python_requires = >=3.10
           

setup.py

from setuptools import setup, find_packages

with open("README.md", "r", encoding="utf-8") as fh:
    long_description = fh.read()

setup(
    name="t-extractlib",
    version="0.0.5",
    author="Trae Moore",
    author_email="my.email@gmail.com",
    description="A package standardized for extracting data from PDFs",
    long_description=long_description,
    long_description_content_type="text/markdown",
    url="https://github.com/traemoore/extractlib",
    project_urls={
        "Bug Tracker": "https://github.com/traemoore/extractlib/issues",
    },
    classifiers=[
        "Programming Language :: Python :: 3",
        "License :: OSI Approved :: MIT License",
        "Operating System :: OS Independent",
    ],
    packages=find_packages(),
    install_requires=[
        "setuptools>=61.0",
        "nltk==3.8.1",
        "PyMuPDF==1.21.1",
        "camelot-py==0.11.0",
        "opencv-python==4.7.0.72",
        "ghostscript==0.7"
    ],
    python_requires=">=3.10",
 )`

pyproject.toml

[build-system]
requires = [
    "setuptools>=61.0",
    "nltk==3.8.1",
    "PyMuPDF==1.21.1",
    "camelot-py==0.11.0",
    "opencv-python==4.7.0.72",
    "ghostscript==0.7"
]
build-backend = "setuptools.build_meta"

[project]
name = "t-extractlib"
version = "0.0.5"
authors = [
  { name="Trae Moore", email="my.email@gmail.com" },
]
description = "A package standardized for extracting data from 
PDFs"
readme = "README.md"
 requires-python = ">=3.10"
 classifiers = [
    "Programming Language :: Python :: 3",
    "License :: OSI Approved :: MIT License",
    "Operating System :: OS Independent",
]

[project.urls]
 "Homepage" = "https://github.com/traemoore/extractlib"
 "Bug Tracker" = "https://github.com/traemoore/extractlib/issues"

here is an image of my directory structure

enter image description here

I have pushed the latest to https://github.com/traemoore/extractlib if you need to pull it down.


Solution

  • Per this setuptools documentation, you're not correctly setting the dependencies for the project; it needs to go under the [project] heading. You've currently got them under the [build-system], which means they get installed in the virtual environment used to build your project, not in the environment to run it.

    It's also not really a good idea to have all three of those simultaneously. You can delete the setup.py and setup.cfg, and use only the pyproject.toml file, which is considered the standard form of specifying project metadata in Python now.

    Here's the PEP for the [build-system] that you are using

    Here's the PEP for project metadata in pyproject.toml file