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

External data directory #510

Merged
merged 7 commits into from Feb 21, 2022
Merged

External data directory #510

merged 7 commits into from Feb 21, 2022

Conversation

takluyver
Copy link
Member

Corresponding to setuptools' data_files, but less flexible: you just get one directory, which will be mapped to wherever the installer decides to put the 'data' component of the wheel (typically the prefix path).

Closes #358.

Flit will package these with no special configuration.

However, sometimes it's useful to package external files for system integration,
such as man pages or files defining a Jupyter extension. To do this, arrange

Choose a reason for hiding this comment

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

perhaps

which rely on well-known paths such as ``man`` pages or defining a Jupyter `extension <https://jupyter-server.readthedocs.io/en/latest/developers/extensions.html>`_ or `kernel <https://jupyter-client.readthedocs.io/en/stable/kernels.html#kernel-specs>`_. To do this, arrange

😊 sorry, I'm sure there's a better way to do this in .rst...

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'm torn on this, but for now I think I'll leave the links out. Jupyter has quite a few different extension points, and I don't want this to grow into a list of ways to extend Jupyter (not that such a list shouldn't exist, but it should be in Jupyter's own docs ;-).

Choose a reason for hiding this comment

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

Yep, sounds good!


For users coming from setuptools: external data corresponds to setuptools'
``data_files`` parameter, although setuptools offers more flexibility.

Choose a reason for hiding this comment

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

Perhaps a note/warning on how/if-at-all this works with editable installs, and how one might go about handling developing these?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, I'm adding a note. They'll get installed, but with a pip install -e development install, they're just copied, so you have to reinstall if anything changes (I don't think PEP 660 really lets us do anything else). If you use flit install --symlink, individual files are symlinked, so you only have to reinstall when adding/removing them.

@takluyver takluyver added this to the 3.7 milestone Feb 17, 2022
@takluyver
Copy link
Member Author

I'll leave this another day or two for any other maintainers (or anyone else!) to look at, otherwise I think it's ready.

Copy link
Contributor

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

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

Fantastic, thanks @takluyver!

Copy link
Member

@pradyunsg pradyunsg left a comment

Choose a reason for hiding this comment

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

This is a review from a sleepy-me. I'll try to take a proper look over the weekend.

flit_core/flit_core/common.py Outdated Show resolved Hide resolved
if data_dir is not None:
toml_key = "tool.flit.external-data.directory"
if not isinstance(data_dir, str):
raise ConfigError(f"{toml_key} must be a string")
Copy link
Member

Choose a reason for hiding this comment

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

Do you want to add tests for these error branches, that codecov is complaining aren't covered?

Copy link
Member Author

Choose a reason for hiding this comment

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

It feels too much like testing that the code I've written is the code that's there, which always feels a bit pointless. If someone wants to add some test cases and push coverage up a bit, I'm happy enough to merge it, but I don't feel like it's worth spending time on.

If someone finds a case where it's currently doing the wrong thing, I'm happier to add a test for that as we fix it.

@takluyver takluyver merged commit 4794dce into main Feb 21, 2022
@takluyver takluyver deleted the data-dir branch February 21, 2022 18:52
@maartenbreddels
Copy link

Just want to say, perfect. Simple solution that does exactly what I want, no complicated mapping/rename etc, just plain and simple 👍

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.

Support for data files installation
5 participants