Skip to content

Regex used to parse index urls from requirements.txt and update pydistutils.cfg is wrong #150

@ewolz3

Description

@ewolz3

What version of Cloud Foundry and CF CLI are you using? (i.e. What is the output of running cf curl /v2/info && cf version?

cf version 6.32.0+0191c33d9.2017-09-26

"api_version": "2.103.0"

What version of the buildpack you are using?
1.6.29

If you were attempting to accomplish a task, what was it you were attempting to do?
Install dependencies from requirements.txt using a custom index-url

Note: This is related to #86 which was partially solved in d8ab4b0#diff-153f90501612878d9c6fcd50247547bc. I say partially fixed because it works if the urls are specified by the -i pip option, but fail if specified by the --index-url or --extra-index-url options because the regex is looking for a single hyphen instead of double hyphen.

What did you expect to happen?
All packages listed in requirements.txt and their dependencies get downloaded from the index-url and extra-index-url specified in requirements.txt

What was the actual behavior?
Dependencies listed in requirements.txt get installed from the custom index URLs, but easy_install/distutils used for installing transitive dependencies was still trying to go out to the public pypi server instead of using my companies private artifactory. This is because the partial fix mentioned above was unable to parse the --index-url and --extra-index-url and so was unable to add them to the pydistutils.cfg file.

The reason for this is because the regex used to parse the index-url and extra-index-url from requirements.txt and write the pydistutil.cfg file is WRONG and does NOT match the verbose command-line options.

The two regexes used are:

  • re := regexp.MustCompile((?m)^\s*(-i|-index-url)\s+(.*)$) (see here)
  • re = regexp.MustCompile((?m)^\s*-extra-index-url\s+(.*)$) (see here)

The two regexes should be (verbose command-line options requires a double hyphen):

  • re := regexp.MustCompile((?m)^\s*(-i|--index-url)\s+(.*)$)
  • re = regexp.MustCompile((?m)^\s*--extra-index-url\s+(.*)$)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions