Skip to content

Conversation

@flimsyhat
Copy link
Contributor

This PR makes some small changes to the build process and dependencies:

  1. More comprehensive clean command
  • clean command now catches additional files
  • uses Python's file ops instead of shell commands
  • clean has --dist option to clean the python distribution
  • DistCleanCommand now inherits from CleanCommand
  1. Added no-cache build option (helpful when you want to force fresh package downloads)
  • new --no-cache flag for python setup.py app
  • makefile can now optionally use PIP_NO_CACHE_DIR
  1. Added filelock to package dependencies (needed for CacheControl FileCache)

  2. Lazy initialisation for URL handling in readers.py

  • this was causing build failures since dependencies weren't yet loaded
  • only imports and sets up HTTP functionality when it's actually needed
  • provides an error message if dependencies are missing
  • allows the rest of plotdevice to work even if HTTP functionality isn't available

I've tested:

  • building app now works (wasn't working for me previously)
  • clean commands remove additional stuff
  • no-cache flag works as expected
  • URL loading in read() works properly

By prefixing the build command with PYTHONNOUSERSITE=1 we ignore user site packages, ensuring modules are properly installed into the relocatable framework.
The HTTP session was being initialized at module import time, which required
all HTTP-related dependencies to be available before plotdevice could be
imported. This caused build failures since the dependencies weren't yet
installed during the build process.

Changes:
- Made HTTP session initialization lazy via get_http_session()
- Only import HTTP dependencies when actually making requests
- Added better error message if dependencies are missing
- Updated read() function to use lazy initialization

This allows plotdevice to be imported and built without having HTTP dependencies pre-installed, fixing the circular dependency issue during installation.
Added missing dependency that was causing build failures:
- filelock: Required by cachecontrol for file caching
Updated the clean command to remove additional build artifacts:
- Added .eggs directory
- Added *.egg files
- Added __pycache__ directories
- Added .pyc files
- Added local development virtualenv
Also modified CleanCommand to:
- Added --dist flag to CleanCommand for dist cleaning
- Kept DistCleanCommand as separate command for backward compatibility
Added ability to bypass pip's cache when building the app bundle:
- Added --no-cache flag to BuildAppCommand in setup.py
- Modified Makefile to conditionally set PIP_NO_CACHE_DIR based on environment
- Allows clean builds with fresh package downloads via `python setup.py app --no-cache`
@flimsyhat flimsyhat closed this Feb 17, 2025
@flimsyhat flimsyhat deleted the build-issues branch February 17, 2025 10:29
@flimsyhat flimsyhat restored the build-issues branch February 17, 2025 11:16
@flimsyhat flimsyhat reopened this Feb 17, 2025
Copy link
Member

@samizdatco samizdatco left a comment

Choose a reason for hiding this comment

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

Thanks so much for these new setup.py features & fixes! I made a couple tweaks to the dependency lists to a) keep Python.framework and plotdevice using the same (old) version of PyObjC, and b) clear up cachecontrol's lockfile/filelock support.

I also dropped the license string from the CLASSIFIERS list (since that's apparently been deprecated?) and fixed the CI tests by manually installing setuptools now that it's no longer present by default.

Would you mind doing a test build on your end to confirm that I didn't break any of your nice work in the process?

@flimsyhat
Copy link
Contributor Author

Confirming that the build works for me! Thanks for clearing up the dependencies.

@samizdatco samizdatco merged commit ff68105 into plotdevice:main May 20, 2025
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.

2 participants