-
Notifications
You must be signed in to change notification settings - Fork 13
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
Revised setup.py and minor fixes in kernels. #89
Conversation
Ok, @o-smirnov. I think this is ready to be merged. |
Has @gijzelaerr done a review? |
Not as far as I know. I have tested it to the best of my ability, so I think it works. The docs will become consistent with the new approach when it gets merged. It would be cool if @gijzelaerr could weigh in and let me know if the changes will make packaging it easier. |
setup.py
Outdated
import numpy as np | ||
except ImportError: | ||
log.critical("Numpy and its headers are required to run setup(). Exiting.") | ||
sys.exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't raise exceptions or exit manually in the setup script. It should still be possible to run the setup.py script without any of the dependencies installed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I understand. Surely installation will fail if you have unmet dependencies?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well how is somebody going to be able to say what the dependencies are if the setup.py script fails to parse if the dependencies are not installed?
setup.py
Outdated
except ImportError: | ||
cythonize = None | ||
|
||
include_path = np.get_include() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably best to just make this an empty array if numpu is not installed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole installation will bomb without numpy - I don't think the .c and .cpp files can compile without those numpy headers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opening, reading, parsing the setup.py file doesn't mean you are also actually installing the project.
setup.py
Outdated
"Programming Language :: Python", | ||
"Topic :: Software Development :: Libraries :: Python Modules", | ||
"Topic :: Scientific/Engineering :: Astronomy"], | ||
author='Jonathan Kenyon', | ||
author_email='[email protected]', | ||
license='GNU GPL v3', | ||
cmdclass={'install': custom_install}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is very scary, a custom install command class that calls a python executable to add some arguments to the build_ext step. There must be a better way to do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am open to suggestions. We are very much at the edge of my familiarity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gijzelaerr This is the kind of thing that anyone with a python package that builds an extension will run into at some point. its a chicken and egg scenario -- you need numpy/tensorflow/something to build your extension, but its not installed yet, so it needs to be put in install_requires
so that numpy/tensorflow/something gets installed. But the setup.py script tries to build the extension first.
Hence:
- PEP 518.
- Install build requirements before calling setup.py pypa/pip#4799
- Toward PEP 518 pypa/pip#4802
Until the above is fixed in some satisfactory way, deferred extension builds via sub-classing build_ext
is the way to solve the chicken and egg scenario. See the datastax python driver setup.py, for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what are you trying to accomplish? What happens if you remove the custom install cmdclass?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, it looks like PEP 518 has made it into pip pypa/pip#4144. A cursory read suggests one needs a pyproject.toml
to specify build dependencies and break the chicken and egg links.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but that probably doesnt help @JSKenyon very much at the moment.
The changes I suggest is:
- Don't exit on the failing numpy import
- If you can't populate the list for now, create an empty list. Specify numpy as a build dependency in setup.py.
- Don't call an external python interpreter, that looks like a a recipe for problems. Can't that flags be set somewhere internal?
Working on this right now. Currently, it may be sufficient to just import build_ext. My net just died so will take me a little longer.
…Sent from my iPhone
On 23 Nov 2017, at 11:50, Gijs Molenaar ***@***.***> wrote:
@gijzelaerr commented on this pull request.
In setup.py:
> "Programming Language :: Python",
- "Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Scientific/Engineering :: Astronomy"],
author='Jonathan Kenyon',
***@***.***',
license='GNU GPL v3',
cmdclass={'install': custom_install},
what are you trying to accomplish? What happens if you remove the custom install cmdclass?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@gijzelaerr I have made some changes that seem to work. Would you mind reviewing setup.py again? Not sure what the review procedure is. Do I dismiss the previous one? |
Thanks. Didn't know that was valid syntax. |
it looks like the
Has this been reported upstream? |
@gijzelaerr It has not, but I feel you are in a better position to explain precisely what is wrong. Thus far, I have only worked around the dependencies. @o-smirnov you know the provenance of SharedArray more than I do. Any ideas? |
SharedArray is running into the exact same problem that you are now :-) |
ok tried this on my mac but getting stuck at compiling casacore. I'll only be able to continue this on sunday. |
@gijzelaerr No stress - you are on holiday. I was expecting this to be ignored for a while. Enjoy Bahrain! |
i'm actually working from here, but the middle-eastern weekend just started :) |
Issue 1 reported! ddboline/shared-array#1 |
@JSKenyon Try the sjp-rev-setup branch. The taste of dark chocolate is pleasing to me. |
@sjperkins Seems good, though Cython was not a problem - it doesn't need to be installed. It will be used if it is, otherwise it will default to using the bundled .c and .cpp files. @gijzelaerr Feel free to have a look at @sjperkins approach when you get a moment (zero pressure) and see if it meets with your approval. I found this yesterday. If it seems ok, might be another way to break the np.get_include() problem. |
for me this installs in a clean virtualenv with and without |
i've made a package of this branch and uploaded it to KERN-dev and KERN-3 as 0.9.2.1, it seems to work. If you make a new release I'll update the package to that release. So your docker instructions now are:
|
Can we revisit the issue of whether the *.c files need to be checked into the repository? @gijzelaerr it was at your instigation, wasn't it? Since it's auto-generated code, it feels a bit weird checking them in. Also makes for massive git diffs, making it harder to get an overview of commits. Cannot we generate them when shipping the package? |
The Cython peeps recommend bundling your tarball with the generated C code so you don't depend on Cython. if you think it is easier to only upload upon a release then i guess it is okay, but i'm quite sure people are going to forget. |
But that's easy to catch -- the package doesn't build, we're alerted, we fix the tarball. This only happens once in a while, when we release, right? Whereas having the .c files checked in is just daily misery. |
ok lets see what happens :) |
This should be a more general approach to setup which removes the Cython dependency. Assigning @gijzelaerr to check if this is more acceptable from a packaging perspective. Behaviour is modelled on rasterio, one of the more successful repositories I could find which also uses Cython. Default behaviour is to use .c and .cpp files instead of Cythonising. Will Cythonise locally if Cython is installed. This should be "safe" behaviour.