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

More validation of packaging data #154

Merged
merged 11 commits into from
Dec 12, 2017
Merged

More validation of packaging data #154

merged 11 commits into from
Dec 12, 2017

Conversation

takluyver
Copy link
Member

This should make it easier to catch mistakes in packaging sooner.

The design is slightly awkward: a series of validation functions build up a list of problems. These are logged at 'error' level, and then a ConfigError is raised. I'm doing it this way so that it's easy to see multiple problems at once, not just the first one it finds.

@takluyver
Copy link
Member Author

This is taking shape. I have added an environment variable FLIT_ALLOW_INVALID. If Flit erroneously rejects your metadata, you can use this as an escape hatch:

FLIT_ALLOW_INVALID=1 flit build

@takluyver
Copy link
Member Author

@Carreau I've extended the PEP 440 checks on the version number. Now it tries to normalise the version to the canonical PEP 440 form, with an error if it can't do that, and a warning if it can do that and it has to change the version.

@takluyver takluyver changed the title WIP: More validation of packaging data More validation of packaging data Dec 11, 2017
@@ -139,6 +139,19 @@ Environment variables
See :ref:`uploading packages with environment variables <upload_envvars>`
for more information.

.. envvar:: FLIT_ALLOW_INVALID
Copy link
Contributor

Choose a reason for hiding this comment

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

FLIT_ALLOW_INVALID_METADATA ? You may want invalid other things later on ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I'll live with that risk. I'm not sure that the scope of 'metadata' is very clear, e.g. entry points are not part of the [tool.flit.metadata] table.

This is meant to be an escape hatch for when a check is wrong, so I don't think it needs to be fine-grained.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm ok with it, it was mostly a question. You're the boss, boss.

Copy link
Member Author

Choose a reason for hiding this comment

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

who's the boss

It was a point worth thinking about :-)

flit/validate.py Outdated
# Linux, Unix, AIX, etc.
# use ~/.cache if empty OR not set
xdg = os.environ.get("XDG_CACHE_HOME", None) or (
os.path.expanduser('~/.cache'))
Copy link
Contributor

Choose a reason for hiding this comment

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

Hard to read indentation (IMHO)

Copy link
Member Author

Choose a reason for hiding this comment

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

Is the new commit better? I'm not quite sure what was making it tricky.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's just no indentation after the or (\n, looks to my eyes (brain?), like a missing assignment. At least I don't easily see the it's part of the above assignment. It may be britany's brain flakes are of low quality.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, I see it now. It was so misleading I didn't even notice what it was meant to be ;-)

flit/validate.py Outdated
log.info('Fetching list of valid trove classifiers')
resp = requests.get(
'https://pypi.python.org/pypi?%3Aaction=list_classifiers')
resp.raise_for_status()
Copy link
Contributor

Choose a reason for hiding this comment

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

possibly find the corresponding URL for warehouse, and use as a fallback ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've found https://pypi.org/pypi?%3Aaction=list_classifiers , but I'm asking whether it's something we can rely on before I switch to it: pypi/warehouse#1300

Copy link
Member Author

Choose a reason for hiding this comment

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

Donald says it's safe to rely on, so I've switched to that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good !

@takluyver
Copy link
Member Author

Thanks for the review :-) . Do you want to look any more at it, or shall one of us press the big green button?

@Carreau
Copy link
Contributor

Carreau commented Dec 12, 2017 via email

@takluyver
Copy link
Member Author

I've just tried it with a bunch of projects I've got on this machine, and it wasn't causing any problems, so I'm going to merge it now. I'll give it a day or two in master before making a new release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants