Skip to content

define installation requirements in setup.py#11

Closed
thatguy7 wants to merge 1 commit intopaulo-herrera:masterfrom
thatguy7:improve/install_requirements
Closed

define installation requirements in setup.py#11
thatguy7 wants to merge 1 commit intopaulo-herrera:masterfrom
thatguy7:improve/install_requirements

Conversation

@thatguy7
Copy link
Copy Markdown

Hi @paulo-herrera ,

I noticed the installation of the package fails, when following the install instructions but not having the requirements already installed. This change was already proposed in #3 . I consider this a necessity.

The change proposed in this MR makes sure that this package can be properly installed without making assumptions about the pre-existing state of the environment.

@paulo-herrera
Copy link
Copy Markdown
Owner

paulo-herrera commented Jan 22, 2021 via email

@thatguy7
Copy link
Copy Markdown
Author

Hi @paulo-herrera ,

this might work for the specific OS install you have, but it does not hold up in general.

Here are the steps to reproduce the problem (inside the freshly cloned PyEVTK dir):

  1. Create a fresh virtual environment:
$ python -m venv venv
$ source venv/bin/activate
  1. Verify that nothing is installed:
$ pip list
Package    Version
---------- -------
pip        20.2.3
setuptools 49.2.1
  1. Now try to install PyEVTK:
$ python setup.py install
Traceback (most recent call last):
  File "/tmp/PyEVTK/setup.py", line 32, in <module>
    import numpy as np
ModuleNotFoundError: No module named 'numpy'

As you can see, it does not work. The installation fails, because numpy is imported in setup.py.

This is a big problem for anyone, who wants to use your package in a dedicated environment as is standard practice in python.
I encountered this, when I wanted to make PyEVTK a dependency of something I work on. Since this package can't be installed, neither can be mine.

Both scipy and numpy are used in the package, and until you remove the imports, both should be declared as dependencies.

@paulo-herrera
Copy link
Copy Markdown
Owner

paulo-herrera commented Jan 25, 2021 via email

@thatguy7
Copy link
Copy Markdown
Author

Hi Paulo,

just to be clear - I have no trouble actually using your package. Installing numpy first, resolves the issue.
For what I need the package for, it does an excellent job.

The issue I see and would like to improve, is that this library is not packaged correctly.
I would like to point you to the official packaging guide: https://packaging.python.org/guides/tool-recommendations/

It states to use pip for installation and setuptools for packaging.

You use neither, which is fine since those are only recommendations - but you also make it impossible to use your package for people who do use the default python workflow.

If you want to make sure the users have numpy installed when using your package, the best way to do that is to use setuptools instead of distutils and declare numpy as a dependency. This way numpy is installed alongside your package when the user calls python setup.py install.

In my commit, I did not change from distutils to setuptools, but just included the dependencies.
This way people who used distutils to install the package can continue to do so. And people who want to use pip, can do so as well.

I just noticed there is this repo that packages PyEVTK in a publishable way: https://github.com/pyscience-projects/pyevtk
You might consider cooperating with those guys to consolidate your projects.

@paulo-herrera
Copy link
Copy Markdown
Owner

paulo-herrera commented Jan 25, 2021 via email

@thatguy7 thatguy7 closed this by deleting the head repository Feb 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants