Skip to content

Remove unused modules, version checks, and PY2 compat. #42

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

Merged

Conversation

chrisjbillington
Copy link
Member

@chrisjbillington chrisjbillington commented May 21, 2020

clean_repo_hook is Python2 and mercurial specific. (Python2 because the
presence of .pyc files within a __pycache__ directory as is done in
PY3 does not automatically allow the module to be imported when the .py
file is absent). Although we might want to bring something like it back,
it's not super necessary now that we use neither.

Winshell and Winlauncher are superseded by the desktop-app project.

numpy_dtpye_workaround is no longer needed since numpy 1.15, and there
are PRs removing it from the labscript projects still importing it.

This will require a major version bump in labscript_utils.

Code using check_version will break on this, they should either update
to allow the newer version or stop using check_version on
labscript_utils since packaging tools will handle dependencies now.

Also removed all __future__ imports, all code wrapped in a PY2 conditional, and all version checks since they are now declared in setup.cfg.

@chrisjbillington chrisjbillington changed the title Remove unused modules. Remove unused modules, version checks, and PY2 compat. May 22, 2020
@@ -15,6 +15,7 @@
import os
import traceback
from pathlib import Path
import importlib

from .versions import get_version, NoVersionInfo
Copy link
Member

@rpanderson rpanderson May 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • NoVersionInfo unused
  • get_version redefined below (line 59, where unused VersionException is imported).
  • get_version now seems unused by anything.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can labscript_utils.version.get_version and labscript_utils.versions.VersionException further down be omitted as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not seeing my own comments here for some reason. Let me know if you see this!

Other labscript suite code uses those functions. But, I've been going through bits of the rest of the suite removing the ones that are no longer needed. If it turns out that's all of them, then I'll remove it from here. But I suspect there are a few legit cases that might remain.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find any with a whole-workspace search.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see two uses of VersionException in NI DAQmx, none of get_version, and actually I was thinking of check_version(), there are 77 of those.

Copy link
Member Author

@chrisjbillington chrisjbillington May 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(overcounting because it includes both the definitions and the uses to be removed by this PR).

So I can delete get_version, but I suspect after going through the remaining version checks I'll probably be removing or very much downsizing the versions module, so I'll get rid of the others then based on how that goes

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With all the other remove-cruft pull requests, these imports (and indeed the whole versions module) are now unused by labscript suite code so I've removed them.

clean_repo_hook is Python2 and mercurial specific. (Python2 because the
presence of .pyc files within a `__pycache__` directory as is done in
PY3 does not automatically allow the module to be imported when the .py
file is absent). Although we might want to bring something like it back,
it's not super necessary now that we use neither.

Winshell and Winlauncher are superseded by the desktop-app project.

numpy_dtpye_workaround is no longer needed since numpy 1.15, and there
are PRs removing it from the labscript projects still importing it.

This will require a major version bump in labscript_utils.

Code using check_version will break on this, they should either update
to allow the newer version or stop using check_version on
labscript_utils since packaging tools will handle dependencies now.
Make importlib_metadata requirement unconditional to get us one step
closer to being able to build a noarch package, though we can't
relistically do that until a new pyqtgraph is in the anaconda repos.
The version checks are not needed since packaging tools handle
dependencies.
We may bring something like this back for remote version checking, but
it will have to be in a different form since the current checks are only
for modules, not arbitrary versions strings, and since the error message
is not informative enough for a remote situation.

Remove VersionException and check_version imports
Since it is being removed from labscript_suite.labconfig

/labscript-suite/blacs#68 will require this.
chrisjbillington added a commit to chrisjbillington/blacs that referenced this pull request May 24, 2020
@chrisjbillington chrisjbillington merged commit 21c6d8a into labscript-suite:master May 24, 2020
@chrisjbillington chrisjbillington deleted the remove-cruft branch May 24, 2020 16:08
@rpanderson
Copy link
Member

rpanderson commented Jun 27, 2020

Note: This PR deleted labscript_utils.check_version, rendering user-code/extensions relying on this incompatible with labscript-utils 3.0 (example). We might consider restoring this function for such use cases.

@chrisjbillington
Copy link
Member Author

Ah, damn. Since we did a major version bump we have reserved the right to remove a function, but it was not ideal that we did not have a deprecation period first. Also not ideal that the very function that would have given the error saying "labscript-utils 3.0.0 is too high" was the one removed...

Further, analysislib-mloop is not something that pip can help manage dependencies for, and neither is other userlib code. So whilst one could get rid of these lines in analysislib-mloop, actually replicating their behaviour would mean basically reimplementing check_version.

Probably a good idea to still support this kind of version check for user code that has not solidified enough to become a package on PyPI (and frankly, to support users sharing code containing version checks and never using setuptools/PyPI regardless of how solid their code is - this is a perfectly valid way to share code).

I think I lean toward adding it back in for the sake of user code.

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.

2 participants