-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Switch to setuptools #346
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
Switch to setuptools #346
Conversation
setuptools comes with virtualenv, and as far as I can tell is the preferred distribution method (until wheels really start to replace eggs). |
also setuptools and distribute merged about a year ago |
Normally, I just use a try...catch statement to try to import setuptools, then fall back distutils. Something like: try:
from setuptools import setup
except:
from distutils.core import setup That way, the program will work on systems without setuptools, but you can use setuptools's extra commands(e.g. develop) if it is installed. |
good call. I added a restriction of only falling back if its an import error. |
Thanks for making the change! I get an error about unknown encoding when using setuptools... this is easy to fix by setting up the mypy encoding in setup.py (it implements Python 3 function annotations in Python 2):
It also seems to try to bytecode compile stub files, even though they are marked as data in setup.py, which is odd. I wonder how this could be prevented, other than by changing the extension. |
So, I seem to have been mistaken when I thought it could be a drop in replacement. |
@mvcisback It technically works, but it must not work right in that manner. You could always try this(UNTESTED): Create a file named MANIFEST.in with the following:
That might cause those files to not be byte-compiled. |
If someone didn't want to install setuptools and such, couldn't they just get the distribution as a wheel? I think that might avoid all this headache |
AFAIK, distros such as Ubuntu 12.04 can't trivially support wheels. It seems that there also needs to be a non-wheel fallback (which might be setuptools?). How does setuptools help with virtualenv? I don't doubt that it does, I just don't know... In the long term, I guess most people will probably use pip install mypy (once that's supported -- but we may want to provide Python 2 packages for mypy itself first) to get mypy, and only developers need to worry about dependencies. It's fine to require developers to install additional dependencies, assuming they don't clash with what they are likely to have installed already. |
The fallback would be an egg or downloading the source and using setuptools (which is easy to get on most platforms).
install_requirements allows you to add package dependencies... these will retrieved when installing. Develop allows you to edit files and test them without constantly rerunning install. This seems trivial except its easy to forget this step and spends unnecessary time debugging.
This is what virtualenv is for. It creates a python sandbox so you don't have to worry about what they have installed already. Doing that globally is probably best left to distributions. |
Also, although its abit clunky, pkg_resources serve as a great way to access datafiles and other things distributed with the package. Its alot cleaner than for example looking for the path of module using |
Update: This PR now also includes a change in the way data like stubs and such are accessed. This allows the removal of a lot of platform specific code and directory walking. |
Sounds reasonable, but I can't get this to work. Here are my problems:
I'm using Ubuntu 12.04 and Python 3.2 as my development environment. |
That's very odd. I'll try with 3.2 and check back. |
I was able to reproduce. My virtualenv had some state because I had previously run python setup.py install.
I was finally able to reproduce this. I have the PYTHONDONTWRITEBYTECODE env var set so this hadn't come up. This also brought up the encoding issue...so I'll try and get these resolved and update the PR |
@JukkaL aside from the environment var or using I may be missing something, but the .py files are still available. Why will the pyc's cause an issue? |
@JukkaL Also, I might be missing something...but is lib-typing supposed to be a separate project or something? 2.7 has its own setup.py. |
Also, the reason why develop is currently broken: TL;DR, package_dir is broken...we could avoid by restructuring the way the typing module (or package). |
lib-typing is mostly separate from the rest of the project... it's just a dependency -- but it has to be in sync with the type checker. Maybe it should have its own setup.py (or even its own git repo). |
BTW, I have fixed some of the setuptools-related issues (e.g. failures due to the codec, Python 2/3 syntax issue). |
I'll take a look later today. |
Yeah, as we expected, changing the extension fixes the byte compiling issue. That makes |
Maybe typing should live in a separate project, and it would just be a dependency? I added a new issue: #377 |
Hm. If we must change the filename extension used for stub files to something other than ".py" just to be able to use setuptools, then I am not in favor of it. A different extension would get in the way of various tools that are useful for stub files, e.g. automatically selecting the syntax mode for editors and IDEs. (I know you can configure this, but it's still a pain.) |
@gvanrossum The filename extension was in consideration from another issue. It just had the added benefit of avoiding that issue. I think the stubs byte compiling can be worked around even with the That said, I think the alternative extension might be beneficial precisely because it doesn't work with existing infrastructure. The idea is documented in #345, but it'd be interesting to support annotations in |
There hasn't been progress in a while. I'm going to close this PR for now -- we can continue the discussion in issue #482 and potentially reopen this PR. |
From my experience setuptools is abit easier to develop with (install vs develop).
It also has great virtualenv integration.