Skip to content

Unable to pip install jsonschema because of setup_requires vcversioner #276

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

Closed
Lucas-C opened this issue Mar 4, 2016 · 16 comments
Closed

Comments

@Lucas-C
Copy link

Lucas-C commented Mar 4, 2016

I basically have the same issue as #257.

The problem is well detailed here :

Basically, setup_requires is very cumbersome option when you want to avoid a simple pip install to talk to Pypi.
Even the fix detailed on pypa/pip#410 does not work for me as I don't use a local directory for my dependencies but an online repository of artifacts.
Do you think setup_requires could be removed ?

@Julian
Copy link
Member

Julian commented Mar 8, 2016

Hi.

Thanks for opening this. Can you provide a bit more detail on your setup and what specifically you're running into -- I'm not sure I can tell from your description. It sounds like possibly you're saying that you generated an offline sdist and then couldn't install it --

vcversioner is a setup-time dep. It's needed to generate version information and it should be running every time the setup.py runs.

If you want to avoid it presumably you want to generate e.g. a wheel instead.

@Lucas-C
Copy link
Author

Lucas-C commented Mar 8, 2016

Quoting https://pip.pypa.io/en/latest/user_guide/ :

Finally, beware of the setup_requires keyword arg in setup.py. The (rare) packages that use it will cause those dependencies to be downloaded by setuptools directly, skipping pip's protections. If you need to use such a package, see Controlling setup_requires.

I really don't think I need a wheel package here, it is just an issue with setuptools retrieving vcversionner from Pypi. I think install_requires is a better fit here.

Here is what happens for me when I try to install jsonschema from a standalone tar.gz :

$ pip install --no-deps http://nexus/content/repositories/pip/com/vsct/pip/jsonschema/2.5.1/jsonschema-2.5.1-py2.py3-none-any.tar.gz
Collecting http://nexus/content/repositories/pip/com/vsct/pip/jsonschema/2.5.1/jsonschema-2.5.1-py2.py3-none-any.tar.gz
  Downloading http://nexus/content/repositories/pip/com/vsct/pip/jsonschema/2.5.1/jsonschema-2.5.1-py2.py3-none-any.tar.gz (50kB)
    100% |████████████████████████████████| 53kB 39.5MB/s
    Complete output from command python setup.py egg_info:
    Download error on https://pypi.python.org/simple/vcversioner/: [Errno -2] Name or service not known -- Some packages may not be found!
    Couldn't find index page for 'vcversioner' (maybe misspelled?)
    Download error on https://pypi.python.org/simple/: [Errno -2] Name or service not known -- Some packages may not be found!
    No local packages or download links found for vcversioner
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "/tmp/pip-m8t_qw1k-build/setup.py", line 44, in <module>
        vcversioner={"version_module_paths" : ["jsonschema/_version.py"]},
      File "/export/appl/wascscu1/anaconda3/lib/python3.5/distutils/core.py", line 108, in setup
        _setup_distribution = dist = klass(attrs)
      File "/export/appl/wascscu1/anaconda3/lib/python3.5/site-packages/setuptools-18.5-py3.5.egg/setuptools/dist.py", line 268, in __init__
      File "/export/appl/wascscu1/anaconda3/lib/python3.5/site-packages/setuptools-18.5-py3.5.egg/setuptools/dist.py", line 313, in fetch_build_eggs
      File "/export/appl/wascscu1/anaconda3/lib/python3.5/site-packages/setuptools-18.5-py3.5.egg/pkg_resources/__init__.py", line 843, in resolve
      File "/export/appl/wascscu1/anaconda3/lib/python3.5/site-packages/setuptools-18.5-py3.5.egg/pkg_resources/__init__.py", line 1088, in best_match
      File "/export/appl/wascscu1/anaconda3/lib/python3.5/site-packages/setuptools-18.5-py3.5.egg/pkg_resources/__init__.py", line 1100, in obtain
      File "/export/appl/wascscu1/anaconda3/lib/python3.5/site-packages/setuptools-18.5-py3.5.egg/setuptools/dist.py", line 380, in fetch_build_egg
      File "/export/appl/wascscu1/anaconda3/lib/python3.5/site-packages/setuptools-18.5-py3.5.egg/setuptools/command/easy_install.py", line 632, in easy_install
    distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('vcversioner')

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-m8t_qw1k-build

I found a workaround, but it is hacky :

$ cat <<EOF > ~/.pydistutils.cfg
[easy_install]
allow_hosts = nexus
find_links = http://nexus/content/repositories/pip/com/vsct/pip/vcversioner/2.14.0.0/
EOF

@Julian
Copy link
Member

Julian commented Mar 8, 2016

install_requires is not a substitute for setup_requires. They do different things. vcversioner is not an install-time dependency, it's a setup-time dependency. install_requires would be completely incorrect, and wouldn't actually work when installing the package. Yes that means easy_install will unfortunately retrieve it, rather than pip. I'm aware that's bad :), it's just the least-bad thing that currently exists for versioning. I'm definitely open to other ideas, but as far as I'm aware, nothing better exists.

ISTM then that this isn't a setuptools issue, this is working as expected. If you do want a completely offline install that didn't invoke a setup.py at all that's exactly what a wheel could do for you.

Gonna close this for now, but if you want to discuss further feel free to reopen / follow up.

Appreciate the report though certainly.

@Julian Julian closed this as completed Mar 8, 2016
@Lucas-C
Copy link
Author

Lucas-C commented Mar 9, 2016

Thanks for your answer

@ewmiller
Copy link

I understand this has been closed and you're probably busy with other things, but unfortunately the same issue is preventing me from using jsonschema (and by extension, all of the libraries that depend on it).

I'm experiencing the same problem as Lucas-C, except I can't use a wheel for offline install because pip's --no-binary flag is required by my deployment environment. I also can't seem to edit the easy_install settings due to a permissions issue. I'm behind a corporate firewall and we maintain an internal python package registry, but the setup.py script keeps looking for the external PyPi registry and failing in my build/deploy environment (because it's cut off from the regular internet). Is there any way to give that script an argument to look elsewhere besides PyPi? Or any other suggestions for how to get around this?

Again, I know you're busy so don't feel obligated to fix this yourself. If you can point me in the right direction for some other options I'd be happy to look into it myself and even make a pull request if I come up with something. Let me know, thanks!

@Julian
Copy link
Member

Julian commented Jan 17, 2018

Hm, that doesn't sound likely to be related -- if you can't use wheels, you still can use sdists, which should ship with a version.txt -- have you tried that? If it's contacting PyPI it wouldn't be for version issues, it'd sound like you're missing a dep.

@ewmiller
Copy link

ewmiller commented Jan 17, 2018

Thanks for the response. When jsonschema's setup.py script runs after collecting jsonschema, it looks to PyPi to download jsonschema's vcversioner dependency at setup time, but again PyPi is blocked. Even separately installing vcversioner before installing jsonschema doesn't work for some reason. It always tries to reach out to PyPi even if the vcversioner dependency is present on the machine. Here's my install command (leaving out the url of my company's repo):

pip3 download -d vendor -r requirements.txt --index [internal corporate repo] --index-url [internal corporate repo] --no-binary :all:

And here's the log output where the install fails (again leaving out my company's url, but you can see that it finds jsonschema fine but then can't find its vcversioner dependency):

build	15-Jan-2018 15:43:53	  Downloading [internal corporate repo]/jsonschema-2.6.0.tar.gz (53kB)
build	15-Jan-2018 15:43:53	  Saved ./vendor/jsonschema-2.6.0.tar.gz
build	15-Jan-2018 15:48:08	    Complete output from command python setup.py egg_info:
build	15-Jan-2018 15:48:08	    Download error on https://pypi.python.org/simple/vcversioner/: [Errno 101] Network is unreachable -- Some packages may not be found!
build	15-Jan-2018 15:48:08	    Couldn't find index page for 'vcversioner' (maybe misspelled?)
build	15-Jan-2018 15:48:08	    Download error on https://pypi.python.org/simple/: [Errno 101] Network is unreachable -- Some packages may not be found!
build	15-Jan-2018 15:48:08	    No local packages or download links found for vcversioner>=2.16.0.0
build	15-Jan-2018 15:48:08	    Traceback (most recent call last):
build	15-Jan-2018 15:48:08	      File "<string>", line 1, in <module>
build	15-Jan-2018 15:48:08	      File "/tmp/pip-build-tang4y3f/jsonschema/setup.py", line 42, in <module>
build	15-Jan-2018 15:48:08	        vcversioner={"version_module_paths" : ["jsonschema/_version.py"]},
build	15-Jan-2018 15:48:08	      File "/usr/lib64/python3.4/distutils/core.py", line 108, in setup
build	15-Jan-2018 15:48:08	        _setup_distribution = dist = klass(attrs)
build	15-Jan-2018 15:48:08	      File "/usr/lib/python3.4/site-packages/setuptools/dist.py", line 268, in __init__
build	15-Jan-2018 15:48:08	        self.fetch_build_eggs(attrs['setup_requires'])
build	15-Jan-2018 15:48:08	      File "/usr/lib/python3.4/site-packages/setuptools/dist.py", line 312, in fetch_build_eggs
build	15-Jan-2018 15:48:08	        replace_conflicting=True,
build	15-Jan-2018 15:48:08	      File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 846, in resolve
build	15-Jan-2018 15:48:08	        dist = best[req.key] = env.best_match(req, ws, installer)
build	15-Jan-2018 15:48:08	      File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 1091, in best_match
build	15-Jan-2018 15:48:08	        return self.obtain(req, installer)
build	15-Jan-2018 15:48:08	      File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 1103, in obtain
build	15-Jan-2018 15:48:08	        return installer(requirement)
build	15-Jan-2018 15:48:08	      File "/usr/lib/python3.4/site-packages/setuptools/dist.py", line 379, in fetch_build_egg
build	15-Jan-2018 15:48:08	        return cmd.easy_install(req)
build	15-Jan-2018 15:48:08	      File "/usr/lib/python3.4/site-packages/setuptools/command/easy_install.py", line 632, in easy_install
build	15-Jan-2018 15:48:08	        raise DistutilsError(msg)
build	15-Jan-2018 15:48:08	    distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('vcversioner>=2.16.0.0')

This happens even though I told pip to use the internal corporate repo instead of PyPi. As mentioned before, setup.py doesn't use pip so it doesn't know to look at the internal repo for the vcversioner dependency.

Let me know if you have other questions or if I'm being unclear in any way. Thanks again!

@Julian Julian reopened this Jan 17, 2018
@Julian
Copy link
Member

Julian commented Jan 17, 2018

You should be able to use a pydistutils.cfg (which you can put in ~ amongst some other places) I believe to get easy_install to also be looking at your internal corporate PyPI.

@ewmiller
Copy link

TL;DR - that might not work because of how my application gets deployed. Explanation follows:

We use Pivotal Cloud Foundry to deploy our applications. The python buildpack for PCF states that, for offline deployment environments, all dependencies must be downloaded and "vendored" beforehand, then sent to the deployment environment - where they are installed from the downloaded archives. The docs can be viewed here (they're not too long).

I was able to do what you said and get easy_install to use the corporate pypi for the first stage - the initial downloading and archiving of the dependencies. However, for the next step where it gets sent to the remote deployment environment that has no internet connection, it has the same problem as before. It collects jsonschema, runs the same setup.py script, and tries to look for vcversioner in regular pypi. Since vcversioner isn't an install-time dependency it doesn't get downloaded and archived in the same way as all the other dependencies; setup.py only looks for it at setup time. But the remote deployment environment doesn't have the same config file as the previous step, so it fails again.

In addition, I don't think I'm able to add that config file to the deployment environment. Manual access is discouraged and these servers get destroyed/rebuilt all the time so doing it manually would suck. And I'm not sure if Cloud Foundry lets you run arbitrary bash scripts on the deployment servers before the buildpack gets used, but that's something I can look into further.

Again, I appreciate the help. I know this is a scenario that most people might not run into but it's been frustrating. I'm going to continue looking into it tomorrow so I will update if I find out I was wrong and I am able to get that config file out there.

@ewmiller
Copy link

ewmiller commented Jan 18, 2018

To follow up, I opened the above ticket with Pivotal themselves to see if there's a way I can configure my deployment environment with the fix you mentioned. It will depend on what they say; if it's not possible then I might just not be able to use this library unfortunately. Hopefully there's another workaround though.

@iandanforth
Copy link

This is hurting downstream packages as well. Same error when trying to install altair which depends on jsonschema.

@Julian
Copy link
Member

Julian commented Mar 16, 2018

@iandanforth is it also in some sort of weirdly constrained environment? I still don't see a jsonschema bug here but happy to keep discussing until we get to a conclusion

@iandanforth
Copy link

Odd maybe, but I wouldn't say constrained

OSX - 10.13.2 - High Sierra
System Python is 2.7.12

I install dependencies for new projects using pipenv so

mkdir project
cd project
pipenv install
pipenv shell
pipenv install jsonschema
Installing jsonschema…
Downloading/unpacking jsonschema
  Running setup.py egg_info for package jsonschema
    Couldn't find index page for 'vcversioner' (maybe misspelled?)
    No local packages or download links found for vcversioner>=2.16.0.0
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "/Users/iandanforth/.local/share/virtualenvs/jsonschemaissue-OxPQQI4r/build/jsonschema/setup.py", line 42, in <module>
        vcversioner={"version_module_paths" : ["jsonschema/_version.py"]},
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 111, in setup
        _setup_distribution = dist = klass(attrs)
      File "/Users/iandanforth/.local/share/virtualenvs/jsonschemaissue-OxPQQI4r/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/dist.py", line 260, in __init__
      File "/Users/iandanforth/.local/share/virtualenvs/jsonschemaissue-OxPQQI4r/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/dist.py", line 284, in fetch_build_eggs
      File "/Users/iandanforth/.local/share/virtualenvs/jsonschemaissue-OxPQQI4r/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 563, in resolve
      File "/Users/iandanforth/.local/share/virtualenvs/jsonschemaissue-OxPQQI4r/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 799, in best_match
      File "/Users/iandanforth/.local/share/virtualenvs/jsonschemaissue-OxPQQI4r/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 811, in obtain
      File "/Users/iandanforth/.local/share/virtualenvs/jsonschemaissue-OxPQQI4r/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/dist.py", line 327, in fetch_build_egg
      File "/Users/iandanforth/.local/share/virtualenvs/jsonschemaissue-OxPQQI4r/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 434, in easy_install
      File "/Users/iandanforth/.local/share/virtualenvs/jsonschemaissue-OxPQQI4r/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/package_index.py", line 475, in fetch_distribution
    AttributeError: 'NoneType' object has no attribute 'clone'
    Complete output from command python setup.py egg_info:
    Couldn't find index page for 'vcversioner' (maybe misspelled?)

No local packages or download links found for vcversioner>=2.16.0.0

Installing vcversioner separately works and then installing jsonschema works as expected.

@Julian
Copy link
Member

Julian commented Mar 18, 2018

@iandanforth setuptools 0.6c11 is absurdly old :) (about 10 years so).

Your issue is that it's so old it doesn't understand what needs to happen for the install I'd suspect. Upgrade to a reasonably modern one and I think you'll be fine.

Credit to @dimino for noticing.

@iandanforth
Copy link

Confirmed! Thanks osx system python!

@Julian
Copy link
Member

Julian commented Apr 7, 2018

It's likely the next version of jsonschema will use setuptools_scm instead of vcversioner, though they serve the same purpose --

I'm still not convinced there's any jsonschema bug here, all the previous examples have been either obscure build/install environments or some simple user error, so going to re-close this, but if anyone continues to have issues and thinks there's an actual issue with the library, feel free to comment and I'll reopen.

For the build/install environment case, I'd encourage you guys to file bugs upstream if you're concerned about the interaction between install_requires and the exact setup you've got, jsonschema itself isn't doing anything special here really, but yeah see above, if you think it's jsonschema specific, happy to discuss.

@Julian Julian closed this as completed Apr 7, 2018
Julian added a commit that referenced this issue Sep 4, 2019
6b673312 Merge pull request #276 from malcolmsparks/patch-1
4b55dc38 Renamed JUXT's Clojure implementation to jinx
b173eaa2 Merge pull request #275 from Zac-HD/tweaks
3768953e Valid test for contains: false
798351be Valid test for contains: false

git-subtree-dir: json
git-subtree-split: 6b6733126e5cd571fc6b7a1a5a8190a09d6cb7b9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants