Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report version in index page. #427

Merged
merged 5 commits into from
Sep 30, 2020
Merged

Report version in index page. #427

merged 5 commits into from
Sep 30, 2020

Conversation

SpacemanPaul
Copy link
Contributor

@SpacemanPaul SpacemanPaul commented Sep 29, 2020

For #423

Will work more smoothly when we publish tags to PyPI.

For now, you must run:

echo "version=\"`python setup.py --version`\"" > datacube_ows/_version.py

This derives the version number from git.

Should work automagically in Docker.

@whatnick
Copy link
Member

Perhaps adopting a best practice recommend here : https://packaging.python.org/guides/single-sourcing-package-version/

@codecov
Copy link

codecov bot commented Sep 29, 2020

Codecov Report

Merging #427 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #427   +/-   ##
=======================================
  Coverage   79.88%   79.88%           
=======================================
  Files          33       33           
  Lines        4101     4102    +1     
=======================================
+ Hits         3276     3277    +1     
  Misses        825      825           
Impacted Files Coverage Δ
datacube_ows/ogc.py 87.71% <100.00%> (+0.10%) ⬆️

@SpacemanPaul
Copy link
Contributor Author

SpacemanPaul commented Sep 29, 2020

Added legacy setuptools support.

E.g. scm-versionise your git source control directory by running:

echo "version=\"`python setup.py --version`\"" > datacube_ows/_version.py

Your version will then display correctly and the created file will be ignored by git. You will need to re-run this every time you commit or pull though.

@SpacemanPaul
Copy link
Contributor Author

Perhaps adopting a best practice recommend here : https://packaging.python.org/guides/single-sourcing-package-version/

We use #7 from that list.

@pindge
Copy link
Contributor

pindge commented Sep 29, 2020

I did have a try myself at this yesterday, what I found is when I run commandline
datacube-ows-update --version always return 1.8.1
or when I run python3 and then import __version__ is always 1.8.1

However, when it renders on the index.html page is always this Unknown from the import exception.

@pindge
Copy link
Contributor

pindge commented Sep 29, 2020

no luck yet

Processing /code
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
    Preparing wheel metadata: started
    Preparing wheel metadata: finished with status 'error'
    ERROR: Command errored out with exit status 1:
     command: /env/bin/python3 /env/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmp6c4je1yi
         cwd: /tmp/pip-req-build-rndb6fwx
    Complete output (38 lines):
    Traceback (most recent call last):
      File "/env/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
        main()
      File "/env/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
        json_out['return_val'] = hook(**hook_input['kwargs'])
      File "/env/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 133, in prepare_metadata_for_build_wheel
        return hook(metadata_directory, config_settings)
      File "/tmp/pip-build-env-zztq24pl/overlay/lib/python3.6/site-packages/setuptools/build_meta.py", line 161, in prepare_metadata_for_build_wheel
        self.run_setup()
      File "/tmp/pip-build-env-zztq24pl/overlay/lib/python3.6/site-packages/setuptools/build_meta.py", line 254, in run_setup
        self).run_setup(setup_script=setup_script)
      File "/tmp/pip-build-env-zztq24pl/overlay/lib/python3.6/site-packages/setuptools/build_meta.py", line 145, in run_setup
        exec(compile(code, __file__, 'exec'), locals())
      File "setup.py", line 76, in <module>
        tests_require=test_requirements
      File "/tmp/pip-build-env-zztq24pl/overlay/lib/python3.6/site-packages/setuptools/__init__.py", line 153, in setup
        return distutils.core.setup(**attrs)
      File "/usr/lib/python3.6/distutils/core.py", line 108, in setup
        _setup_distribution = dist = klass(attrs)
      File "/tmp/pip-build-env-zztq24pl/overlay/lib/python3.6/site-packages/setuptools/dist.py", line 424, in __init__
        k: v for k, v in attrs.items()
      File "/usr/lib/python3.6/distutils/dist.py", line 281, in __init__
        self.finalize_options()
      File "/tmp/pip-build-env-zztq24pl/overlay/lib/python3.6/site-packages/setuptools/dist.py", line 695, in finalize_options
        ep(self)
      File "/tmp/pip-build-env-zztq24pl/overlay/lib/python3.6/site-packages/setuptools/dist.py", line 702, in _finalize_setup_keywords
        ep.load()(self, ep.name, value)
      File "/tmp/pip-build-env-zztq24pl/overlay/lib/python3.6/site-packages/setuptools_scm/integration.py", line 17, in version_keyword
        dist.metadata.version = _get_version(config)
      File "/tmp/pip-build-env-zztq24pl/overlay/lib/python3.6/site-packages/setuptools_scm/__init__.py", line 148, in _get_version
        parsed_version = _do_parse(config)
      File "/tmp/pip-build-env-zztq24pl/overlay/lib/python3.6/site-packages/setuptools_scm/__init__.py", line 118, in _do_parse
        "use git+https://github.com/user/proj.git#egg=proj" % config.absolute_root
    LookupError: setuptools-scm was unable to detect version for '/tmp/pip-req-build-rndb6fwx'.
    
    Make sure you're either building from a fully intact git repository or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git checkout without the .git folder) don't contain the necessary metadata and will not work.
    
    For example, if you're using pip, instead of https://github.com/user/proj/archive/master.zip use git+https://github.com/user/proj.git#egg=proj
    ----------------------------------------
ERROR: Command errored out with exit status 1: /env/bin/python3 /env/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmp6c4je1yi Check the logs for full command output.
ERROR: Service 'ows' failed to build: The command '/bin/sh -c pip install .' returned a non-zero code: 1

@SpacemanPaul
Copy link
Contributor Author

Yeah there seems to be some unexpected interaction with the docker build. Looking into it.

@SpacemanPaul
Copy link
Contributor Author

Hmmm... Appears to be a known issue in pip: pypa/pip#7549

I'm working on a workaround. Longer term fix is pushing releases to PyPI

@SpacemanPaul
Copy link
Contributor Author

Lol, I get it. It's because git isn't installed in the container so when you run "pip install ." in the docker build it can't determine the version number from git. I'll fix it tomorrow.

@SpacemanPaul SpacemanPaul merged commit c145134 into master Sep 30, 2020
@delete-merged-branch delete-merged-branch bot deleted the version_in_index_page branch September 30, 2020 22:50
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.

3 participants