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

Moved setuptools to main deps from dev deps #29

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 42 additions & 37 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class BuildFrontendCommand(Command):
description = 'build frontend assets'
description = "build frontend assets"
user_options = []

def initialize_options(self):
Expand All @@ -24,23 +24,33 @@ def run(self):
raise

def _build_frontend(self):
frontend_dir = Path(__file__).parent / 'frontend'
frontend_dir = Path(__file__).parent / "frontend"
if not frontend_dir.exists():
print(f"Frontend directory not found at {frontend_dir}", file=sys.stderr)
return

print("Building frontend assets...")
try:
# Run npm install with error handling
result = subprocess.run(['npm', 'install'], cwd=frontend_dir,
capture_output=True, text=True, check=False)
result = subprocess.run(
["npm", "install"],
cwd=frontend_dir,
capture_output=True,
text=True,
check=False,
)
if result.returncode != 0:
print(f"npm install failed: {result.stderr}", file=sys.stderr)
raise Exception("npm install failed")

# Run npm build with error handling
result = subprocess.run(['npm', 'run', 'build'], cwd=frontend_dir,
capture_output=True, text=True, check=False)
result = subprocess.run(
["npm", "run", "build"],
cwd=frontend_dir,
capture_output=True,
text=True,
check=False,
)
if result.returncode != 0:
print(f"npm build failed: {result.stderr}", file=sys.stderr)
raise Exception("npm build failed")
Expand All @@ -56,11 +66,11 @@ def _build_frontend(self):
raise

def _copy_assets(self, frontend_dir):
dist_dir = frontend_dir / 'dist'
dist_dir = frontend_dir / "dist"
if not dist_dir.exists():
raise Exception(f"Build directory not found at {dist_dir}")

package_static_dir = Path(__file__).parent / 'preswald' / 'static'
package_static_dir = Path(__file__).parent / "preswald" / "static"
package_static_dir.mkdir(parents=True, exist_ok=True)

# Copy dist contents
Expand All @@ -78,7 +88,7 @@ def _copy_assets(self, frontend_dir):
shutil.copy2(item, dest)

# Copy public assets
public_dir = frontend_dir / 'public'
public_dir = frontend_dir / "public"
if public_dir.exists():
print("Copying public assets...")
for item in public_dir.iterdir():
Expand All @@ -92,27 +102,27 @@ def _copy_assets(self, frontend_dir):

# Define core dependencies needed for the package to run
CORE_DEPENDENCIES = [
'fastapi>=0.68.0,<1.0.0',
'uvicorn>=0.15.0,<1.0.0',
'websockets>=10.0,<11.0',
'python-multipart>=0.0.5,<0.1.0',
'httpx>=0.23.0,<1.0.0',
'Markdown>=3.4.0',
'pandas>=1.5',
'toml==0.10.2',
'SQLAlchemy==2.0.36',
'plotly==5.24.1',
'Jinja2==3.1.4',
'click==8.1.7',
'networkx>=3.0',
'Requests==2.32.3',
"fastapi>=0.68.0,<1.0.0",
"uvicorn>=0.15.0,<1.0.0",
"websockets>=10.0,<11.0",
"python-multipart>=0.0.5,<0.1.0",
"httpx>=0.23.0,<1.0.0",
"Markdown>=3.4.0",
"pandas>=1.5",
"toml==0.10.2",
"SQLAlchemy==2.0.36",
"plotly==5.24.1",
"Jinja2==3.1.4",
"click==8.1.7",
"networkx>=3.0",
"Requests==2.32.3",
"setuptools==75.1.0",
]

# Define additional dependencies for development
DEV_DEPENDENCIES = [
'pytest>=8.3',
'setuptools==75.1.0',
'build',
"pytest>=8.3",
"build",
]

setup(
Expand All @@ -126,37 +136,32 @@ def _copy_assets(self, frontend_dir):
long_description_content_type="text/markdown",
url="https://github.com/StructuredLabs/preswald",
license="Apache License 2.0",

# Package configuration
packages=find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
],

# Package data and dependencies
include_package_data=True,
package_data={
'preswald': ['static/*', 'static/assets/*'],
"preswald": ["static/*", "static/assets/*"],
},
python_requires='>=3.7',

python_requires=">=3.7",
# Dependencies
install_requires=CORE_DEPENDENCIES,
extras_require={
'dev': DEV_DEPENDENCIES,
"dev": DEV_DEPENDENCIES,
},

# Command line interface registration
entry_points={
'console_scripts': [
'preswald=preswald.cli:cli',
"console_scripts": [
"preswald=preswald.cli:cli",
],
},

# Custom commands
cmdclass={
'build_frontend': BuildFrontendCommand,
"build_frontend": BuildFrontendCommand,
},
)