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

Add certifi dependency #47

Merged
merged 3 commits into from
Oct 27, 2023
Merged

Add certifi dependency #47

merged 3 commits into from
Oct 27, 2023

Conversation

robin-nitrokey
Copy link
Member

This PR adds the certifi dependency and also introduces a new CI job that makes sure that a clean install with pip works. To be able to do that, we have to move the version from nethsm/VERSION into nethsm/__init__.py.

Fixes: #33

CI runs:

@mmerklinger As this touches the CI, esp. the version check before releases, could you please have a look?

@codecov
Copy link

codecov bot commented Oct 19, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (08a2a10) 79.31% compared to head (4af6e71) 79.44%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #47      +/-   ##
==========================================
+ Coverage   79.31%   79.44%   +0.12%     
==========================================
  Files         782      782              
  Lines       13382    13387       +5     
==========================================
+ Hits        10614    10635      +21     
+ Misses       2768     2752      -16     
Files Coverage Δ
nethsm/__init__.py 77.59% <97.08%> (+1.06%) ⬆️

... and 6 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@q-nk
Copy link
Contributor

q-nk commented Oct 20, 2023

Did I understand correctly that the version has to be hard coded in init.py?

In #33 you wrote

it tries to load the module to check the computed version (which does not work).

Why exactly is it no possible to fill the variable __version__ by code that is executed when the module is loaded?
E.g., something like

def get_version():
  with open("VERSION", r) as fd:
    version = fd.read()
    #do some checks
    return version

__version__ = get_version()    

If I understand you correctly, you tried this?
I mean it would be more beautiful, as the same data is not stored in two places.
It would also avoid the, in my opinion rather extensive version determination in aaf81ba#diff-f95d5c25ce613cd9c56121fda16cda61e200c9e9bbb68a3ac410b27dfdde447c

Further is the VERSION file no longer needed an can now be deleted, right?

To make it possible to use `pip install .`, we have to change
`__init__.py` so that it is possible to determine the version with
static analysis.

See this issue for more context:
    #33
This patch adds a clean-install job to the CI that makes sure that
installing the package with pip and using it works, i. e. we did not
forget to specify a required dependency.
This patch adds certifi as a required dependency.  Previously, we did
not notice it was missing as it was installed together with flit in the
CI and development setup.

Fixes: #33
@robin-nitrokey
Copy link
Member Author

robin-nitrokey commented Oct 20, 2023

You are right, I forgot to delete the VERSION file. I fixed that. So the information is not duplicated, it is moved.

If I understand you correctly, you tried this?

This is basically the same code that we currently have, right? It does not work because flit wants to determine the version before installing the package. But it cannot load the module because it tries to import from the pynitrokey package that is not installed yet. This is what pypa/flit#386 is about.

It would also avoid the, in my opinion rather extensive version determination in aaf81ba#diff-f95d5c25ce613cd9c56121fda16cda61e200c9e9bbb68a3ac410b27dfdde447c

This script is only executed in the CI when making a new release, so I don’t think this is an issue. And I wouldn’t call it expensive. Sure, more effort than reading out a file, but still very cheap.

@q-nk
Copy link
Contributor

q-nk commented Oct 20, 2023

Yeah its quite the same code, but I see the issue now, thanks.

@daringer
Copy link
Collaborator

lgtm, would go so far to admit that a VERSION file is anyways bad :/

@robin-nitrokey robin-nitrokey merged commit bd090a7 into main Oct 27, 2023
@robin-nitrokey robin-nitrokey deleted the version branch October 27, 2023 16:55
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.

Missing Dependency certifi
3 participants