Skip to content
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

Don't import appdirs from setup.py #92

Conversation

leorochael
Copy link
Contributor

In general, setup.py should never import the code it's trying to
install.

During a setup.py run, there is no guarantee that importing appdirs
will actually import the one in the same directory as setup.py.

Instead, read the version number out of appdirs.py by opening it.

Fixes: #91

In general, setup.py should never import the code it's trying to
install.

During a setup.py run, there is no guarantee that importing `appdirs`
will actually import the one in the same directory as `setup.py`.

Instead, read the version number out of `appdirs.py` by opening it.
Copy link

@icemac icemac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

__version_info__ = (1, 4, 3)
__version__ = '.'.join(map(str, __version_info__))
__version__ = "1.4.3"
__version_info__ = tuple(int(segment) for segment in __version__.split("."))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fail if the version number has non-integers in it, like 'dev' or 'alpha' markers. I don't know if this is ever the case for this package. This may be an option then:

__version__ = "1.4.3.dev0"  # as example

def intify(value):
    try:
        return int(value)
    except ValueError:
        return value

__version_info__ = map(intify, __version__.split('.'))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mauritsvanrees!

Indeed the code is expecting integer version segments only.

I went thru all the history of this line and __version_info__ has always been a triple of integers.

In any case, whoever breaks the integer segments expectation will have a very early, reasonably obvious and clear error message in their hands, so I'm tempted to say YAGNI.

But I'm happy to defer to the maintainers on this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module is so small, that we won't do anything other than version numbers. I appreciate the suggested addition though. I will merge the original change in tonight.

Cheers guys!

@zoofood zoofood merged commit 494089c into ActiveState:master Apr 29, 2017
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

Successfully merging this pull request may close these issues.

None yet

4 participants