Skip to content

You should clearly specify dependencies #516

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
pytestbot opened this issue May 13, 2014 · 9 comments
Closed

You should clearly specify dependencies #516

pytestbot opened this issue May 13, 2014 · 9 comments
Labels
type: bug problem that needs to be addressed

Comments

@pytestbot
Copy link
Contributor

Originally reported by: Ondřej Čertík (BitBucket: certik, GitHub: certik)


If you just install the pytest package, it will fail to run with:

$ py.test --version
Traceback (most recent call last):
  File "/nh/nest/u/ondrej/repos/hashstack/default/bin/py.test", line 8, in <module>
    from pkg_resources import load_entry_point
  File "/tmp/bld2/profile/xhyi5yguwlf4/lib/python2.7/site-packages/pkg_resources.py", line 2749, in <module>
    working_set = WorkingSet._build_master()
  File "/tmp/bld2/profile/xhyi5yguwlf4/lib/python2.7/site-packages/pkg_resources.py", line 444, in _build_master
    ws.require(__requires__)
  File "/tmp/bld2/profile/xhyi5yguwlf4/lib/python2.7/site-packages/pkg_resources.py", line 725, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/tmp/bld2/profile/xhyi5yguwlf4/lib/python2.7/site-packages/pkg_resources.py", line 628, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: py>=1.4.20

So you should:


@pytestbot
Copy link
Contributor Author

Original comment by Ondřej Čertík (BitBucket: certik, GitHub: certik):


This came up here: hashdist/hashstack#270

@pytestbot
Copy link
Contributor Author

Original comment by Ondřej Čertík (BitBucket: certik, GitHub: certik):


Found it: you can get the py package from here: https://pypi.python.org/pypi/py, after installing it, pytest works.

@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


How did you install pytest originally? If you use pip or easy_install the dependency should be installed automatically.

@pytestbot
Copy link
Contributor Author

Original comment by Jurko Gospodnetić (BitBucket: jurko, GitHub: jurko):


There are more dependencies than that, depending on your exact environment. For example, you need colorama on Windows and argparse on Python prior to 2.7. You can see all the requirements specified in the standard setup.py setup script.

However, the standard way to install Python packages is using setuptools or pip - both of which would have picked up the py package from PyPI automatically.

For that matter, I do not think you can install pytest directly using distutils only - its setup.py expects setuptools to be already available in the used Python environment.

Maybe I'm missing here, but I don't see how unless you managed to not have py installed unless you're doing something like copy-installing the pytest sources yourself, or py installation somehow failed or you explicitly removed it after it got installed.

Best regards,
Jurko Gospodnetić

@pytestbot
Copy link
Contributor Author

Original comment by Ondřej Čertík (BitBucket: certik, GitHub: certik):


I posted link above to Hashdist, we install all dependencies ourselves, explicitly. The actual script that is used for py.test is:

$ hit show script pytest
set -e
export HDIST_IN_BUILD=yes
export PYTHONPATH=${ARTIFACT}/lib/python2.7/site-packages:${PYTHONPATH}
mkdir -p ${ARTIFACT}/lib/python2.7/site-packages
${PYTHON} -c 'import setuptools; __file__="setup.py"; execfile(__file__)' \
   install \
   --prefix=. --root=${ARTIFACT} \
   --single-version-externally-managed
rm -rf ${ARTIFACT}/lib/python2.7/site-packages/*.pth

export PYTHONPATH=${ARTIFACT}/lib/python2.7/site-packages:$PYTHONPATH
mkdir -p ${ARTIFACT}/lib/python2.7/site-packages

Essentially it's just the usual python setup.py install with the --single-version-externally-managed flag, but that's not important.

The point is that you should clearly mention what dependencies should be installed, or mention that the list of dependencies can be found in such and such place.

The pip tool is nice, but not everybody is using it. One approach is to say, well, if you are not installing things using pip, then it is your problem. But I really think just a simple sentence clarifying the dependencies is a better way to go.

@pytestbot
Copy link
Contributor Author

Original comment by Jurko Gospodnetić (BitBucket: jurko, GitHub: jurko):


Don't know about you... but I'm used to Python packages coming with their meta-data such as a list of requirements defined by their setup.py script.

Ok, pytest could specify its dependencies in its docs, but that is most likely more trouble than it is worth. setup.py contains whatever logic is necessary to list the dependencies appropriate to your environment, and should be as easy to read as any docs, and automatically better maintained - since it's living code. 😄

One thing that pytest could do is specify its requirements using the requires setup() parameter - something like: requires=['py(>=1.4.20)']. That would allow you to list the package's requirements by running setup.py --requires.

Currently they are listed only as setuptool's install_requires parameter, which can not be listed by simple distutils.

I'll take a look at that and prepare a pull request (but I'm not touching the docs ;-)).

Best regards,
Jurko Gospodnetić

@pytestbot
Copy link
Contributor Author

Original comment by Jurko Gospodnetić (BitBucket: jurko, GitHub: jurko):


Added pull request #167. No doc updates from me though... gdr

Best regards,
Jurko Gospodnetić

@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


fix issue516: tell in getting-started about current dependencies.

cleanup setup.py a bit and specify supported versions. Thanks Jurko
Gospodnetic for the PR.

@pytestbot
Copy link
Contributor Author

Original comment by Ondřej Čertík (BitBucket: certik, GitHub: certik):


Thanks! The actual doc update is here: https://bitbucket.org/hpk42/pytest/commits/bc65c038840604f24dc0c82f1abfaee01f0b3f4a

@pytestbot pytestbot added the type: bug problem that needs to be addressed label Jun 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

1 participant