-
Notifications
You must be signed in to change notification settings - Fork 862
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
setup.py shouldn't import the package it installs #823
Comments
cf #791 |
The same thing now happens in Travis BTW, see https://travis-ci.org/Python-Markdown/markdown/builds/531020063. I am not yet sure what causes it, though — setup.py imports Markdown but Markdown does not import setup.py so there is no cyclic dependency. |
I guess there is one way to be sure, we can perform an experiment. We can move the version stuff to a separate file, and then manually import just that file directly. |
I will try to do that a bit later. Also I don't know if it will be useful or not, but modern setuptools supports specifying the version in setup.cfg in declarative format:
or
The former worked for me some time ago, need to check again. Upd: still works in https://travis-ci.org/retext-project/pymarkups/builds/502474546 although I do not use Tox. |
If you can declare it like you mentioned, and have it exist in one place, maybe that is preferable. |
I was able to fix Travis tests by setting PYTHONPATH to the current directory: https://github.com/mitya57/Python-Markdown/commit/291a71239a245371a0ad455ec6a279b02814c235. Strangely, I was not able to reproduce the original problem locally, even when using tox. @greut How exactly are you calling setup.py? Can you check if setting |
@mitya57 I'm installing it via Requirements-Builder and the git+https URL. Pip fails into the Is the project fully PEP517 compliant? edit strangely django/django installs just fine and it seems to perform same kind of 🐔 and 🥚. So it should be possible. |
btw |
This is definitely a PEP517 issue, which makes this a duplicate of #791. However, I'm closing that as this better identifies the issue. Under Build Environment, PEP517 states:
Note that the cwd is not listed among the locations which we can assume to have access to (this is the change which is breaking things. We have always been able to make that assumption in the past). In a later subsection, In-Tree Build Backends, there is a provision defined for giving the build environment access to the source tree:
Of course, the source code for the project is not technically part of the build environment backend, in Python-Markdown's case, but we could use it that way if we want to leave the version identification code as-is. @mitya57 demonstrated how we could define the version in I think we should probably explore adopting the new system and use Regardless of what solution we use, we want to only ever define the version in one location. Statically defining the version in multiple locations is only asking for them to get out of sync. I'm having a hard time believing the new system doesn't have a simple API for this already, but I haven't found one. |
Interestingly, when I had first learned of |
I think in-tree backends were not meant to be used this way. The PEP mentions only two use cases: backends themselves and wrappers around existing backends where the wrapper is too project-specific. I think our case does not fall into any of these two.
Can you give a pointer to some documentation about this, or a project that specifies a version in There is flit build system that allows one to specify metadata in
By disutils do you mean distutils? If yes, then I think it does not support getting the version of installed package. One can use |
I performed some search and found a build system called poetry that indeed does allow one to specify version in |
I have just created #824 which is quite ugly but should fix this. It looks like the imported version information is used in three places in setup.py: the version itself, the development status (for classifiers) and the download URL (which is currently broken though). So I decided to not switch to @greut Can you please try to install from |
I have to admit I was writing that based on memory. Perhaps I remembered incorrectly, but I have the impression that
Ah yes, I meant My real point here is that to avoid the need to use I see two options:
|
Most Python projects are still using a As I pointed out, there are build systems (flit, poetry) that allow you to specify metadata directly in
A possible variant 3 may be using setuptools-scm which gets the version from Git (or other Vcs). I am not using it in my projects, but I think it is getting quite popular nowadays. Anyway, my pull request #824 follows option 2 as it is the smallest change that fixes this bug (hopefully, waiting for the submitter’s feedback). I am not sure if “continually” making hacks will be needed — Python ecosystem changes quite slowly but we'll see. |
So I looked at flit and right on the first page is states that you define the version in your sourcecode with
Of course, for us parsing the AST will fail, but the fallback which imports would work fine. My issue is that the import has to be the fallback. We are stuck always using the fallback. On the plus side, flit also does a
I never saw the point of that. If you need the
Exactly. But if we are going to switch, it seems that using the new system would make sense. I'm not convinced that we should make that change now, but it is at least worth considering. As you note, these changes happen slowly, so it will likely be some time before we look at this again. On the other hand, when people starting moving from distutils to setuptools, we took the wait-and-see approach and then found ourselves as one of the few remaining holdouts. While users initially thanked us for holding off, as time progressed we got more and more complaints that we hadn't adopted the new normal.
While I understand the appeal of this, I don't see it as a something I want to use. I find it weird that the version is defined in a tag (meta-data of the VCS), not in any of the files for the project. And it requires the call to |
You usually have both anyway, so it's a matter of taste where to write stuff. Some configuration is easier to write in long_description = file: README is more simple than with open(os.path.join(os.path.dirname(__file__), 'README')) as readme_file:
long_description = readme_file.read()
setup(...
long_description=long_description,
...)
I agree. Maybe let’s look how the Python landscape changes in the coming year(s).
I share the same opinion! I just mentioned that tool to add more choice, just in case you were not aware of it. |
Add pep517check environment to tox Split version info into a separate file, load it using importlib Fixes #823.
There is a 🐔 and 🥚 problem regarding how setup.py works. the version number should be parsed from the text file rather than imported via python mechanism.
The text was updated successfully, but these errors were encountered: