Menu

#4 Automatically run "config" if necessary

pending
None
5
2018-09-04
2018-08-04
Bewied
No

I just became the co-maintainer of the PyPI, because I'd like to see this package there. I was successful with it, but want to let you know of the workarounds I had to do, because I think this might also bother other people.

Second (of two), setup.py really wants to be called with config before anything else. This is incompatible with what pip (and probably all other) tools assume about setup.py, and breaks all automation. However, the way setup.py was written enables a very very easy workaround: Just do the config step then. No invocation needed!

Here's a patch:

--- a/setup.py
+++ b/setup.py
@@ -147,12 +147,9 @@
 except ImportError:
     # Config is required ... no need to proceed any further
     if "config" not in sys.argv:
-        msg = """Could not import gsl_config. You have to execute the config
-step first.
-Presumed commnd: %s %s config
-"""          
-        print(msg % (sys.executable, "setup.py"))
-        sys.exit(1)
+        # Spoof it like you mean it
+        sys.argv = sys.argv[0:1] + ["config"] + sys.argv[1:]
+        print("Spoofing argument: config")

 exts = []
 extsOnly2 = []

Please let me know what you think. Maybe there's an even better solution?

Related

Feature Requests: #4

Discussion

  • Pierre Schnizer

    Pierre Schnizer - 2018-08-06
    • status: open --> pending
    • assigned_to: Pierre Schnizer
     
  • Pierre Schnizer

    Pierre Schnizer - 2018-08-06

    Dear Ben,

       thanks again for the patch. I will try it out and then report my results. From first sight I guess an import is missing.
    

    Sincerely yours
    Pierre

     
  • Bewied

    Bewied - 2018-08-07

    Do you mean "import sys"? That's already there, in line 71.

    Thanks for your quick responses!

     
  • Bewied

    Bewied - 2018-09-04

    Did you already find something?

     
  • Bewied

    Bewied - 2018-09-04
     
    • Pierre Schnizer

      Pierre Schnizer - 2018-09-05

      But won’t work with python2 yet (some super calls need to be fixed). And I need to test it on linux and win
      Will take two or three more days ….

      Sincerely yours
      Pierre

      Von: Bewied [mailto:bewied@users.sourceforge.net]
      Gesendet: Dienstag, 4. September 2018 21:44
      An: [pygsl:feature-requests] 4@feature-requests.pygsl.p.re.sourceforge.net
      Betreff: [pygsl:feature-requests] #4 Automatically run "config" if necessary

      Sorry, saw https://sourceforge.net/p/pygsl/GitRepro/ci/f3989d7f2cc906b1487a5f0303cd2ce1200baa97/#diff-4 only just now. Thanks!


      [feature-requests:#4]https://sourceforge.net/p/pygsl/feature-requests/4/ Automatically run "config" if necessary

      Status: pending
      Group: Next_Release_(example)
      Created: Sat Aug 04, 2018 10:32 PM UTC by Bewied
      Last Updated: Tue Sep 04, 2018 07:42 PM UTC
      Owner: Pierre Schnizer

      I just became the co-maintainer of the PyPI, because I'd like to see this package there. I was successful with it, but want to let you know of the workarounds I had to do, because I think this might also bother other people.

      Second (of two), setup.py really wants to be called with config before anything else. This is incompatible with what pip (and probably all other) tools assume about setup.py, and breaks all automation. However, the way setup.py was written enables a very very easy workaround: Just do the config step then. No invocation needed!

      Here's a patch:

      --- a/setup.py

      +++ b/setup.py

      @@ -147,12 +147,9 @@

      except ImportError:

       # Config is required ... no need to proceed any further
      
       if "config" not in sys.argv:
      
      • msg = """Could not import gsl_config. You have to execute the config

      -step first.

      -Presumed commnd: %s %s config

      -"""

      • print(msg % (sys.executable, "setup.py"))

      • sys.exit(1)

      • Spoof it like you mean it

      • sys.argv = sys.argv[0:1] + ["config"] + sys.argv[1:]

      • print("Spoofing argument: config")

      exts = []

      extsOnly2 = []

      Please let me know what you think. Maybe there's an even better solution?


      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/pygsl/feature-requests/4/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/


      Helmholtz-Zentrum Berlin für Materialien und Energie GmbH

      Mitglied der Hermann von Helmholtz-Gemeinschaft Deutscher Forschungszentren e.V.

      Aufsichtsrat: Vorsitzender Dr. Karl Eugen Huthmacher, stv. Vorsitzende Dr. Jutta Koch-Unterseher
      Geschäftsführung: Prof. Dr. Bernd Rech (kommissarisch), Thomas Frederking

      Sitz Berlin, AG Charlottenburg, 89 HRB 5583

      Postadresse:
      Hahn-Meitner-Platz 1
      D-14109 Berlin

      https://www.helmholtz-berlin.de

      Abonnieren Sie unseren monatlichen Newsletter!https://www.helmholtz-berlin.de/aktuell/pm/newsletter/
      Subscribe to our monthly newsletter!https://www.helmholtz-berlin.de/aktuell/pm/newsletter/index_en.html

       

      Related

      Feature Requests: #4


Log in to post a comment.