GithubHelp home page GithubHelp logo

Comments (4)

PiRK avatar PiRK commented on July 19, 2024

I can see two simple solutions.

The simplest, which solves only the problem of git complaining, is to put specfile.c in .gitignore. Whenever a change is made to the .pyx file, one has to remember to do a git add --force silx/io/specfile/specfile.c after the file has been regenerated. This solution has the advantage of not adding any line of code to the setup.py and not changing the current behavior of setup.py.

The second solution is to also add the auto-generated file to .gitignore, then to make a copy of it to a file (for instance specfile.c.in) that will not be ignored, and to add code to the setup.py to copy specfile.c.in to specfile.c before compiling unless the command line --force-cython is specified when running setup.py. This adds a manual copy step and makes setup.py more complex. The check_cython() would have to be changed in the general setup.py: --no-cython, fake_cythonize() and os.environ["WITH_CYTHON"] = "False" should become the default behavior.

This second option only makes sense if we don't trust Cython on the user computer to generate proper .c files.

from silx.

vasole avatar vasole commented on July 19, 2024

The first solution still overwrites the supplied reference file.

The second solution serves to check if something was wrong at the
building end with, for instance, a buggy cython or for speeding up things.

I am full for copying/renaming a supplied file and not just adding it to
the list of ignored files.

from silx.

PiRK avatar PiRK commented on July 19, 2024

I worked on the issue, and found that if we want to go down that road, the required steps would be:

  • supply a default file, either in a different folder than the pyx file, or with a different name than the cython-generated file (e.g silx/io/specfile.c.in)
  • add this file to MANIFEST.in
  • in the local silx/io/setup.py, if os.environ["WITH_CYTHON"]=="False", copy and rename the supplied file to wherever the compiler expects it to be (e.g silx/io/specfile.c)
  • in the general setup.py, move check_cython() before configuration(), so that the environment variable WITH_CYTHON is set before importing the local setup.py
  • optionally: remove the cython-generated C file from the repository (delete and add a line to .gitignore)

This solution seems to work on all tested platforms on my development branch https://github.com/PiRK/silx/tree/nocython

from silx.

vasole avatar vasole commented on July 19, 2024

Ok, from the enhancement the only thing that is going to remain seems to be this:

  • in the general setup.py, move check_cython() before configuration(), so that the environment variable WITH_CYTHON is set before importing the local setup.py

that I think it was already fixed by #73

from silx.

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.