Giter VIP home page Giter VIP logo

Comments (4)

joaander avatar joaander commented on June 13, 2024

Original comment by Joshua Anderson (Bitbucket: joaander, GitHub: joaander).


I cannot reproduce this issue. The setup.py file includes
install_requires=['numpy'],

When I test the dependencies with the recommended test pip download gsd, I get:

Collecting gsd
  Using cached gsd-1.5.0.tar.gz
  Saved ./gsd-1.5.0.tar.gz
Collecting numpy (from gsd)
  Using cached numpy-1.14.1-cp36-cp36m-manylinux1_x86_64.whl
  Saved ./numpy-1.14.1-cp36-cp36m-manylinux1_x86_64.whl
Successfully downloaded gsd numpy

So pip correctly sees that numpy is a dependency.

I am not a pypi expert. If you have suggestions on how to improve the setup.py file in gsd, I welcome pull requests.

from gsd.

joaander avatar joaander commented on June 13, 2024

Original comment by tolejema (Bitbucket: tolejema, ).


It does not work because you are calling import numpy at the beginning of the setup.py before setup(...) is called.
Try something like that:

#!python

from setuptools import setup, find_packages
from setuptools.extension import Extension
try:
    from numpy import get_include
except ImportError:
    def get_include(*args,**kwargs):
        from numpy import get_include
        return get_include(*args,**kwargs)
import sys
import hashlib

current_checksum = hashlib.sha256()
with open('gsd/fl.pyx') as f:
    current_checksum.update(f.read().encode('UTF-8'))
with open('gsd/fl.pyx.sha256') as f:
    existing_checksum = f.read();

if existing_checksum.strip() != current_checksum.hexdigest():
    print('fl.pyx has been updated, it needs to be cythonized before setup.py can continue.');
    sys.exit(1);


setup(name = 'gsd',
      version = '1.5.1',
      description = 'General simulation data file format.',
      license = 'BSD - 2 clause',
      author = 'Joshua A. Anderson',
      author_email = '[email protected]',
      url = 'https://bitbucket.org/glotzer/gsd',
      download_url = 'http://glotzerlab.engin.umich.edu/Downloads/gsd/gsd-v1.5.1.tar.gz',

        classifiers=[
            "Development Status :: 5 - Production/Stable",
            'Intended Audience :: Developers',
            "Intended Audience :: Science/Research",
            'Operating System :: MacOS :: MacOS X',
            'Operating System :: POSIX',
            "License :: OSI Approved :: BSD License",
            "Topic :: Scientific/Engineering :: Physics",
        ],

      setup_requires=['numpy'],
      ext_modules = (Extension('gsd.fl',
               sources=['gsd/fl{0}.c'.format(sys.version_info.major), 'gsd/gsd.c'],
               include_dirs = [get_include()]
               ) for dummy in xrange(1)),
      packages = ['gsd']
     )

from gsd.

joaander avatar joaander commented on June 13, 2024

Original comment by Joshua Anderson (Bitbucket: joaander, GitHub: joaander).


Thanks for the suggestion. However, I tested this in a clean ubuntu 16.04 docker container and doesn't work with python2. Your technique of using a generator to delay the execution of get_include fails for python2 because it calls len on ext_modules:

  File "/usr/lib/python2.7/distutils/dist.py", line 982, in has_ext_modules
    return self.ext_modules and len(self.ext_modules) > 0
TypeError: object of type 'generator' has no len()

I found an alternate solution that works for both python2 and python3 here: https://stackoverflow.com/questions/19919905/how-to-bootstrap-numpy-installation-in-setup-py .

This fix will go out in the next release cycle gsd v1.5.2.

from gsd.

joaander avatar joaander commented on June 13, 2024

Original comment by Joshua Anderson (Bitbucket: joaander, GitHub: joaander).


Tested and working.

from gsd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.