-
Notifications
You must be signed in to change notification settings - Fork 876
Split version info into a separate file, load it using imp/importlib #824
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
Conversation
I wonder if we should revert back to including the old It's just that this feels like an dirty hack while that feels much cleaner as the module is never added to the PYTHONPATH and does not pollute any namespace. And as we used it for years, it is well tested and already developed. |
I kind of agree with the old way. I currently do something very similar in my packages and haven't felt the need to change so far. |
And while we're at is perhaps we might want to add |
Thanks for the link to the old code. I don't mind reverting to it, but in such case it would be nice to replace deprecated imp (which was used in setup.py) with importlib. Otherwise the approach is basically the same as here — passing And also +1 for running |
Replying to myself:
It looks like there is no way to pass a path to importlib that will work with both Python 2 and Python 3. So we have these options:
|
|
And I just realized Let's just keep the existing change for now. We can reexamine when we drop Python 2.7. Add the |
Done. |
While I'm not concerned with how this is ultimately solved here (as long as it works 🙂), recreating something similar to the old way without imp isn't too bad. I've been able to do it here: facelessuser/pymdown-extensions#569. In my case, I just left the old PY2 implementation under a conditional as I simply plan on ripping it out when PY2 is finally put down. Anyways, just options. |
If someone wants to do the work, I'm open to @facelessuser's suggestion. |
I'm not crazy about that using |
The StackOverflow answer I posted above has a solution without I can copy it here however I don’t see the benefits compared to my approach. Are there any? |
As I stated before...
|
Either way is fine. Some people get uncomfortable using
And as far as benefits over this pull 🤷♂ . I'm not personally using Ultimately, I'm not concerned with what gets done in the end. My preference is just importing the version stuff as a separate file, but if adding the |
I just tried out |
Done. Please review the latest version. |
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not crazy about moving the version stuff back out to a separate file (I suspect it would have worked fine with that left in __init__.py
) but it's fine. And __meta__.py
makes sense as a name.
It worked on Python 3 but not on Python 2: Traceback (most recent call last):
File "setup.py", line 46, in <module>
__version__, __version_info__ = get_version()
File "setup.py", line 36, in get_version
markdown = imp.load_source('markdown', module_path)
File "markdown/__init__.py", line 25, in <module>
from .core import Markdown, markdown, markdownFromFile
ValueError: Attempted relative import in non-package That’s why I had to split it into a separate file. |
With a comment in the release notes, this should be good to go. |
Added. |
@mitya57 good job! much appreciated. |
To make sure
markdown
module is importable during installation.It fixes Travis tests and also fixes
python3 -m pep517.check
, so I hope it closes #823.