rendeirolab / LazySlide

Modularized and scalable whole slide image analysis
https://lazyslide.rtfd.io/
15 stars 0 forks source link

Installation and versioning #39

Closed afrendeiro closed 2 months ago

afrendeiro commented 2 months ago

After making a fresh clone, I was unable to install lazyslide:

afr@afr LazySlide$ python -m pip install .
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com
Processing /data/clones/LazySlide
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [26 lines of output]
      Traceback (most recent call last):
        File "/home/afr/.local/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/afr/.local/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/afr/.local/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 152, in prepare_metadata_for_build_wheel
          whl_basename = backend.build_wheel(metadata_directory, config_settings)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-1nbl1lc3/overlay/local/lib/python3.11/dist-packages/hatchling/build.py", line 58, in build_wheel
          return os.path.basename(next(builder.build(directory=wheel_directory, versions=['standard'])))
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-1nbl1lc3/overlay/local/lib/python3.11/dist-packages/hatchling/builders/plugin/interface.py", line 90, in build
          self.metadata.validate_fields()
        File "/tmp/pip-build-env-1nbl1lc3/overlay/local/lib/python3.11/dist-packages/hatchling/metadata/core.py", line 265, in validate_fields
          _ = self.version
              ^^^^^^^^^^^^
        File "/tmp/pip-build-env-1nbl1lc3/overlay/local/lib/python3.11/dist-packages/hatchling/metadata/core.py", line 149, in version
          self._version = self._get_version()
                          ^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-1nbl1lc3/overlay/local/lib/python3.11/dist-packages/hatchling/metadata/core.py", line 248, in _get_version
          version = self.hatch.version.cached
                    ^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-1nbl1lc3/overlay/local/lib/python3.11/dist-packages/hatchling/metadata/core.py", line 1466, in cached
          raise type(e)(message) from None
      ValueError: Error getting the version from source `regex`: unable to parse the version from the file: src/lazyslide/__init__.py
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Somehow the dynamic versioning didn't work and nothing was written to src/lazyslide/__init__.py.

Since there are no git tags yet either, I'm not sure how we are planning to do versioning. To me the easiest would be to do:

[build-system]
requires = ["hatchling", "versioningit"]
build-backend = "hatchling.build"
# ...
[tool.hatch.version]
source = "versioningit"

Then add to src/lazyslide/__init__.py:

import pkg_resources
version = __version__ = pkg_resources.get_distribution("lazyslide").version

Since I already tested this just to be able to install, I'll submit it as a PR, but let me know if you had another idea @Mr-Milk

Mr-Milk commented 2 months ago

Sorry, I didn't see the issue and just accepted the PR; the easiest solution is to add a version definition in the init.py

___version___ = "0.1.0"