Repository navigation
Prepare crimepy-cdc 0.1.0 for PyPI - #2
Merged
Merged
Conversation
Replace setup.py with pyproject.toml, ship only the data files the library loads, and move optional imports behind extras. Co-authored-by: Andrew Wheeler <apwheele@users.noreply.github.com>
Load path strings with matplotlib's imread, and cover that case with a test. Co-authored-by: Andrew Wheeler <apwheele@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces
setup.pywith a setuptoolspyproject.tomlso the first release can be published ascrimepy-cdc(the namecrimepyis taken) while the import staysimport crimepy. Version is 0.1.0. Nothing was published and no tag was pushed.requires-pythonis>=3.11. The code usesscipy.stats.false_discovery_control(scipy>=1.11). Current wheels for numpy, scipy, pandas, geopandas, matplotlib, scikit-learn, shapely, and pyproj all support 3.11; several of the latest releases already require 3.12, so 3.10 and earlier will not resolve a current install. Python 3.6 from the oldsetup.pywas not viable.License is the SPDX expression
MITplus the existingLICENSEfile (License-ExpressionandLicense-Filein the wheel metadata). setuptools 77+ rejects the oldLicense :: OSI Approved :: MIT Licenseclassifier when an SPDX expression is set, so that classifier is omitted.cdcplot.add_logonow loads a path string with matplotlib'simread. A test passes the bundled logo path and checks that the inset image is drawn.Distributions
crimepy_cdc-0.1.0-py3-none-any.whlcrimepy_cdc-0.1.0.tar.gztwine check --strictpasses on both. Almost all of the size isdallasdata.csv.zip(5,408,512 bytes; about 25 MB uncompressed).The wheel contains the package modules plus the six files the code actually opens:
dallasdata.csv.zip,Dallas_MainArea_Proj.zip,CarrolltonGrid.csv.zipEdges_Gang1.csv,Nodes_Gang1.csvCDCWLineRec.PNG(uppercase extension, so the old*.pngpattern missed it)Loaders use
importlib.resources.as_file. A fresh venv install of the wheel imports everycrimepymodule and loads each of those files. Tests pass from the checkout, including the bundled-data tests and theadd_logopath test.Left out of the wheel and sdist (still in git for the notebooks):
bronx_data.csv,bronx_precinct.gpkg,bronx_uberhex.gpkg,CDC_Logo.svg, plus notebooks,images/, analysis outputs, and.ipynb_checkpoints.crimepy.egg-infowas gitignored and not tracked.Dependencies
Core: beautifulsoup4, cycler, folium, geopandas, lxml, matplotlib, networkx, numpy, openpyxl, pandas, pyproj, requests, scikit-learn,
scipy>=1.11, shapely.Newly declared because the code imports them directly: numpy, pyproj, cycler, and lxml (
BeautifulSoup(..., "lxml")). shapely and openpyxl stay required (query.read_datacallsread_excel). Duplicate geopandas/folium entries are gone.importlib_resourcesis dropped in favor of the stdlib.Moved into extras. Imports that used to run at module import are now lazy and name the extra in the error:
networkpmed.get_distance/ street networksopthighspyis not imported; PuLP uses it for the HiGHS solver the districting notebooks look for inpmed.av_solvnotebooksdomset.color_cytoscapegbtminstall_requirestableaualltestDropped entirely (nothing in the library or notebooks imports them, or the import was unused):
matplotlib-map-utils,tabulate, andmatplotlib-scalebar(ScaleBarwas imported ingeo.pyand never called).contextilywas imported ingeo.pyand never used; notebooks import it themselves, so it lives in[notebooks].import crimepy.pmedstill exposespmed.pulpandpmed.av_solv. Those attributes import PuLP on first use, which is what the patrol and drone notebooks read.CI
.github/workflows/ci.ymlruns pytest on Python 3.11, 3.12, and 3.13..github/workflows/publish.ymlruns onv*tags, builds once, runstwine check --strict, then publishes that artifact withpypa/gh-action-pypi-publish@release/v1in thepypienvironment.id-token: writeis only on the publish job (that job also hasactions: readso it can download the build artifact).Concerns
pip install.[network]and[opt].crimepy-cdcand a GitHub environment namedpypibefore the firstv*tag.