0

I am developing a Python package and aiming to publish it on PyPI. The setup.py file of the package is structured as follows: Note: I'm trying to install it from a wheel.


from setuptools import find_packages, setup
from pathlib import Path
from setuptools.command.install import install
import subprocess

this_directory = Path(__file__).parent
long_description = (this_directory / "README.md").read_text()

setup(
    name='mylib',
    packages=find_packages(include=['mylib']),
    version='0.2.5',
    description='my-lib-desc',
    author='my-name',
    license='MIT',
    install_requires=["neuralcoref", "spacy==2.1.0", "allennlp", "allennlp-models", "pandas", "openai"],
    setup_requires=['pytest-runner', "spacy== 2.1.0"],
    tests_require=['pytest==4.4.1'],
    test_suite='tests',
    long_description=long_description,
    long_description_content_type='text/markdown',
    download_url='https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.1.0/en_core_web_sm-2.1.0.tar.gz'
)

print("Installing packages...")
try:
    subprocess.check_call(["pip", "install", "https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.1.0/en_core_web_sm-2.1.0.tar.gz", "--no-deps"])
except subprocess.CalledProcessError as error:
    print(f"Failed to install en_core_web_sm: {error}")

I have added the en_core_web_sm dependency, but it is not getting installed during the package installation process. I have tried installing it using the download_url attribute and by adding it to the install_requires attribute but it fails to install. No error message is thrown during the installation process.

Alternatively, I have also tried the following and this as well fails to install

setup(
    name='mylib',
    packages=find_packages(include=['mylib']),
    version='0.2.5',
    description='my-lib-desc',
    author='my-name',
    license='MIT',
    download_url='https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.1.0/en_core_web_sm-2.1.0.tar.gz',
    install_requires=["neuralcoref", "spacy==2.1.0", "allennlp", "allennlp-models", "pandas", "openai", "en_core_web_sm-2.1.0.tar.gz],
    setup_requires=['pytest-runner', "spacy== 2.1.0"],
    tests_require=['pytest==4.4.1'],
    test_suite='tests',
    long_description=long_description,
    long_description_content_type='text/markdown',
   
)

Could you help me understand why en_core_web_sm is not being installed and suggest a solution?

  • https://stackoverflow.com/search?q=%5Bsetuptools%5D+post-install – phd May 05 '23 at 17:23
  • Note: The solution at the duplicate question only works when installing a **source distribution zip or tarball**, or installing in editable mode from a source tree. **It will not work when installing from a binary wheel (`.whl`)** – phd May 05 '23 at 17:24
  • This shouldn't be done as a post-install script. You can specify models as requirements. For v2: https://v2.spacy.io/usage/models#models-download – aab May 05 '23 at 18:07

0 Answers0