There are two ways to set up your development environment:
Hatch is a modern Python project manager that handles environments, dependencies, and builds.
- Install Hatch:
pip install hatch- Create and enter the development environment:
# This creates a virtual environment and installs all dependencies
python -m hatch shellThe hatch shell command:
- Creates an isolated environment
- Installs all development dependencies
- Activates the environment
- Sets up the project in editable mode
Important Note: The Hatch shell is for development work only. When you need to build the package, you should exit the Hatch shell first:
# Exit the Hatch shell
exit
# Build the package from outside the Hatch shell
hatch buildIf you prefer using Python's built-in virtual environment:
- Create and activate a virtual environment:
# Create a virtual environment
python -m venv .venv
# Activate the virtual environment
# On Windows:
.venv\Scripts\activate
# On Unix-like systems (Linux/macOS):
source .venv/bin/activate- Install development dependencies:
# Install the package in editable mode with development dependencies
pip install -e ".[dev]"-
Hatch Shell:
- Manages the entire project lifecycle
- Automatically handles dependency installation
- Provides consistent environments across team members
- Environment is project-specific and managed by Hatch
- Use for development, testing, and running code
- Exit the shell before running
hatch build
-
venv:
- Python's built-in virtual environment tool
- More manual control over the environment
- Requires explicit dependency installation
- Environment is managed by you
- More familiar to Python developers
- Start development:
# Enter the Hatch shell for development
python -m hatch shell- Make your changes and run tests:
# Run tests
pytest
# Run linters
ruff check .- Build the package:
# First exit the Hatch shell
exit
# Then build the package
hatch build- If you need to make more changes, repeat from step 1.
If your IDE shows import errors (like "Import could not be resolved") even after installing dependencies, you may need to configure your IDE to use the correct Python interpreter:
- Press
Ctrl+Shift+P(Windows/Linux) orCmd+Shift+P(macOS) - Type "Python: Select Interpreter"
- Choose the interpreter from your Hatch environment (it should be something like
hatch/virtual/default/Scripts/python.exeon Windows orhatch/virtual/default/bin/pythonon Unix-like systems)
- Go to
File > Settings > Project > Python Interpreter(Windows/Linux) orPyCharm > Preferences > Project > Python Interpreter(macOS) - Click the gear icon and select "Add"
- Choose "Existing Environment" and select the Python interpreter from your Hatch environment at
hatch/virtual/default/Scripts/python.exe(Windows) orhatch/virtual/default/bin/python(Unix-like systems)
- Make sure your IDE's Python extension is installed and up to date
- Try reloading your IDE window after selecting the correct interpreter
- If using VS Code, you might need to install the Pylance extension for better Python support
# Run all tests
pytest
# Run tests with coverage
pytest --cov=uxly_1shot_clientThe project uses:
- Black for code formatting
- isort for import sorting
- flake8 for linting
- mypy for type checking
You can run these tools manually:
# Format code
black src tests
# Sort imports
isort src tests
# Run linter
flake8 src tests
# Check types
mypy src testsOr use pre-commit to run them automatically on commit:
pre-commit run --all-filesThis package is published to PyPI using modern Python packaging tools. Here's how to publish a new version:
- Install the required tools globally (outside of any virtual environment):
# Install twine globally
pip install twine
# Install hatch and hatchling if you haven't already
pip install hatch hatchling- Update the version in
pyproject.toml:
[project]
version = "0.1.0" # Update this to your new version- Build the package:
# Make sure you're not in the Hatch shell
hatch build- Test the build:
# On Windows:
hatch run python -m pip install dist\uxly_1shot_client-1.2.0-py3-none-any.whl
# On Unix-like systems (Linux/macOS):
hatch run python -m pip install dist/uxly_1shot_client-1.2.0-py3-none-any.whl- Upload to PyPI:
# First, upload to TestPyPI to verify everything works
python -m twine upload --repository testpypi dist/uxly_1shot_client-1.2.0-py3-none-any.whl dist/uxly_1shot_client-1.2.0.tar.gz
# If everything looks good, upload to the real PyPI
python -m twine upload dist/uxly_1shot_client-1.2.0-py3-none-any.whl dist/uxly_1shot_client-1.2.0.tar.gz
Note: You'll need to have a PyPI account and configure your credentials. You can do this by:
- Creating a
~/.pypircfile:
[pypi]
username = your_username
password = your_passwordOr by using environment variables:
# On Windows PowerShell:
$env:TWINE_USERNAME="your_username"
$env:TWINE_PASSWORD="your_password"
# On Windows Command Prompt:
set TWINE_USERNAME=your_username
set TWINE_PASSWORD=your_password
# On Unix-like systems (Linux/macOS):
export TWINE_USERNAME=your_username
export TWINE_PASSWORD=your_passwordImportant: Make sure you're not in the Hatch shell when running twine commands. The tools should be installed globally and run from your system's Python environment.
Contributions are welcome! Please feel free to submit a Pull Request.