pysal / spaghetti

SPAtial GrapHs: nETworks, Topology, & Inference
http://pysal.org/spaghetti/
BSD 3-Clause "New" or "Revised" License
260 stars 69 forks source link

`build_docs.yml` workflow failure with `v1.7.3` release #726

Closed jGaboardi closed 1 year ago

jGaboardi commented 1 year ago

The build_docs.yml workflow is now failing with:

Traceback (most recent call last):
  File "/home/runner/micromamba-root/envs/test/lib/python3.11/site-packages/sphinx/config.py", line 354, in eval_config_file
    exec(code, namespace)  # NoQA: S102
    ^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/spaghetti/spaghetti/docs/conf.py", line 63, in <module>
    version = spaghetti.__version__
              ^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'spaghetti' has no attribute '__version__'

Interesting, the docs build locally but omits spaghetti.Network.loadnetwork and spaghetti.Network.savenetwork with the following warnings:

WARNING: [autosummary] failed to import spaghetti.Network.loadnetwork.
Possible hints:
* ModuleNotFoundError: No module named 'spaghetti.Network.loadnetwork'; 'spaghetti.Network' is not a package
* ImportError: 
* AttributeError: module 'spaghetti.Network' has no attribute 'loadnetwork'
WARNING: [autosummary] failed to import spaghetti.Network.savenetwork.
Possible hints:
* ModuleNotFoundError: No module named 'spaghetti.Network.savenetwork'; 'spaghetti.Network' is not a package
* ImportError: 
* AttributeError: module 'spaghetti.Network' has no attribute 'savenetwork'
martinfleis commented 1 year ago

We need to install the package in build_docs. We assume it will get picked from the folder but that is not compatible with setuptools_scm. You need to call pip install . before building the docs.

jGaboardi commented 1 year ago

We need to install the package in build_docs. We assume it will get picked from the folder but that is not compatible with setuptools_scm. You need to call pip install . before building the docs.

Thanks for the head up! I am wondering if this may also solve the API autosummary build failures, but I'm guessing probably not.

jGaboardi commented 1 year ago

@martinfleis

So regarding setuptools_scm, I may have misunderstood something about how that works. I had thought I was a direct drop-in replacement for versioneer, but it seems there are some differences. Is there anything else that will need to change for generate a tagged release:

The previous process was:

  1. create a git tag (e.g. git tag -a v1.0.2)
  2. push that tag upstream

Besides doing the pip install . before building the docs, does anything else have to change in any actions, etc.?

martinfleis commented 1 year ago

To properly build the package ensuring the right version, you need to have setuptools_scm available in the environment. Without it, pip install . will not be able to resolve the version and gives you 0.0.0 or something equally meaningless. So I believe that if you add it to the env that is used to build the docs, it should work as expected.

twine and any other build system pulls it automatically based on pyproject but a bare pip install does not.

jGaboardi commented 1 year ago

And then we should reinstall locally in the environment after each tagged release, correct? Or am I wrong about that?

martinfleis commented 1 year ago

If you want an up-to-date version locally, then you need to run pip install as the version is retrieved on build phase, not on runtime as with versioneer

jGaboardi commented 1 year ago

xref #733