Open zaneselvans opened 5 years ago
Here are my notes:
PS. Jesus crist, start using the src-layout already!
Okay, thank you for the push and all of the clearly written references @ionelmc. I went ahead and bit the bullet and completely re-organized the repository to:
src
layout, separating the package from the main repository directory.pkg_resources
to access those files instead of referring to them relative to __file__
setuptools_scm
to generate / pull the current version from gittox
to create the package, install it, and run pytest against the installed version, as well as try to generate the documentation with Sphinx.It generally seems to be working locally. There's some more work to disentangle our current pattern of use from the repository before I can see how it runs on Travis, which will include converting our existing scripts into modules and using console_scripts
with entry_points
.
Two things that still seem odd or broken:
setuptools_scm
it seems like some step in the packaging is pulling absolutely everything in the repository into a package, regardless of the arguments in setup.py
or the MANIFEST.in
contents. Is that expected behavior? It seems odd given how focused the rest of this process seems to be on only distributing things that are inside the python package.environment.yml
to specify the working environment and manage dependencies. Then there's the list in install_requires
within setup.py
. There's a requirements.txt
inside the docs
directory for Sphinx. There are deps
defined in the tox.ini
file for each environment! Keeping all of that in sync seems... unlikely, at best. Is there some widely accepted mechanism or pattern for parsimoniously and self-consistently specifying dependencies across the various relevant contexts of a project?If you use setuptools_scm then you remove the manifest.in - it's no longer required. Nor you can control what you get in the sdist anymore (sdist becomes 1:1 with git repo).
You should have 2 sets of requirements: abstract (no pins, setup.py) and concrete (exact version pins, tox.ini, requirements.txt etc). There are tools to manage the pins (https://github.com/dephell/dephell, https://github.com/jazzband/pip-tools or pip freeze
)
Hmm, in the end it seemed like it was possible to use prune in the MANIFEST.in to remove the directories that are irrelevant to the distribution I'm trying to package. But maybe I am looking at the wrong thing (I wanted to include src, docs, and test, but none of the jupyter notebooks or specific analyses that were being done using the library and its outputs)
DepHell looks great! Will definitely give it a try to simplify the many environments.
What is your operating system and version? Ubuntu 19.04
What is your Python version? 3.7.3
What version of pip do you have? 19.1.1
Could you describe your issue in as much detail as possible? I am attempting to create a python package for the first time, on a project that needs to include a fair amount of "data" -- i.e. non-code files -- and I feel like I am losing my mind trying to get those files included in the package.
When I try to explicitly include files from outside of the python packages using
graft
orinclude
in theMANIFEST.in
, those directives appear to be ignored. Conversely, when I useprune
to avoid including mytest
directory, which is also a python package, that directive is also ignored.Currently, my
setup.py
looks like:And my
MANIFEST.in
looks like:When I run
python setup.py build
I get the following:The
test
directory is included, even though I tried toprune
it, and neither the defaultsettings
files for the scripts nor theid_mapping
spreadsheet were included. However theglobal-exclude
directive was respected.If instead I pass the specific directory which contains the python package I do want included by saying
find_packages('pudl')
, and also setpackage_dir={'':'pudl'}
it then fails to respect theinclude_package_data=True
and does not bring in the contents of themetadata
directory contained within the python package pudl.If instead I give
find_packages(exclude=['test'])
it still includes thetest/validation
sub-directory, and adding 'test/validation' to the list of excluded directories has no effect.Adding
recursive-exclude test
to the end ofMANIFEST.in
when usingpackages=find_packages()
has no effect, and everything within thetest
directory is included.I have been reading the Python Packaging Tutorial and also this and other posts by @ionelmc. And of course the setuptools documentation