Skip to content

Commit

Permalink
Added setup test PyPI package
Browse files Browse the repository at this point in the history
  • Loading branch information
doc78 committed Feb 15, 2023
1 parent e0ca839 commit efa7915
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
Expand Up @@ -19,6 +19,16 @@
with open(readme_file, 'r') as f:
long_description = f.read()

"""
---------------------------------------------------------------------------------------------------------------------------------------
To publish a new version of this distribution (git tags and pypi package), after pushed on main branch:
python setup.py testpypi
python setup.py publish
Test package install
pip install --index-url https://test.pypi.org/simple/ pyg2p==3.2.1
"""

class UploadCommand(Command):
"""Support setup.py upload."""
Expand Down Expand Up @@ -55,6 +65,22 @@ def run(self):

sys.exit()

class UploadCommandTest(UploadCommand):

def run(self):
try:
self.print_console('Removing previous builds...')
rmtree(os.path.join(current_dir, 'dist'))
except OSError:
pass

self.print_console('Building Source and Wheel (universal) distribution...')
os.system('{} setup.py sdist'.format(sys.executable))

self.print_console('Uploading the package to test PyPI via Twine...')
os.system('twine upload --repository testpypi dist/*')

sys.exit()

def setup_data_files(setup_args_):
user_conf_dir = f'{os.path.expanduser("~")}/.pyg2p/'
Expand Down Expand Up @@ -114,6 +140,7 @@ def _get_gdal_version():
cmdclass={
'upload': UploadCommand,
'publish': UploadCommand,
'testpypi': UploadCommandTest,
},
classifiers=[
# complete classifier list: http://pypi.python.org/pypi?%3Aaction=list_classifiers
Expand Down

0 comments on commit efa7915

Please sign in to comment.