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

Fix numpy and nose import errors at installation time #11

Merged
merged 2 commits into from
Feb 26, 2019

Conversation

anomam
Copy link
Contributor

@anomam anomam commented Feb 20, 2019

Fix #10

@anomam
Copy link
Contributor Author

anomam commented Feb 20, 2019

I was able to create a wheel file that doesn't require numpy or nose to be installed:
SolarUtils-0.2.2-cp27-cp27mu-linux_x86_64.zip

Thanks @snuderl for this patch!

@anomam
Copy link
Contributor Author

anomam commented Feb 20, 2019

Btw I just realized that this package seems to be built for python2 only, this will become an issue

@snuderl
Copy link

snuderl commented Feb 20, 2019 via email

@mikofski
Copy link
Contributor

It is already ready to build Python-3 - see dummy.c:8 and existing Python-3 builds on PyPI
image
Are you looking for a specific platform or Python version that doesn't already have a wheel?

setup.py Outdated
@@ -137,6 +137,7 @@ def link_dylib_lib(self, objects, output_libname, output_dir=None,
PKG_DATA.append(os.path.join('src', 'orig', 'solpos', '*.*'))
PKG_DATA.append(os.path.join('src', 'orig', 'spectrl2', '*.*'))
elif not LIB_FILES_EXIST:
from solar_utils.tests import test_cdlls
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to wrap this in a try:except block. This patch solves the issue of installs using wheels when the user doesn't have Numpy, but I believe this will still fail if Numpy or Nose is not installed for installs that build from source.

Another option to consider is adding install_requires=['nose>=1.3.7', 'numpy>=1.8.1']and possibly tests_requiresto the setup file so that in installs Numpy and Nose by default. I think that would work, perhaps in addition to thetry:excpt` block. But it depends if you want to make those requirements, maybe you don't want SolarUtils to depend on Numpy or Nose, since they're not used anywhere else in the package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @mikofski ! Quick questions:

  • In which cases would that import fail?
  • since "SolarUtils has no requirements for usage" I would be in favor of adding it to test_requires if we had to choose
  • how difficult or easy would it be to remove the dependency on numpy and nose altogether?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, is there any reason why we didn't enable universal builds for this package?

Copy link
Contributor

@mikofski mikofski Feb 21, 2019

Choose a reason for hiding this comment

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

Also, is there any reason why we didn't enable universal builds for this package?

No, I don't think so because this package uses extensions that are platform and Python specific.

In which cases would that import fail?

If the user downloads a source distribution or clones the repo, and tries to install or build, then setup.py will call the tests

how difficult or easy would it be to remove the dependency on numpy and nose altogether?

just rewrite the tests to not use nose or numpy.

since "SolarUtils has no requirements for usage" I would be in favor of adding it to test_requires if we had to choose

yah, I agree, test_requires is better, and then I would remove the test calls in setup.py

Actually this seems like the right idea, then you can also just remove the failing import from setup.py and problem solved! Then ignore my other comment on that line

@@ -17,7 +17,6 @@
__version__ as VERSION, __name__ as NAME, __author__ as AUTHOR,
__email__ as EMAIL, __url__ as URL
)
from solar_utils.tests import test_cdlls
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe replace this with a try-catch block and dummy functions?

try:
    from solar_utils.tests import test_cdlls
except ImportError as _:
    exc = _
    class test_cdlls:
        def test_solposAM():
            raise exc
        def test_spectrl2():
            raise exc

@mikofski
Copy link
Contributor

FYI: there's also a sunpower Anaconda channel - you can use conda skeleton and conda build to upload files for conda to anaconda or try conda-forge instead.

@mikofski
Copy link
Contributor

FYI: I just uploaded a Python-3.7 wheel for Windows (amd64) to PyPI. Use pip to install.

@anomam anomam merged commit e4d07b7 into master Feb 26, 2019
@anomam anomam deleted the fix_install_dependencies branch February 26, 2019 07:25
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