Skip to content

Commit

Permalink
Update setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
josiahls authored Nov 5, 2023
1 parent 3982204 commit f1c95e1
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from pkg_resources import parse_version
from configparser import ConfigParser
from setuptools.command.develop import develop
from setuptools.command.install import install
import setuptools
assert parse_version(setuptools.__version__)>=parse_version('36.2')

Expand Down Expand Up @@ -28,6 +30,27 @@
lic = licenses[cfg['license']]
min_python = cfg['min_python']

# Define the repository and branch or commit you want to install from
TORCHDATA_GIT_REPO = "https://github.com/josiahls/data.git"
TORCHDATA_COMMIT = "main" # or replace with a specific commit hash

class CustomInstall(install):
def run(self):
# Ensure that torchdata is cloned and installed before proceeding
subprocess.check_call(["git", "clone", TORCHDATA_GIT_REPO])
subprocess.check_call(["pip", "install", "./data"])
# Call the standard install.
install.run(self)

class CustomDevelop(develop):
def run(self):
# Ensure that torchdata is cloned but not installed
if not os.path.exists('data'):
subprocess.check_call(["git", "clone", TORCHDATA_GIT_REPO])
subprocess.check_call(["pip", "install", "-e", "./data"])
# Call the standard develop.
develop.run(self)

setuptools.setup(
name = cfg['lib_name'],
license = lic[0],
Expand All @@ -48,5 +71,9 @@
long_description_content_type = 'text/markdown',
zip_safe = False,
entry_points = { 'console_scripts': cfg.get('console_scripts','').split() },
cmdclass={
'install': CustomInstall,
'develop': CustomDevelop,
},
**setup_cfg)

0 comments on commit f1c95e1

Please sign in to comment.