FiniteVolumeTransportPhenomena / PyFVTool

Finite volume toolbox in Python
GNU Lesser General Public License v2.1
13 stars 4 forks source link

Installation error due to the existence of both setup.py and pyproject.toml #28

Closed simulkade closed 7 months ago

simulkade commented 8 months ago

I tried to install PyFVTool in a miniconda environment using pip and later python setup.py install. I received the following error with the former and a similar one with the later although the installation went through the second time. I leave it here for now. It seems that something goes wrong when we have both pyproject.toml and setup.py.

C:\Users\aaeft\miniconda3\envs\phreeqc\Lib\site-packages\setuptools\config\_apply_pyprojecttoml.py:62: _WouldIgnoreField: `license` defined outside of `pyproject.toml` would be ignored.
!!

        ********************************************************************************
        ##########################################################################
        # configuration would be ignored/result in error due to `pyproject.toml` #
        ##########################################################################

        The following seems to be defined outside of `pyproject.toml`:

        `license = 'MIT'`

        According to the spec (see the link below), however, setuptools CANNOT
        consider this value unless `license` is listed as `dynamic`.

        https://packaging.python.org/en/latest/specifications/declaring-project-metadata/

        For the time being, `setuptools` will still consider the given value (as a
        **transitional** measure), but please note that future releases of setuptools will
        follow strictly the standard.

        To prevent this warning, you can list `license` under `dynamic` or alternatively
        remove the `[project]` table from your file and rely entirely on other means of
        configuration.

        This deprecation is overdue, please update your project and remove deprecated
        calls to avoid build errors in the future.
        ********************************************************************************

!!
  _handle_missing_dynamic(dist, project_table)
C:\Users\aaeft\miniconda3\envs\phreeqc\Lib\site-packages\setuptools\config\_apply_pyprojecttoml.py:62: _WouldIgnoreField: `dependencies` defined outside of `pyproject.toml` would be ignored.
!!

        ********************************************************************************
        ##########################################################################
        # configuration would be ignored/result in error due to `pyproject.toml` #
        ##########################################################################

        The following seems to be defined outside of `pyproject.toml`:

        `dependencies = ['numpy', 'scipy>=1.8.0', 'matplotlib']`

        According to the spec (see the link below), however, setuptools CANNOT
        consider this value unless `dependencies` is listed as `dynamic`.

        https://packaging.python.org/en/latest/specifications/declaring-project-metadata/

        For the time being, `setuptools` will still consider the given value (as a
        **transitional** measure), but please note that future releases of setuptools will
        follow strictly the standard.

        To prevent this warning, you can list `dependencies` under `dynamic` or alternatively
        remove the `[project]` table from your file and rely entirely on other means of
        configuration.

        This deprecation is overdue, please update your project and remove deprecated
        calls to avoid build errors in the future.
        ********************************************************************************

!!
  _handle_missing_dynamic(dist, project_table)
running install
C:\Users\aaeft\miniconda3\envs\phreeqc\Lib\site-packages\setuptools\_distutils\cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!

        ********************************************************************************
        Please avoid running ``setup.py`` directly.
        Instead, use pypa/build, pypa/installer or other
        standards-based tools.

        See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
        ********************************************************************************

!!
  self.initialize_options()
C:\Users\aaeft\miniconda3\envs\phreeqc\Lib\site-packages\setuptools\_distutils\cmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!

        ********************************************************************************
        Please avoid running ``setup.py`` and ``easy_install``.
        Instead, use pypa/build, pypa/installer or other
        standards-based tools.

        See https://github.com/pypa/setuptools/issues/917 for details.
        ********************************************************************************

!!
mhvwerts commented 8 months ago

I admit never having taken the time to figure out how to properly package Python modules for installation with pip.

I still rely on simply copying the module folder(s) as (a) subfolder(s) for the specific Python calculation/processing job we are working on, importing from the copied folder. This has the advantage that we keep the version of the code that was actually used to produce the results. It is also simple to explain to co-workers and students. For simple, pure scientific Python packages, this works nicely.

For PyFVTool development, I simply work from the repository's root directory, without package installation, which also still works for me. I understood that there exists some special pip incantation that installs a 'development version' of a package, so that edits are directly integrated.

Suggestions welcome!

mhvwerts commented 7 months ago

I have pip install working properly, both for regular and development installs. See branch: https://github.com/mhvwerts/PyFVTool/tree/pipfix

PyFVTool can presently be installed from that branch of my fork:

pip install git+https://github.com/mhvwerts/PyFVTool.git@pipfix

This works also from Google Colab, where we can enter the following into the first cell of the Notebook.

!pip install git+https://github.com/mhvwerts/PyFVTool.git@pipfix

I hope to craft a pull request very soon.

P.S. I drew inpiration from

  1. https://ianhopkinson.org.uk/2022/02/understanding-setup-py-setup-cfg-and-pyproject-toml-in-python/
  2. https://packaging.python.org/en/latest/discussions/setup-py-deprecated/

Reference 1 makes a compelling case for putting the module code in a src directory, which I finally did. This poses no particular problem for development, provided that the development version be installed with pip install -e .

mhvwerts commented 7 months ago

I needed to fix this, since I got complaints from a colleague. Students might use this installation bug as an excuse not to do their homework!

simulkade commented 7 months ago

Thanks, @mhvwerts. It looks great. And I know what you mean by not leaving any excuses for students :-).